You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.0 KiB
66 lines
1.0 KiB
8 years ago
|
#!/bin/sh
|
||
|
|
||
|
[ -x /bin/lcd4linux ] || exit 1
|
||
|
[ -e /tmp/.lcd-* ] || exit 1
|
||
|
|
||
8 years ago
|
. /etc/init.d/globals
|
||
|
|
||
8 years ago
|
configfile() {
|
||
|
read layout < /tmp/lcd/layout
|
||
6 years ago
|
test ${layout##*_} = user && CONF_DIR=/var/etc || CONF_DIR=/etc
|
||
8 years ago
|
|
||
|
chmod 600 ${CONF_DIR}/lcd4linux.conf
|
||
|
chown 0:0 ${CONF_DIR}/lcd4linux.conf
|
||
|
|
||
|
printf "${CONF_DIR}/lcd4linux.conf"
|
||
|
}
|
||
|
|
||
|
doStart() {
|
||
|
( # do always run in background
|
||
|
while [ ! -e /tmp/.lcd4linux ]; do sleep 2; done
|
||
|
/bin/lcd4linux -f $(configfile)
|
||
|
) &
|
||
|
}
|
||
|
|
||
|
doStop() {
|
||
7 years ago
|
if [ -e /var/run/lcd4linux.pid ]; then
|
||
8 years ago
|
# read pid from pidfile
|
||
7 years ago
|
read PID < /var/run/lcd4linux.pid
|
||
8 years ago
|
|
||
|
# kill child processes
|
||
|
CHILDS=$(ps -o pid --ppid $PID --no-heading)
|
||
|
for CHILD in $CHILDS; do
|
||
|
kill -KILL $CHILD
|
||
|
done
|
||
|
sleep 5
|
||
|
|
||
|
# terminate main process
|
||
|
kill -TERM $PID > /dev/null 2>&1 &
|
||
|
sleep 5
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
doOff() {
|
||
|
echo "LCD::backlight(0)" | /bin/lcd4linux -i > /dev/null 2>&1
|
||
|
}
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
|
doStart
|
||
|
;;
|
||
|
stop)
|
||
|
doStop
|
||
|
;;
|
||
|
off)
|
||
|
doStop
|
||
|
doOff
|
||
|
;;
|
||
|
restart|reload)
|
||
|
doStop
|
||
|
doStart
|
||
|
;;
|
||
|
*)
|
||
8 years ago
|
echo "[${BASENAME}] Usage: $0 {start|stop|off|restart|reload}"
|
||
8 years ago
|
;;
|
||
|
esac
|