forked from MiSTer-devel/xow_MiSTer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xow_init_script
executable file
·97 lines (82 loc) · 1.65 KB
/
xow_init_script
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
########################################################################
#
# Description : xow user mode driver service
#
# Authors : John K. <[email protected]>
#
# Version : 1.0
#
# Notes : https://github.com/medusalix/xow
#
########################################################################
XOW_BINARY=/media/fat/linux/xow
XOW_COMPATIBILITY=0 # 0 = normal mode, 1 = compatibility mode
XOW_CONSOLE_LOG=0 # 0 = disabled, 1 = console logging
[ -f $XOW_BINARY ] || exit 0
is_running() {
[ ! -z "$(pidof xow)" ]
}
status() {
if is_running ; then
echo "xow server is running."
else
echo "xow server is NOT running."
fi
}
start() {
if is_running ; then
echo "xow service is already running."
exit 0
fi
printf "Starting xow service: "
if [ "$XOW_CONSOLE_LOG" = "1" ]; then
$XOW_BINARY &
else
$XOW_BINARY >/dev/null 2>&1 &
fi
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
stop() {
if ! is_running ; then
echo "xow service is not running."
exit 0
fi
printf "Shutting down xow service: "
kill -9 `pidof xow`
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
restart() {
stop
start
}
pair() {
if ! is_running ; then
echo "ERROR: xow service is not running."
exit 0
fi
printf "Enabling pairing mode: "
kill -s USR1 `pidof xow`
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
pair)
pair
;;
*)
echo "Usage: $0 {start|stop|restart|status|pair}"
exit 1
esac
exit $?