forked from lageIBUSP/notaR-legacy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rserve
executable file
·68 lines (57 loc) · 943 Bytes
/
rserve
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
#! /bin/sh
### BEGIN INIT INFO
# Provides: rserve
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Executes the rserve in daemon mode
# Description:
### END INIT INFO
## Config
# Default user:
USR="rserve"
start() {
echo -n "Starting Rserve... "
su - ${USR} -c "R --vanilla <<EOF
library(Rserve)
Rserve(args=\"--no-save\")
EOF" > /dev/null
$0 status
}
status() {
local GREEN="\033[0;32m"
local RED="\033[0;31m"
local NO_COLOUR="\033[0m"
N=`ps -ef | grep Rserve | wc -l`
if [ "$N" -lt 2 ]; then
echo "Rserve is ${RED}down${NO_COLOUR}.";
else
echo "Rserve is ${GREEN}up${NO_COLOUR}.";
fi
}
stop() {
echo -n "Shutting down Rserve... "
killall -9 Rserve
$0 status
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|reload|force-reload)
stop
start
;;
*)
echo "Usage: $0 start|stop|status|restart" >&2
exit 3
;;
esac
: