forked from Cloud-Foundations/Dominator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimageserver.Debian-7
executable file
·120 lines (94 loc) · 2.48 KB
/
imageserver.Debian-7
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
#! /bin/bash --posix
### BEGIN INIT INFO
# Provides: imageserver
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Dominator imageserver
### END INIT INFO
# /etc/init.d/imageserver: start and stop the Dominator imageserver
. /lib/lsb/init-functions
umask 022
readonly default_log_dir='/var/log/imageserver'
ARCHIVE_MODE=false
DAEMON='/usr/local/sbin/imageserver'
FD_LIMIT=unlimited
IMAGE_DIR=
IMAGE_SERVER_HOSTNAME=
LOG_DIR="$default_log_dir"
LOG_QUOTA=
LOGBUF_LINES=
LOOP_PIDFILE='/var/run/imageserver.loop.pid'
OBJECT_DIR=
PIDFILE='/var/run/imageserver.pid'
USERNAME='imageserver'
PROG_ARGS=
[ -f /etc/default/imageserver ] && . /etc/default/imageserver
test -x "$DAEMON" || exit 0
export PATH="${PATH:+$PATH:}/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin"
if [ -n "$FD_LIMIT" ]; then
ulimit -n "$FD_LIMIT"
fi
mkdir -m 0755 -p "$LOG_DIR"
chown "$USERNAME" "$LOG_DIR"
if [ "$ARCHIVE_MODE" = "true" ] || [ "$ARCHIVE_MODE" = "1" ]; then
PROG_ARGS="$PROG_ARGS -archiveMode=true"
fi
if [ -n "$IMAGE_DIR" ]; then
PROG_ARGS="$PROG_ARGS -imageDir=$IMAGE_DIR"
fi
if [ -n "$IMAGE_SERVER_HOSTNAME" ]; then
PROG_ARGS="$PROG_ARGS -imageServerHostname=$IMAGE_SERVER_HOSTNAME"
fi
if [ -n "$LOG_DIR" ] && [ "$LOG_DIR" != "$default_log_dir" ]; then
PROG_ARGS="$PROG_ARGS -logDir=$LOG_DIR"
fi
if [ -n "$LOG_QUOTA" ]; then
PROG_ARGS="$PROG_ARGS -logQuota=$LOG_QUOTA"
fi
if [ -n "$LOGBUF_LINES" ]; then
PROG_ARGS="$PROG_ARGS -logbufLines=$LOGBUF_LINES"
fi
if [ -n "$OBJECT_DIR" ]; then
PROG_ARGS="$PROG_ARGS -objectDir=$OBJECT_DIR"
fi
do_start ()
{
start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
--exec "$DAEMON" --chuid "$USERNAME" --make-pidfile -- \
$PROG_ARGS
}
start_loop ()
{
echo "$BASHPID" > "$LOOP_PIDFILE"
while true; do
do_start
rm -f "$PIDFILE"
sleep 1
done
}
case "$1" in
start)
log_daemon_msg "Starting imageserver daemon" "imageserver" || true
(start_loop < /dev/null &> /dev/null &)
;;
stop)
log_daemon_msg "Stopping imageserver daemon" "imageserver" || true
[ -s "$LOOP_PIDFILE" ] && kill -KILL $(cat "$LOOP_PIDFILE")
[ -s "$PIDFILE" ] && kill -TERM $(cat "$PIDFILE")
rm -f "$LOOP_PIDFILE" "$PIDFILE"
;;
reload|force-reload)
$0 stop
$0 start
;;
restart)
$0 stop
$0 start
;;
*)
log_action_msg "Usage: /etc/init.d/imageserver {start|stop|reload|force-reload|restart}" || true
exit 1
esac
exit 0