-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrx-etersoft.init
executable file
·139 lines (130 loc) · 2.64 KB
/
rx-etersoft.init
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
#
# chkconfig: 2345 95 15
# description: Starts and stops the RX Etersoft service
# processname: nxserver
### BEGIN INIT INFO
# Provides: freenx_server
# Required-Start: sshd
# Required-Stop: sshd
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: RX Etersoft Server
# Description: Cleanup RX Etersoft Server session database at boot time
### END INIT INFO
# Read the config file
. $(PATH=$(cd $(dirname $0) && pwd):$PATH which nxloadconfig) --
SERVNAME=`basename $0`
AUTH_NAME=$NX_HOME_DIR/.ssh/$SSH_AUTHORIZED_KEYS
LOCKFILE=/var/lock/$SERVNAME
OUTFORMAT=/etc/init.d/outformat
[ -x $OUTFORMAT ] || OUTFORMAT=/usr/share/misc/$SERVNAME.outformat
if which tput >/dev/null && test -x $OUTFORMAT ; then
. $OUTFORMAT
else
MOVE_TO_COL(){ :; }
SETCOLOR_SUCCESS(){ :; }
SETCOLOR_FAILURE(){ :; }
SETCOLOR_WARNING(){ :; }
SETCOLOR_NORMAL(){ :; }
fi
success()
{
MOVE_TO_COL
echo -n '[ '
SETCOLOR_SUCCESS
echo -n 'DONE'
SETCOLOR_NORMAL
echo ' ]'
}
failure()
{
MOVE_TO_COL
echo -n '['
SETCOLOR_FAILURE
echo -n 'FAILED'
SETCOLOR_NORMAL
echo ']'
}
passed()
{
MOVE_TO_COL
echo -n '['
SETCOLOR_WARNING
echo -n 'PASSED'
SETCOLOR_NORMAL
echo ']'
}
start()
{
#check for first run
[[ ! ( -e "$AUTH_NAME" ) && ! ( -e "$AUTH_NAME.disabled" ) ]] && $PATH_BIN/rxsetup --init
echo -n $"Starting $SERVNAME service: "
if [ -e $LOCKFILE ] ; then
passed
exit 1
fi
[ ! -d "/tmp/.X11-unix" ] && mkdir -m1777 /tmp/.X11-unix/
$PATH_BIN/nxserver --cleanup > /dev/null 2>&1
$PATH_BIN/nxserver --start > /dev/null 2>&1
#status_cmd
ret=`$PATH_BIN/nxserver --status | grep 'run' | wc -l`
if [ $ret -eq 1 ] ; then
touch $LOCKFILE
success
else
failure
fi
}
stop()
{
echo -n $"Stopping $SERVNAME service: "
if [ -e $LOCKFILE ] ; then
$PATH_BIN/nxserver --stop > /dev/null 2>&1
$PATH_BIN/nxserver --cleanup > /dev/null 2>&1
ret=`$PATH_BIN/nxserver --status | grep 'run' | wc -l`
if [ $ret -eq 0 ] ; then
rm -f $LOCKFILE
success
else
failure
fi
else
passed
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -e $LOCKFILE ] ; then
stop
start
fi
;;
condstop)
if [ -e $LOCKFILE ] ; then
stop
fi
;;
status)
$PATH_BIN/nxserver --status
;;
setup)
$PATH_BIN/nxsetup --install
;;
check)
$PATH_BIN/nxsetup --test
;;
*)
echo "Usage: $0 <start|stop|restart|condrestart|condstop|status|setup|check>"
;;
esac