]> git.proxmox.com Git - pve-sheepdog.git/blame - debian/pve-sheepdog.sheepdog.init.d
allow to set DAEMON_ARGS in /etc/default/sheepdog
[pve-sheepdog.git] / debian / pve-sheepdog.sheepdog.init.d
CommitLineData
ff62b221
DM
1#!/bin/sh
2### BEGIN INIT INFO
3# Provides: sheepdog
7bf46d8c
AD
4# Required-Start: $network $remote_fs $syslog cman
5# Required-Stop: $network $remote_fs $syslog cman
ff62b221
DM
6# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6
8# Short-Description: Sheepdog server
9# Description: Sheepdog server
10### END INIT INFO
11
12# Author: Proxmox Support Team <support@proxmox.com>
13
14# PATH should only include /usr/* if it runs after the mountnfs.sh script
15PATH=/sbin:/usr/sbin:/bin:/usr/bin
16DESC="Sheepdog Server" # Introduce a short description here
17NAME=sheepdog # Introduce the short server's name here
18DAEMON=/usr/sbin/sheep # Introduce the server's location here
ff62b221 19SCRIPTNAME=/etc/init.d/$NAME
506d51be 20PIDFILE="/var/run/sheep.pid"
ff62b221
DM
21
22# Exit if the package is not installed
23[ -x $DAEMON ] || exit 0
24
506d51be
AD
25ROOTDIR="/var/lib/sheepdog/"
26JOURNALSIZE="256"
60c4ccff 27DAEMON_ARGS=""
75a10ce5 28
ff62b221
DM
29# Read configuration variable file if it is present
30[ -r /etc/default/$NAME ] && . /etc/default/$NAME
31
32if [ "$START" != "yes" ]; then
33 exit 0
34fi
35
ff62b221
DM
36. /lib/lsb/init-functions
37
38#
39# Function that starts the daemon/service
40#
41do_start()
42{
ff62b221
DM
43 mkdir -p /var/run
44
a30f86c5 45 # Return
ff62b221
DM
46 # 0 if daemon has been started
47 # 1 if daemon was already running
48 # 2 if daemon could not be started
506d51be
AD
49 ulimit -n 1024000 #avoid check_host_env(395) WARN: Allowed open files 1024 too small, suggested 1024000 warning message
50 ulimit -c unlimited #avoid check_host_env(404) Allowed core file size 0, suggested unlimited warning message
60c4ccff 51 DAEMON_ARGS="${DAEMON_ARGS} --pidfile ${PIDFILE}"
506d51be
AD
52 DAEMON_ARGS="${DAEMON_ARGS} $ROOTDIR"
53
54 # /path/to/meta-store,/path/to/disk1{,/path/to/disk2,...}
55 for d in $ROOTDIR/disc*
56 do
57 if [ -d "$d" ]; then
58 DAEMON_ARGS="${DAEMON_ARGS},$d"
07e2d38c 59 fi
506d51be 60 done
a30f86c5 61
506d51be
AD
62 if [ -d "$ROOTDIR/journal" ]; then
63 DAEMON_ARGS="${DAEMON_ARGS} -j dir=$ROOTDIR/journal,size=$JOURNALSIZE"
a30f86c5 64
506d51be
AD
65 fi
66 status_of_proc -p ${PIDFILE} $DAEMON "$NAME" >/dev/null && continue
67 start-stop-daemon --start --quiet --pidfile ${PIDFILE} --exec $DAEMON -- $DAEMON_ARGS || return 2
a30f86c5
DM
68
69 return 0
ff62b221
DM
70}
71
72#
73# Function that stops the daemon/service
74#
75do_stop()
76{
77 # Return
78 # 0 if daemon has been stopped
79 # 1 if daemon was already stopped
80 # 2 if daemon could not be stopped
81 # other if a failure occurred
ff62b221 82
506d51be 83 start-stop-daemon --stop --oknodo --retry=TERM/20/KILL/5 --quiet --pidfile ${PIDFILE} --exec $DAEMON || return 2
ff62b221
DM
84}
85
86case "$1" in
75a10ce5
DM
87 start)
88 log_daemon_msg "Starting $DESC " "$NAME"
89 do_start
90 case "$?" in
91 0|1) log_end_msg 0 ;;
92 2) log_end_msg 1 ;;
ff62b221 93 esac
75a10ce5
DM
94 ;;
95 stop)
96 log_daemon_msg "Stopping $DESC" "$NAME"
ff62b221
DM
97 do_stop
98 case "$?" in
75a10ce5
DM
99 0|1) log_end_msg 0 ;;
100 2) log_end_msg 1 ;;
ff62b221 101 esac
a30f86c5 102
ff62b221 103 ;;
75a10ce5 104 status)
506d51be 105 status_of_proc -p ${PIDFILE} $DAEMON "$NAME ${dir}" || exit 1
75a10ce5
DM
106 ;;
107 restart|force-reload)
ff62b221
DM
108 log_daemon_msg "Restarting $DESC" "$NAME"
109 do_stop
110 case "$?" in
75a10ce5 111 0|1)
ff62b221
DM
112 do_start
113 case "$?" in
75a10ce5
DM
114 0) log_end_msg 0 ;;
115 1) log_end_msg 1 ;; # Old process is still running
116 *) log_end_msg 1 ;; # Failed to start
ff62b221
DM
117 esac
118 ;;
75a10ce5 119 *)
ff62b221
DM
120 # Failed to stop
121 log_end_msg 1
122 ;;
123 esac
124 ;;
75a10ce5 125 *)
ff62b221
DM
126 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
127 exit 3
128 ;;
129esac
130
131:
132