slackbuilds/system/system76-power/config/rc.system76-power

61 lines
1019 B
Bash

#!/bin/sh
# Start system76-power daemon
#
LOG_FILE=/var/log/system76-power.log
add_log_msg() {
echo "[$(date "+%Y-%m-%d %T")] $1" >> $LOG_FILE
}
s76pwr_start() {
PWR_DIR=/usr/bin
if [ -x $PWR_DIR/system76-power ] ; then
echo "Starting system76-power..."
add_log_msg "Starting system76-power daemon from /etc/rc.d/rc.system76-power"
$PWR_DIR/system76-power daemon >>$LOG_FILE 2>&1 &
fi
}
s76pwr_stop() {
add_log_msg "Killing system76-power daemon from /etc/rc.d/rc.system76-power"
killall system76-power 2> /dev/null
}
s76pwr_restart() {
s76pwr_stop
sleep 1
s76pwr_start
}
s76pwr_help() {
cat <<EOF
usage: $0 start|stop|restart
$0 start
Starts the system76-power daemon
$0 stop
Stops the system76-power daemon
$0 restart
Restarts the system76-power daemon
EOF
}
case "$1" in
'start')
s76pwr_start
;;
'stop')
s76pwr_stop
;;
'restart')
s76pwr_restart
;;
*)
s76pwr_help
;;
esac