Continue conversion test + HTML.supports() fix
[fanfix.git] / fanfix.sysv
CommitLineData
d9cb7150
NR
1#!/bin/sh
2#
3# fanfix This starts the Fanfix remote service.
4#
5# chkconfig: 2345 10 90
6# description: Starts the Fanfix remote service
7#
8### BEGIN INIT INFO
9# Short-Description: Fanfix service
10# Description: Starts the Fanfix remote service
11### END INIT INFO
12
13ENABLED=true
14USER=fanfix
15
16JAR=/path/to/fanfix.jar
17PINCODE="my password"
18PORT=12000
19
20FPID=/tmp/fanfix.pid
21OUT=/var/log/fanfix
22ERR=/var/log/fanfix.err
23
24if [ "$ENABLED" != true ]; then
25 [ "$1" != status ]
26 exit $?
27fi
28
29if [ ! -e "$JAR" ]; then
30 echo "Canot find main jar file: $JAR" >&2
31 exit 4
32fi
33
34case "$1" in
35start)
36 if sh "$0" status --quiet; then
37 echo "Fanfix is already running." >&2
38 false
39 else
40 sudo -u "$USER" -- java -jar "$JAR" --server "$PINCODE" "$PORT" > "$OUT" 2> "$ERR" &
41 echo $! > "$FPID"
42 fi
43
44 sleep 0.1
45 sh "$0" status --quiet
46;;
47stop)
48 if sh "$0" status --quiet; then
49 sudo -u "$USER" -- java -jar "$JAR" --stop-server "$PINCODE" "$PORT"
50 fi
51
52 i=1
53 while [ $i -lt 100 ]; do
54 if sh "$0" status --quiet; then
55 echo -n . >&2
56 sleep 1
57 fi
58 i=`expr $i + 1`
59 done
60 echo >&2
61
62 if sh "$0" status --quiet; then
63 echo "Process not responding, killing it..." >&2
64 kill "`cat "$FPID"`"
65 sleep 10
66 kill -9 "`cat "$FPID"`" 2>/dev/null
67 fi
68
48587cad 69 rm -f "$FPID"
d9cb7150
NR
70;;
71restart)
72 sh "$0" stop
73 sh "$0" start
74;;
75status)
76 if [ -e "$FPID" ]; then
77 if [ "$2" = "--quiet" ]; then
78 ps "`cat "$FPID"`" >/dev/null
79 else
80 ps "`cat "$FPID"`" >/dev/null \
81 && echo service is running >&2
82 fi
83 else
84 false
85 fi
86;;
87*)
88 echo $"Usage: $0 {start|stop|status|restart}" >&2
89 false
90;;
91esac
92