Sophie

Sophie

distrib > Mageia > 8 > i586 > media > core-updates_testing-src > by-pkgid > 30904ee9988b644cfe4ae84db264678d > files > 17

syslog-ng-3.30.1-2.1.mga8.src.rpm

#!/bin/bash

CFGNAME=journald.conf

## This script takes as a a first argument the directory containing
## the systemd journal configuration file (journald.conf). According
## to the value of the second argument, the script either saves the
## current journald.conf file and switches on systemd forwarding to
## syslog; or restore the back-up file

if [ $# -ne 2 ]; then
    echo "syslog-ng_switchfwd should be called with 2 arguments"
    exit 1
fi

JNLDIR=$1
SYSFWD=$2

JNLFILE=$1/$CFGNAME
JNLSAVE=$JNLFILE.syslog-ng

#exit if file is not found
if [ ! -r $JNLFILE ]; then
    echo "systemd journal configuration file not found!"
    exit 1
fi


case $SYSFWD in
    yes | 1 | on)

#abort if it already exists
	if [ -r $JNLSAVE ]; then
	    echo "journal configuration file already modified!"
	    exit 1
	fi
	
	#save the current file
	mv $JNLFILE $JNLSAVE

	#edit the new
	cp $JNLSAVE $JNLFILE
	echo "switching on syslog forwarding in: $JNLFILE"
	sed -i 's|#ForwardToSyslog=no|ForwardToSyslog=yes|g' $JNLFILE

	;;
    no | 0 | off)
#abort if it does not exist
	if [ ! -r $JNLSAVE ]; then
	    echo "saved journal configuration file not found!"
	    exit 1
	fi
	echo "restoring original journal configuration from $JNLSAVE"
	mv $JNLSAVE $JNLFILE
	;;
    *)
	echo "invalid argument"
	exit 1
esac

exit 0