/
rocraild
executable file
·84 lines (73 loc) · 1.86 KB
/
rocraild
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: rocrail
# Required-Start: $network
# X-UnitedLinux-Should-Start:
# Required-Stop:
# X-UnitedLinux-Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the Rocrail Daemon
# Description: Starts the Rocrail Daemon
### END INIT INFO
# --- Start of options ---
# Path to Rocrail install directory. Default path is /opt/rocrail
rocrail_DIR=/opt/rocrail
# Path to Rocrail working directory. Default path is the same as in $rocrail_DIR
WORKDIR=$rocrail_DIR
# Path to Rocrail library directory. Default path is the same as in $rocrail_DIR
LIBDIR=$rocrail_DIR
# Path to Rocrail image directory. Default path is the same as in $rocrail_DIR
IMGDIR=$rocrail_DIR
# Check for serial devices at startup. If yes leave this blank, if no set it to -nodevcheck
DEVCHECK=-nodevcheck
# --- End of options ---
rocrail_PID=$(ps -C rocrail -o pid=)
if [ ! -e $rocrail_DIR/rocrail ] ; then
echo Rocrail is not installed
exit 5
fi
case "$1" in
start)
if [ -n "$rocrail_PID" ] ; then
$0 status
else
echo "Starting Rocrail (> $rocrail_DIR/nohup.out)"
rm -f $rocrail_DIR/nohup.out
nohup $rocrail_DIR/rocrail $DEVCHECK -w $WORKDIR -l $LIBDIR -img $IMGDIR > $rocrail_DIR/nohup.out 2>&1 &
fi
;;
stop)
if [ -n "$rocrail_PID" ] ; then
echo Shutting down Rocrail
kill $rocrail_PID
else
$0 status
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
if [ -n "$rocrail_PID" ] ; then
echo Rocrail is up and running with PID $rocrail_PID
exit 4
else
echo Rocrail is not running
exit 5
fi
;;
deltrace)
$0 stop
sleep 1
echo Erase Trace-Files
rm -f $WORKDIR/*.trc
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|status|deltrace}"
exit 1
esac
exit 0