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