File: codeville.init

package info (click to toggle)
codeville 0.8.0-2.1
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 1,140 kB
  • sloc: python: 10,335; ansic: 89; sh: 62; makefile: 25
file content (98 lines) | stat: -rw-r--r-- 1,954 bytes parent folder | download | duplicates (2)
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
#! /bin/sh

### BEGIN INIT INFO
# Provides:          codeville
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $network $local_fs $remote_fs
# Should-Start:      
# Should-Stop:       
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start a codeville server
# Description:       Starts a codeville daemon for remote
#                    access to codeville repositories.
### END INIT INFO

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="codeville server"
NAME=cdvserver
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/codeville

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

DATADIR=/var/lib/codeville
LOGFILE=/var/log/codeville.log

# Read config file if it is present.
if [ -r /etc/default/codeville ]
then
. /etc/default/codeville
fi

# Add optional option $1 with argument $2 to OPTS, if $2 is nonempty
add_opt () {
if ! test -z "$2" ; then
OPTS="$OPTS $1 $2"
fi
}

# Add arguments for start-stop-daemon, based on variables set in
# /etc/default/$NAME
OPTS=""
add_opt --chroot "$DAEMONCHROOT"
add_opt --chdir "$DAEMONCHDIR"
add_opt --nicelevel "$DAEMONNICE"
METAOPTS="$OPTS"

#
#Function that starts the daemon/service.
#
d_start() {
if [ $START_CODEVILLE -ne 1 ]; then
	echo -n "disabled in /etc/default/codeville"
else
	echo -n "$NAME"
	start-stop-daemon --start --background --quiet \
	--pidfile "$PIDFILE" \
	$METAOPTS \
	--exec $DAEMON -- -c /etc/cdvserver.conf
fi
}

#
#Function that stops the daemon/service.
#
d_stop() {
start-stop-daemon --stop --oknodo --quiet --pidfile "$PIDFILE"
}

case "$1" in
  start)
echo -n "Starting $DESC: "
d_start
echo "."
;;
  stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
  restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
  *)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0