-
Notifications
You must be signed in to change notification settings - Fork 10
/
generic.initscript
executable file
·90 lines (79 loc) · 1.55 KB
/
generic.initscript
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
#! /bin/sh
#
# HDA_SERVER: Starts the ServerTweet Daemon
#
# chkconfig: 345 96 03
# description: This is a daemon which runs on the servertweet daemon
#
# processname: transmission-daemon
# config:
# Source function library.
. /etc/init.d/functions
DAEMON=HDA_SERVER
PROGRAM_NAME="ServerTweet"
PROGRAM_BIN=/var/hda/platform/apps/servertweet/$DAEMON
PROGRAM_DIR=/var/hda/platform/html
LOCKFILE=/var/lock/subsys/$DAEMON
PIDFILE=/var/run/$DAEMON.pid
DAEMON_USER=apache
if [[ ! -e $PROGRAM_DIR ]]; then
mkdir -p $PROGRAM_DIR
fi
if [ "$1" == 'status' ]; then
test -x $PROGRAM_BIN || exit 4
else
test -x $PROGRAM_BIN || exit 5
fi
base=${0##*/}
start() {
echo -n $"Starting $PROGRAM_NAME daemon... "
daemon --user $DAEMON_USER $PROGRAM_BIN -w $PROGRAM_DIR
RETVAL=$?
if [ $RETVAL = 0 ]; then
touch $LOCKFILE
pidof $DAEMON > $PIDFILE
success $"$base startup"
else
failure $"$base startup"
fi
echo
return $RETVAL
}
stop() {
echo -n $"Shutting down $PROGRAM_NAME daemon: "
killproc $DAEMON
RETVAL=$?
[ $RETVAL = 0 ] && success $"$base shutdown" || failure $"$base shutdown"
rm -f $LOCKFILE $PIDFILE
echo
return $RETVAL
}
restart() {
stop
start
}
RETVAL=0
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $DAEMON
RETVAL=$?
;;
restart)
restart
;;
condrestart)
[ ! -f $lockfile ] || restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
;;
esac
exit $RETVAL