-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathS60tty2tft
executable file
·69 lines (63 loc) · 1.73 KB
/
S60tty2tft
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
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
#
! [ "$(dos2unix -ic /media/fat/tty2tft/*.ini)" = "" ] && dos2unix -k -q /media/fat/tty2tft/*.ini
. /media/fat/tty2tft/tty2tft-system.ini
. /media/fat/tty2tft/tty2tft-user.ini
cd /tmp
# Start
start() {
### Wait for USB module and start tty2tft daemon
WAITEND=$((SECONDS+10))
while ! [ -c ${TTYDEV} ] && [ ${SECONDS} -lt ${WAITEND} ]; do
sleep 0.1
done
if ! [ -c ${TTYDEV} ]; then
echo "Could not find the needed USB module ${TTYDEV}. Exiting."
exit 1
fi
if [[ -x ${DAEMONSCRIPT} ]]; then
if [ -e /run/tty2tft-daemon.pid ] && [ -d /proc/$(</run/tty2tft-daemon.pid) ]; then
echo "${DAEMONNAME} already running"
exit 1
else
echo "Starting ${DAEMONNAME}..."
${DAEMONSCRIPT} & echo $! > /run/tty2tft-daemon.pid
fi
else
echo "${DAEMONSCRIPT} not found!"
fi
}
# Stop
stop() {
echo "Stopping ${DAEMONNAME}..."
if [ -e /run/tty2tft-daemon.pid ]; then
PIDDAEMON=$(</run/tty2tft-daemon.pid)
PIDINOTIFY=$(ps -eo pid,ppid,args | grep $(ps | grep tty2tft | awk 'NR==1{print $1}') | tail -1 | awk '{print $1}')
#[ -e /run/tty2tft-daemon.pid ] && PIDDAEMON=$(</run/tty2tft-daemon.pid)
#[ -e /run/tty2tft-inotify.pid ] && PIDINOTIFY=$(</run/tty2tft-inotify.pid)
[ ${PIDDAEMON} ] && kill ${PIDDAEMON}
[ ${PIDINOTIFY} ] && kill ${PIDINOTIFY}
rm -f /run/tty2tft-daemon.pid
#rm -f /run/tty2tft-daemon.pid /run/tty2tft-inotify.pid
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
# reload)
# reload
# ;;
*)
# echo "Usage: $0 {start|stop|restart|reload}"
echo "Usage: $0 {start|stop|restart}"
exit 1
esac