blob: 7632ff2b807273014d4f964b4ce15a1ce7d436f6 [file] [log] [blame]
#! /bin/sh
#
# Laptop mode tools module: syslog.conf switching functionality (DEPRECATED)
#
#
# This module implements the old syslog.conf functionality -- deprecated but
# still supported for backward compatibility.
#
if [ x$CONTROL_SYSLOG_CONF = x1 ] ; then
log "VERBOSE" "Adjusting syslog configuration."
if [ "`readlink -f $SYSLOG_CONF`" != "$SYSLOG_CONF" ] ; then
log "MSG" "$SYSLOG_CONF is a symlink."
if [ ! -f "$SYSLOG_CONF.no-lm" ] ; then
log "VERBOSE" "But there is no $SYSLOG_CONF.no-lm. This must have been done by an earlier"
log "VERBOSE" "version of laptop-mode-tools."
log "VERBOSE" "Creating it now from $NOLM_AC_SYSLOG_CONF."
cp "$NOLM_AC_SYSLOG_CONF" "$SYSLOG_CONF.no-lm"
fi
else
log "VERBOSE" "$SYSLOG_CONF is not a symlink."
if [ "$STATE" = "enabled" ] ; then
log "VERBOSE" "Saving it to $SYSLOG_CONF.no-lm."
cp --backup=numbered "$SYSLOG_CONF" "$SYSLOG_CONF.no-lm"
fi
fi
if [ "$STATE" != "enabled" ] ; then
log "VERBOSE" "Laptop mode is not enabled. Restoring $SYSLOG_CONF."
if [ -f "$SYSLOG_CONF.no-lm" ] ; then
mv "$SYSLOG_CONF.no-lm" "$SYSLOG_CONF"
elif [ "`readlink -f $SYSLOG_CONF`" != "$SYSLOG_CONF" ] ; then
echo "ERROR: $SYSLOG_CONF is a symlink but $SYSLOG_CONF.no-lm is not present."
fi
elif [ $ON_AC -eq 1 ] ; then
if [ "$ACTIVATE" -eq 1 ] ; then
log "VERBOSE" "Setting syslog config to $LM_AC_SYSLOG_CONF."
ln -fs "$LM_AC_SYSLOG_CONF" "$SYSLOG_CONF"
else
log "VERBOSE" "Setting syslog config to $NOLM_AC_SYSLOG_CONF."
ln -fs "$NOLM_AC_SYSLOG_CONF" "$SYSLOG_CONF"
fi
else
log "VERBOSE" "Setting syslog config to $BATT_SYSLOG_CONF."
ln -fs "$BATT_SYSLOG_CONF" "$SYSLOG_CONF"
fi
# Notify syslogd of configuration change.
if [ "$SYSLOG_CONF_SIGNAL_PROGRAM" != "" ] ; then
log "VERBOSE" "Sending SIGHUP to all $SYSLOG_CONF_SIGNAL_PROGRAM processes."
killall -q -HUP $SYSLOG_CONF_SIGNAL_PROGRAM
fi
fi