Best reviewed with "git show -w" or similar.
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
### END INIT INFO
# Source function library.
-if [ -f /etc/init.d/functions ] ; then
- # Red Hat
- . /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ] ; then
- # Red Hat
- . /etc/rc.d/init.d/functions
-elif [ -f /etc/rc.status ] ; then
- # SUSE
- . /etc/rc.status
- rc_reset
- LC_ALL=en_US.UTF-8
-elif [ -f /lib/lsb/init-functions ] ; then
- # Debian
- . /lib/lsb/init-functions
+if [ -f /etc/init.d/functions ]; then
+ # Red Hat
+ . /etc/init.d/functions
+elif [ -f /etc/rc.d/init.d/functions ]; then
+ # Red Hat
+ . /etc/rc.d/init.d/functions
+elif [ -f /etc/rc.status ]; then
+ # SUSE
+ . /etc/rc.status
+ rc_reset
+ LC_ALL=en_US.UTF-8
+elif [ -f /lib/lsb/init-functions ]; then
+ # Debian
+ . /lib/lsb/init-functions
fi
# Avoid using root's TMPDIR
load_system_config "network"
# check networking is up (for redhat)
-if [ "$NETWORKING" = "no" ] ; then
- exit 0
+if [ "$NETWORKING" = "no" ]; then
+ exit 0
fi
load_system_config "ctdb"
start()
{
- printf "Starting ctdbd service: "
+ printf "Starting ctdbd service: "
- case "$CTDB_INIT_STYLE" in
+ case "$CTDB_INIT_STYLE" in
suse)
- startproc "$ctdbd"
- rc_status -v
- ;;
+ startproc "$ctdbd"
+ rc_status -v
+ ;;
redhat)
- daemon --pidfile "$pidfile" "$ctdbd"
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
- return $RETVAL
- ;;
+ daemon --pidfile "$pidfile" "$ctdbd"
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
+ return $RETVAL
+ ;;
debian)
- eval start-stop-daemon --start --quiet --background --exec "$ctdbd"
- ;;
- esac
+ eval start-stop-daemon --start --quiet --background --exec "$ctdbd"
+ ;;
+ esac
}
stop()
{
- printf "Shutting down ctdbd service: "
+ printf "Shutting down ctdbd service: "
- case "$CTDB_INIT_STYLE" in
+ case "$CTDB_INIT_STYLE" in
suse)
- "$ctdb" "shutdown"
- rc_status -v
- ;;
+ "$ctdb" "shutdown"
+ rc_status -v
+ ;;
redhat)
- "$ctdb" "shutdown"
- RETVAL=$?
- # Common idiom in Red Hat init scripts - success() always
- # succeeds so this does behave like if-then-else
- # shellcheck disable=SC2015
- [ $RETVAL -eq 0 ] && success || failure
- echo ""
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
- return $RETVAL
- ;;
+ "$ctdb" "shutdown"
+ RETVAL=$?
+ # Common idiom in Red Hat init scripts - success() always
+ # succeeds so this does behave like if-then-else
+ # shellcheck disable=SC2015
+ [ $RETVAL -eq 0 ] && success || failure
+ echo ""
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
+ return $RETVAL
+ ;;
debian)
- "$ctdb" "shutdown"
- log_end_msg $?
- ;;
- esac
+ "$ctdb" "shutdown"
+ log_end_msg $?
+ ;;
+ esac
}
restart()
{
- stop
- start
+ stop
+ start
}
-check_status ()
+check_status()
{
case "$CTDB_INIT_STYLE" in
suse)
############################################################
case "$1" in
- start)
- start
+start)
+ start
;;
- stop)
- stop
+stop)
+ stop
;;
- restart|reload|force-reload)
- restart
+restart | reload | force-reload)
+ restart
;;
- status)
- check_status
+status)
+ check_status
;;
- condrestart|try-restart)
- if check_status >/dev/null ; then
- restart
+condrestart | try-restart)
+ if check_status >/dev/null; then
+ restart
fi
;;
- cron)
+cron)
# used from cron to auto-restart ctdb
- check_status >/dev/null 2>&1 || restart
+ check_status >/dev/null 2>&1 || restart
;;
- *)
+*)
echo "Usage: $0 {start|stop|restart|reload|force-reload|status|cron|condrestart|try-restart}"
exit 1
+ ;;
esac
if validate_percentage "$_unhealthy_threshold" "$_thing"; then
if [ "$_usage" -ge "$_unhealthy_threshold" ]; then
printf 'ERROR: %s utilization %d%% >= threshold %d%%\n' \
- "$_thing" \
- "$_usage" \
- "$_unhealthy_threshold"
+ "$_thing" \
+ "$_usage" \
+ "$_unhealthy_threshold"
# Only run unhealthy callout if passing the
# unhealthy threshold. That is, if the
# previous usage was below the threshold.
return
fi
printf 'WARNING: %s utilization %d%% >= threshold %d%%\n' \
- "$_thing" \
- "$_usage" \
- "$_warn_threshold"
+ "$_thing" \
+ "$_usage" \
+ "$_warn_threshold"
echo "$_usage" >"$_cache"
else
if [ ! -r "$_cache" ]; then
return
fi
printf 'NOTICE: %s utilization %d%% < threshold %d%%\n' \
- "$_thing" \
- "$_usage" \
- "$_warn_threshold"
+ "$_thing" \
+ "$_usage" \
+ "$_warn_threshold"
rm -f "$_cache"
fi
fi
sed -n -e 's@.*[[:space:]]\([[:digit:]]*\)%.*@\1@p')
if [ -z "$_fs_usage" ]; then
printf 'WARNING: Unable to get FS utilization for %s\n' \
- "$_fs_mount"
+ "$_fs_mount"
continue
fi
#!/bin/sh
# event script to manage clamd in a cluster environment
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
CTDB_BASE=$(d="$(dirname "$0")" && cd -P "$d/../../" && pwd)
. "${CTDB_BASE}/functions"
case "$1" in
startup)
- service "$service_name" stop > /dev/null 2>&1
+ service "$service_name" stop >/dev/null 2>&1
service "$service_name" start || exit $?
;;
;;
monitor)
- ctdb_check_unix_socket "$CTDB_CLAMD_SOCKET" || exit $?
- ;;
+ ctdb_check_unix_socket "$CTDB_CLAMD_SOCKET" || exit $?
+ ;;
esac
exit 0
#!/bin/sh
# event strict to manage vsftpd in a cluster environment
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
CTDB_BASE=$(d="$(dirname "$0")" && cd -P "$d/../../" && pwd)
. "${CTDB_BASE}/functions"
service_name="vsftpd"
-service_reconfigure ()
+service_reconfigure()
{
# shellcheck disable=SC2317
# Called indirectly via ctdb_service_reconfigure()
case "$1" in
startup)
- service "$service_name" stop > /dev/null 2>&1
+ service "$service_name" stop >/dev/null 2>&1
service "$service_name" start
failcount_init "$port_21"
;;
service "$service_name" stop
;;
-takeip|releaseip)
+takeip | releaseip)
ctdb_service_set_reconfigure
;;
ipreallocated)
- if ctdb_service_needs_reconfigure ; then
+ if ctdb_service_needs_reconfigure; then
ctdb_service_reconfigure
fi
;;
monitor)
- if ctdb_check_tcp_ports 21 ; then
+ if ctdb_check_tcp_ports 21; then
failcount_reset "$port_21"
else
# Set defaults, if unset
#!/bin/sh
# event script to manage httpd in a cluster environment
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
CTDB_BASE=$(d="$(dirname "$0")" && cd -P "$d/../../" && pwd)
. "${CTDB_BASE}/functions"
redhat)
service_name="httpd"
;;
-suse|debian|*)
+suse | debian | *)
service_name="apache2"
;;
esac
# RHEL5 sometimes use a SIGKILL to terminate httpd, which then leaks
# semaphores. This is a hack to clean them up.
-cleanup_httpd_semaphore_leak() {
- killall -q -0 "$service_name" ||
- for i in $(ipcs -s | awk '$3 == "apache" { print $2 }') ; do
- ipcrm -s "$i"
- done
+cleanup_httpd_semaphore_leak()
+{
+ killall -q -0 "$service_name" ||
+ for i in $(ipcs -s | awk '$3 == "apache" { print $2 }'); do
+ ipcrm -s "$i"
+ done
}
##########
-service_start ()
+service_start()
{
- cleanup_httpd_semaphore_leak
- service $service_name start
+ cleanup_httpd_semaphore_leak
+ service $service_name start
}
-service_stop ()
+service_stop()
{
- service $service_name stop
- killall -q -9 $service_name || true
+ service $service_name stop
+ killall -q -9 $service_name || true
}
case "$1" in
;;
monitor)
- if ctdb_check_tcp_ports 80 >/dev/null 2>/dev/null ; then
+ if ctdb_check_tcp_ports 80 >/dev/null 2>/dev/null; then
ctdb_counter_init
else
ctdb_counter_incr
num_fails=$(ctdb_counter_get)
- if [ "$num_fails" -eq 2 ] ; then
+ if [ "$num_fails" -eq 2 ]; then
echo "HTTPD is not running. Trying to restart HTTPD."
service_stop
service_start
exit 0
- elif [ "$num_fails" -ge 5 ] ; then
+ elif [ "$num_fails" -ge 5 ]; then
echo "HTTPD is not running. Trying to restart HTTPD."
service_stop
service_start
esac
exit 0
-
#!/bin/sh
# ctdb event script for SAMBA DCERPCD Services
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
CTDB_BASE=$(d="$(dirname "$0")" && cd -P "$d/../../" && pwd)
. "${CTDB_BASE}/functions"
detect_init_style
case $CTDB_INIT_STYLE in
- *)
- # distributions don't have this yet,
- # but assume samba-dcerpcd as service name
- CTDB_SERVICE_SAMBA_DCERPCD=${CTDB_SERVICE_SAMBA_DCERPCD:-samba-dcerpcd}
- ;;
+*)
+ # distributions don't have this yet,
+ # but assume samba-dcerpcd as service name
+ CTDB_SERVICE_SAMBA_DCERPCD=${CTDB_SERVICE_SAMBA_DCERPCD:-samba-dcerpcd}
+ ;;
esac
load_script_options
-service_start ()
+service_start()
{
- # make sure samba-dcerpcd is not already started
- service "$CTDB_SERVICE_SAMBA_DCERPCD" stop > /dev/null 2>&1
- killall -0 -q samba-dcerpcd && {
- sleep 1
- # make absolutely sure samba-dcerpcd is dead
- killall -q -9 samba-dcerpcd
- }
+ # make sure samba-dcerpcd is not already started
+ service "$CTDB_SERVICE_SAMBA_DCERPCD" stop >/dev/null 2>&1
+ killall -0 -q samba-dcerpcd && {
+ sleep 1
+ # make absolutely sure samba-dcerpcd is dead
+ killall -q -9 samba-dcerpcd
+ }
- # start Samba dcerpcd service. Start it reniced, as under very heavy load
- # the number of smbd processes will mean that it leaves few cycles
- # for anything else
- nice_service "$CTDB_SERVICE_SAMBA_DCERPCD" start || die "Failed to start samba-dcerpcd"
+ # start Samba dcerpcd service. Start it reniced, as under very heavy load
+ # the number of smbd processes will mean that it leaves few cycles
+ # for anything else
+ nice_service "$CTDB_SERVICE_SAMBA_DCERPCD" start || die "Failed to start samba-dcerpcd"
}
-service_stop ()
+service_stop()
{
- service "$CTDB_SERVICE_SAMBA_DCERPCD" stop
+ service "$CTDB_SERVICE_SAMBA_DCERPCD" stop
}
-service_status ()
+service_status()
{
- service "$CTDB_SERVICE_SAMBA_DCERPCD" status > /dev/null
- test $? = 0 && return 0
- service "$CTDB_SERVICE_SAMBA_DCERPCD" status
+ service "$CTDB_SERVICE_SAMBA_DCERPCD" status >/dev/null
+ test $? = 0 && return 0
+ service "$CTDB_SERVICE_SAMBA_DCERPCD" status
}
###########################
#!/bin/sh
# ctdb event script for Netbios Name Services
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
CTDB_BASE=$(d="$(dirname "$0")" && cd -P "$d/../../" && pwd)
. "${CTDB_BASE}/functions"
detect_init_style
case $CTDB_INIT_STYLE in
- suse)
- CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
- ;;
- debian)
- CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmbd}
- ;;
- *)
- # Use redhat style as default:
- CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
- ;;
+suse)
+ CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
+ ;;
+debian)
+ CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmbd}
+ ;;
+*)
+ # Use redhat style as default:
+ CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
+ ;;
esac
service_name="netbios"
ctdb_setup_state_dir "service" "$service_name"
-service_start ()
+service_start()
{
- # make sure nmbd is not already started
- service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
- killall -0 -q nmbd && {
- sleep 1
- # make absolutely sure nmbd is dead
- killall -q -9 nmbd
- }
-
- # start Samba nmbd service. Start it reniced, as under very heavy load
- # the number of smbd processes will mean that it leaves few cycles
- # for anything else
- nice_service "$CTDB_SERVICE_NMB" start || die "Failed to start nmbd"
+ # make sure nmbd is not already started
+ service "$CTDB_SERVICE_NMB" stop >/dev/null 2>&1
+ killall -0 -q nmbd && {
+ sleep 1
+ # make absolutely sure nmbd is dead
+ killall -q -9 nmbd
+ }
+
+ # start Samba nmbd service. Start it reniced, as under very heavy load
+ # the number of smbd processes will mean that it leaves few cycles
+ # for anything else
+ nice_service "$CTDB_SERVICE_NMB" start || die "Failed to start nmbd"
}
-service_stop ()
+service_stop()
{
- service "$CTDB_SERVICE_NMB" stop
+ service "$CTDB_SERVICE_NMB" stop
}
-service_status ()
+service_status()
{
- service "$CTDB_SERVICE_NMB" status > /dev/null
- test $? = 0 && return 0
- service "$CTDB_SERVICE_NMB" status
+ service "$CTDB_SERVICE_NMB" status >/dev/null
+ test $? = 0 && return 0
+ service "$CTDB_SERVICE_NMB" status
}
###########################
get_public_ifaces
pub_iface_list=$public_ifaces
public_ifaces=""
- for iface in $pub_iface_list;
- do
+ for iface in $pub_iface_list; do
public_ifaces="$public_ifaces \"$iface;options=dynamic\""
done
public_ifaces="$public_ifaces $CTDB_SAMBA_INTERFACES_EXTRA"
fi
-cat <<EOT > "$CTDB_SAMBA_INTERFACES_FILE"
+ cat <<EOT >"$CTDB_SAMBA_INTERFACES_FILE"
bind interfaces only = yes
interfaces = lo $public_ifaces
EOT
testparm_foreground_update "$_timeout" >/dev/null 2>&1 </dev/null &
}
-testparm_get ()
+testparm_get()
{
_param="$1"
sed -n \
- -e "s|^[[:space:]]*${_param}[[:space:]]*=[[:space:]]\(..*\)|\1|p" \
- "$smbconf_cache"
+ -e "s|^[[:space:]]*${_param}[[:space:]]*=[[:space:]]\(..*\)|\1|p" \
+ "$smbconf_cache"
}
{
testparm_get "server smb transports"
testparm_get "smb ports"
- # only | head -1 would cause a broken pipe for the 2nd command
+ # only | head -1 would cause a broken pipe for the 2nd command
} | head -2 | head -1
}