aboutsummaryrefslogtreecommitdiff
path: root/system/system76-power/config/rc.system76-power
blob: 93e3e25dfa77e335236132fc2c4a5d015fa830e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/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