]> git.proxmox.com Git - pve-cluster.git/blame - debian/init.d
Makefile: remove unused RELEASE var
[pve-cluster.git] / debian / init.d
CommitLineData
fe000966
DM
1#!/bin/sh
2#
3### BEGIN INIT INFO
4# Provides: pve-cluster
060a989f
DM
5# Required-Start: $remote_fs $network $syslog $time
6# Required-Stop: $remote_fs $network $syslog $time
2217ebad 7# X-Start-Before: cron +ceph
d920d75a 8# X-Stop-After: +ceph
5d7679ac
DM
9# Default-Start: 2 3 4 5
10# Default-Stop: 0 1 6
fe000966
DM
11# Short-Description: Starts the pve cluster filesystem
12# Description: Starts and stops the pve cluster filesystem
13### END INIT INFO
14
15PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
16
17DAEMON=/usr/bin/pmxcfs # Introduce the server's location here
18NAME=pve-cluster # Introduce the short server's name here
19DESC="pve cluster filesystem" # Introduce a short description here
20
21PIDFILE=/var/run/$NAME.pid
22
23test -x $DAEMON || exit 0
24
25. /lib/lsb/init-functions
26
27# Default options, these can be overriden by the information
28# at /etc/default/$NAME
29DAEMON_OPTS="-q" # Additional options given to the server
30
31# Include defaults if available
32if [ -f /etc/default/$NAME ] ; then
33 . /etc/default/$NAME
34fi
35
36set -e
37
38running_pid() {
39# Check if a given process pid's cmdline matches a given name
40 pid=$1
41 name=$2
42 [ -z "$pid" ] && return 1
43 [ ! -d /proc/$pid ] && return 1
44 cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
45 # Is this the expected server
46 [ "${cmd##*/}" != "${name##*/}" ] && return 1
47 return 0
48}
49
50running() {
51# Check if the process is running looking at /proc
52# (works for all users)
53
54 # No pidfile, probably no daemon present
55 [ ! -f "$PIDFILE" ] && return 1
56 pid=`cat $PIDFILE`
57 running_pid $pid $DAEMON || return 1
58 return 0
59}
60
61start_server() {
62
060a989f
DM
63 if ! grep -qw fuse /proc/filesystems; then
64 modprobe fuse >/dev/null 2>&1 || true
65 fi
66
9c533477 67 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
fe000966
DM
68 errcode=$?
69 return $errcode
70}
71
72stop_server() {
73 start-stop-daemon --stop --quiet --retry TERM/2/TERM/10/KILL/2 --pidfile $PIDFILE
74 errcode=$?
75 return $errcode
76}
77
78case "$1" in
79 start)
80 log_daemon_msg "Starting $DESC " "$NAME"
81
82 # Check if it's running first
83 if running ; then
84 log_progress_msg "apparently already running"
85 log_end_msg 0
86 exit 0
87 fi
060a989f 88
fe000966
DM
89 errcode=0
90 start_server || errcode=$?
91 # try to create required directories. This only works
92 # for a single node setup, because we have no quorum
93 # in a cluster setup. But this doesn't matter, because the
94 # cluster manager creates all needed files (pvecm)
95 if [ $errcode -eq 0 ] ; then
96 /usr/bin/pvecm updatecerts --silent || true
97 fi
98 log_end_msg $errcode
99 ;;
100 stop)
101 log_daemon_msg "Stopping $DESC" "$NAME"
102 if running ; then
103 # Only stop the server if we see it running
104 errcode=0
105 stop_server || errcode=$?
106 log_end_msg $errcode
107 else
108 # If it's not running don't do anything
109 log_progress_msg "apparently not running"
110 log_end_msg 0
111 exit 0
112 fi
113 ;;
114 restart|force-reload)
115 log_daemon_msg "Restarting $DESC" "$NAME"
116 errcode=0
117 stop_server || errcode=$?
118 errcode=0
119 start_server || errcode=$?
120 log_end_msg $errcode
121 ;;
122 status)
123 log_daemon_msg "Checking status of $DESC" "$NAME"
124 if running ; then
125 log_progress_msg "running"
126 log_end_msg 0
127 else
128 log_progress_msg "apparently not running"
129 log_end_msg 1
130 exit 1
131 fi
132 ;;
133 reload)
134 log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
135 log_warning_msg "cannot re-read the config file (use restart)."
136 ;;
137
138 *)
139 N=/etc/init.d/$NAME
140 echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
141 exit 1
142 ;;
143esac
144
145exit 0