-
Notifications
You must be signed in to change notification settings - Fork 436
/
start-debian-template
81 lines (66 loc) · 1.95 KB
/
start-debian-template
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
#! /bin/bash
### BEGIN INIT INFO
# Provides: ${{app_name}}
# Required-Start: ${{start_facilities}}
# Required-Stop: ${{stop_facilities}}
# Default-Start: ${{start_runlevels}}
# Default-Stop: ${{stop_runlevels}}
# Short-Description: ${{descr}}
### END INIT INFO
source /lib/init/vars.sh
source /lib/lsb/init-functions
# adding bashScriptEnvConfigLocation
[[ -f ${{env_config}} ]] && . ${{env_config}}
# $JAVA_OPTS used in $RUN_CMD wrapper
export JAVA_OPTS
# If program manages its own PID file then it
# should declare its location in PIDFILE
if [ -z "$PIDFILE" ]; then
create_pidfile=true
PIDFILE=/var/run/${{app_name}}/running.pid
fi
if [ -z "$DAEMON_USER" ]; then
DAEMON_USER=${{daemon_user}}
fi
if [ -z "$DAEMON_GROUP" ]; then
DAEMON_GROUP=${{daemon_group}}
fi
RUN_CMD="${{chdir}}/bin/${{exec}}"
start_daemon() {
log_daemon_msg "Starting" "${{app_name}}"
[ -d "/var/run/${{app_name}}" ] || install -d -o "$DAEMON_USER" -g "$DAEMON_GROUP" -m755 "/var/run/${{app_name}}"
if [ "$create_pidfile" = true ]; then
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS
else
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS
fi
log_end_msg $?
}
stop_daemon() {
log_daemon_msg "Stopping" "${{app_name}}"
start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" --retry=TERM/${{term_timeout}}/KILL/${{kill_timeout}}
log_end_msg $?
rm -f "$PIDFILE"
}
case "$1" in
start)
start_daemon
exit $?
;;
stop)
stop_daemon
exit $?
;;
restart|force-reload)
stop_daemon
start_daemon
exit $?
;;
status)
status_of_proc -p "$PIDFILE" "$RUN_CMD" ${{app_name}} && exit 0 || exit $?
;;
*)
log_daemon_msg "Usage: /etc/init.d/${{app_name}} {start|stop|restart|status}"
;;
esac
exit 0