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.
65 lines
1.0 KiB
65 lines
1.0 KiB
#!/bin/sh
|
|
|
|
[ -x /bin/lcd4linux ] || exit 1
|
|
[ -e /tmp/.lcd-* ] || exit 1
|
|
|
|
. /etc/init.d/globals
|
|
|
|
configfile() {
|
|
read layout < /tmp/lcd/layout
|
|
test ${layout##*_} = user && CONF_DIR=/var/etc || CONF_DIR=/etc
|
|
|
|
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() {
|
|
if [ -e /var/run/lcd4linux.pid ]; then
|
|
# read pid from pidfile
|
|
read PID < /var/run/lcd4linux.pid
|
|
|
|
# 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
|
|
;;
|
|
*)
|
|
echo "[${BASENAME}] Usage: $0 {start|stop|off|restart|reload}"
|
|
;;
|
|
esac
|
|
|