]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Reformat with "shfmt -w -i 0 -fn"
authorMartin Schwenke <mschwenke@ddn.com>
Sat, 28 Feb 2026 10:48:06 +0000 (21:48 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 9 Jul 2026 16:02:43 +0000 (16:02 +0000)
Best reviewed with "git show -w" or similar.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/ctdb.init
ctdb/config/events/legacy/05.system.script
ctdb/config/events/legacy/31.clamd.script
ctdb/config/events/legacy/40.vsftpd.script
ctdb/config/events/legacy/41.httpd.script
ctdb/config/events/legacy/47.samba-dcerpcd.script
ctdb/config/events/legacy/48.netbios.script
ctdb/config/events/legacy/50.samba.script

index 6a7f7812394d3025e7512fc197de23d22a02a628..237fa6a1ef0a0fc0363fd256dcd0e1df8bd2b5a1 100755 (executable)
 ### 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
@@ -45,8 +45,8 @@ unset 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"
@@ -62,60 +62,60 @@ pidfile="/var/run/ctdb/ctdbd.pid"
 
 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)
@@ -134,28 +134,29 @@ check_status ()
 ############################################################
 
 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
index 47f3acbce4461b1afd69db5ffcfc1911956833a8..66f9f4ffeb5e8349b06d5d033075c237b953d59d 100755 (executable)
@@ -52,9 +52,9 @@ check_thresholds()
        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.
@@ -72,18 +72,18 @@ check_thresholds()
                                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
@@ -129,7 +129,7 @@ monitor_filesystem_usage()
                        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
 
index 966f63cc30ab467016f6026421c01acae900ded2..c4e28adc240a38f615de583c02e037d397aa51e2 100755 (executable)
@@ -1,7 +1,7 @@
 #!/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"
@@ -21,7 +21,7 @@ load_script_options
 
 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 $?
        ;;
 
@@ -30,8 +30,8 @@ shutdown)
        ;;
 
 monitor)
-        ctdb_check_unix_socket "$CTDB_CLAMD_SOCKET" || exit $?
-        ;;
+       ctdb_check_unix_socket "$CTDB_CLAMD_SOCKET" || exit $?
+       ;;
 esac
 
 exit 0
index 6497c715888e08d08dce6f7b63b82d6518a0c2b4..89119d4d06541225d751270d294789cd56103d2b 100755 (executable)
@@ -1,14 +1,14 @@
 #!/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()
@@ -23,7 +23,7 @@ port_21="vsftpd listening on TCP port 21"
 
 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"
        ;;
@@ -32,18 +32,18 @@ shutdown)
        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
index 51d85947ff3ca0c898b54aa5ea69e95ad458e639..048cf3286d73481d61d53fec18d2790d8e54b162 100755 (executable)
@@ -1,7 +1,7 @@
 #!/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"
@@ -12,7 +12,7 @@ case $CTDB_INIT_STYLE in
 redhat)
        service_name="httpd"
        ;;
-suse|debian|*)
+suse | debian | *)
        service_name="apache2"
        ;;
 esac
@@ -23,24 +23,25 @@ ctdb_setup_state_dir "service" "$service_name"
 
 # 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
@@ -54,17 +55,17 @@ shutdown)
        ;;
 
 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
@@ -75,4 +76,3 @@ monitor)
 esac
 
 exit 0
-
index fae9ee9f0f020e08630b1952d39cbfca09548ea8..f2c0a9a23ab583c841258a1e38505ed450d44f8c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/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"
@@ -9,41 +9,41 @@
 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
 }
 
 ###########################
index ed0f871f939b468b7453ad3eaae8cf21abd9b931..cf2d1450af10e6ae862f8e5c07640b3573c06148 100755 (executable)
@@ -1,7 +1,7 @@
 #!/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"
@@ -9,16 +9,16 @@
 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"
@@ -27,32 +27,32 @@ load_script_options
 
 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
 }
 
 ###########################
index 7da0c399d5916f2e29e7b98542a55101398698e7..fbffcec06e508d565d0379b35741a291d15d570a 100755 (executable)
@@ -32,8 +32,7 @@ generate_smb_interfaces_config()
        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
 
@@ -41,7 +40,7 @@ generate_smb_interfaces_config()
                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
@@ -132,13 +131,13 @@ testparm_background_update()
        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"
 
 }
 
@@ -152,7 +151,7 @@ list_samba_ports()
        {
                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
 }