]>
git.proxmox.com Git - pve-sheepdog.git/blob - debian/pve-sheepdog.sheepdog.init.d
4 # Required-Start: $network $remote_fs $syslog
5 # Required-Stop: $network $remote_fs $syslog
6 # Default-Start: 2 3 4 5
8 # Short-Description: Sheepdog server
9 # Description: Sheepdog server
12 # Author: Proxmox Support Team <support@proxmox.com>
14 # PATH should only include /usr/* if it runs after the mountnfs.sh script
15 PATH
=/sbin
:/usr
/sbin
:/bin
:/usr
/bin
16 DESC
="Sheepdog Server" # Introduce a short description here
17 NAME
=sheepdog
# Introduce the short server's name here
18 DAEMON
=/usr
/sbin
/sheep
# Introduce the server's location here
19 SCRIPTNAME
=/etc
/init.d
/$NAME
21 # Exit if the package is not installed
22 [ -x $DAEMON ] ||
exit 0
24 DISKLIST
=$
(echo /var
/lib
/sheepdog
/disc
[0123456789])
26 for dir
in ${DISKLIST}; do
27 RDISKLIST
="${dir} ${RDISKLIST}"
30 # Read configuration variable file if it is present
31 [ -r /etc
/default
/$NAME ] && .
/etc
/default
/$NAME
33 if [ "$START" != "yes" ]; then
37 .
/lib
/lsb
/init-functions
40 # Function that starts the daemon/service
47 # 0 if daemon has been started
48 # 1 if daemon was already running
49 # 2 if daemon could not be started
51 for dir
in ${DISKLIST}; do
52 test -f "${dir}/startup" ||
continue
53 DAEMON_ARGS
=$
(head -n1 "${dir}/startup");
54 DISKID
=${dir##/var/lib/sheepdog/disc}
55 PIDFILE
="$dir/sheep.pid"
56 DAEMON_ARGS
="${DAEMON_ARGS} --pidfile ${PIDFILE}"
57 if ! test "$(echo ${DAEMON_ARGS}|grep -c '\-p ')" -eq 1 ; then
58 DAEMON_ARGS
="${DAEMON_ARGS} -p $((7000 + ${DISKID}))"
61 status_of_proc
-p ${PIDFILE} $DAEMON "$NAME" >/dev
/null
&& continue
63 start-stop-daemon
--start --quiet --pidfile ${PIDFILE} --exec $DAEMON -- $DAEMON_ARGS ${dir} ||
return 2
70 # Function that stops the daemon/service
75 # 0 if daemon has been stopped
76 # 1 if daemon was already stopped
77 # 2 if daemon could not be stopped
78 # other if a failure occurred
81 for dir
in ${RDISKLIST}; do
82 test -f "${dir}/startup" ||
continue
83 PIDFILE
="$dir/sheep.pid"
84 start-stop-daemon
--stop --oknodo --retry=TERM
/20/KILL
/5 --quiet --pidfile ${PIDFILE} --exec $DAEMON || RETVAL
=2
92 log_daemon_msg
"Starting $DESC " "$NAME"
100 log_daemon_msg
"Stopping $DESC" "$NAME"
103 0|
1) log_end_msg
0 ;;
110 for dir
in ${DISKLIST}; do
111 test -f "${dir}/startup" ||
continue
112 PIDFILE
="$dir/sheep.pid"
113 status_of_proc
-p ${PIDFILE} $DAEMON "$NAME ${dir}" || RETVAL
=1
117 restart|force-reload
)
118 log_daemon_msg
"Restarting $DESC" "$NAME"
125 1) log_end_msg
1 ;; # Old process is still running
126 *) log_end_msg
1 ;; # Failed to start
136 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2