diff options
author | Martin Schwenke <mschwenke@ddn.com> | 2023-02-13 13:02:52 +1100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2023-02-14 07:44:30 +0000 |
commit | 029dddfb79fb557039c9daa9eebde333e6d19233 (patch) | |
tree | bf672dc0496a8d104c5ab104a08810d6b487c95f /ctdb | |
parent | 5d8647376fbfe0ad3b479be3a4479f1c9d5ecd7b (diff) | |
download | samba-029dddfb79fb557039c9daa9eebde333e6d19233.tar.gz |
ctdb-scripts: Reformat script with "shfmt -w -p -i 0 -fn"
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/config/events/legacy/50.samba.script | 165 |
1 files changed, 83 insertions, 82 deletions
diff --git a/ctdb/config/events/legacy/50.samba.script b/ctdb/config/events/legacy/50.samba.script index 81c6e7fa6ba..11b22abac67 100755 --- a/ctdb/config/events/legacy/50.samba.script +++ b/ctdb/config/events/legacy/50.samba.script @@ -1,7 +1,7 @@ #!/bin/sh # ctdb event script for Samba -[ -n "$CTDB_BASE" ] || \ +[ -n "$CTDB_BASE" ] || CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD") . "${CTDB_BASE}/functions" @@ -9,16 +9,16 @@ detect_init_style case $CTDB_INIT_STYLE in - suse) - CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb} - ;; - debian) - CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smbd} - ;; - *) - # Use redhat style as default: - CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb} - ;; +suse) + CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb} + ;; +debian) + CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smbd} + ;; +*) + # Use redhat style as default: + CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb} + ;; esac service_name="samba" @@ -27,25 +27,25 @@ load_script_options ctdb_setup_state_dir "service" "$service_name" -service_start () +service_start() { - # make sure samba is not already started - service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1 - killall -0 -q smbd && { - sleep 1 - # make absolutely sure samba is dead - killall -q -9 smbd - } - # start Samba 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_SMB" start || die "Failed to start samba" + # make sure samba is not already started + service "$CTDB_SERVICE_SMB" stop >/dev/null 2>&1 + killall -0 -q smbd && { + sleep 1 + # make absolutely sure samba is dead + killall -q -9 smbd + } + # start Samba 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_SMB" start || die "Failed to start samba" } -service_stop () +service_stop() { - service "$CTDB_SERVICE_SMB" stop - program_stack_traces "smbd" 5 + service "$CTDB_SERVICE_SMB" stop + program_stack_traces "smbd" 5 } ###################################################################### @@ -56,74 +56,75 @@ service_stop () # shellcheck disable=SC2154 smbconf_cache="$script_state_dir/smb.conf.cache" -testparm_foreground_update () +testparm_foreground_update() { - _timeout="$1" + _timeout="$1" - # No need to remove these temporary files, since there are only 2 - # of them. - _out="${smbconf_cache}.out" - _err="${smbconf_cache}.err" + # No need to remove these temporary files, since there are only 2 + # of them. + _out="${smbconf_cache}.out" + _err="${smbconf_cache}.err" - timeout "$_timeout" testparm -v -s >"$_out" 2>"$_err" - case $? in + timeout "$_timeout" testparm -v -s >"$_out" 2>"$_err" + case $? in 0) : ;; 124) - if [ -f "$smbconf_cache" ] ; then - echo "WARNING: smb.conf cache update timed out - using old cache file" - return 1 - else - echo "ERROR: smb.conf cache create failed - testparm command timed out" - exit 1 - fi - ;; + if [ -f "$smbconf_cache" ]; then + echo "WARNING: smb.conf cache update timed out - using old cache file" + return 1 + else + echo "ERROR: smb.conf cache create failed - testparm command timed out" + exit 1 + fi + ;; *) - if [ -f "$smbconf_cache" ] ; then - echo "WARNING: smb.conf cache update failed - using old cache file" - cat "$_err" - return 1 - else - echo "ERROR: smb.conf cache create failed - testparm failed with:" - cat "$_err" - exit 1 - fi - esac - - # Only using $$ here to avoid a collision. This is written into - # CTDB's own state directory so there is no real need for a secure - # temporary file. - _tmpfile="${smbconf_cache}.$$" - # Patterns to exclude... - _pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|winbind[[:space:]]+separator)[[:space:]]+=' - grep -Ev "$_pat" <"$_out" >"$_tmpfile" - mv "$_tmpfile" "$smbconf_cache" # atomic - - return 0 + if [ -f "$smbconf_cache" ]; then + echo "WARNING: smb.conf cache update failed - using old cache file" + cat "$_err" + return 1 + else + echo "ERROR: smb.conf cache create failed - testparm failed with:" + cat "$_err" + exit 1 + fi + ;; + esac + + # Only using $$ here to avoid a collision. This is written into + # CTDB's own state directory so there is no real need for a secure + # temporary file. + _tmpfile="${smbconf_cache}.$$" + # Patterns to exclude... + _pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|winbind[[:space:]]+separator)[[:space:]]+=' + grep -Ev "$_pat" <"$_out" >"$_tmpfile" + mv "$_tmpfile" "$smbconf_cache" # atomic + + return 0 } -testparm_background_update () +testparm_background_update() { - _timeout="$1" + _timeout="$1" - testparm_foreground_update "$_timeout" >/dev/null 2>&1 </dev/null & + testparm_foreground_update "$_timeout" >/dev/null 2>&1 </dev/null & } -testparm_cat () +testparm_cat() { - testparm -s "$smbconf_cache" "$@" 2>/dev/null + testparm -s "$smbconf_cache" "$@" 2>/dev/null } -list_samba_shares () +list_samba_shares() { - testparm_cat | - sed -n -e 's@^[[:space:]]*path[[:space:]]*=[[:space:]]@@p' | - sed -e 's/"//g' + testparm_cat | + sed -n -e 's@^[[:space:]]*path[[:space:]]*=[[:space:]]@@p' | + sed -e 's/"//g' } -list_samba_ports () +list_samba_ports() { - testparm_cat --parameter-name="smb ports" | - sed -e 's@,@ @g' + testparm_cat --parameter-name="smb ports" | + sed -e 's@,@ @g' } ########################### @@ -142,20 +143,20 @@ monitor) ret=$? smb_ports="$CTDB_SAMBA_CHECK_PORTS" - if [ -z "$smb_ports" ] ; then - smb_ports=$(list_samba_ports) - [ -n "$smb_ports" ] || die "Failed to set smb ports" + if [ -z "$smb_ports" ]; then + smb_ports=$(list_samba_ports) + [ -n "$smb_ports" ] || die "Failed to set smb ports" fi # Intentionally unquoted multi-word value here # shellcheck disable=SC2086 ctdb_check_tcp_ports $smb_ports || exit $? - if [ "$CTDB_SAMBA_SKIP_SHARE_CHECK" != "yes" ] ; then - list_samba_shares | ctdb_check_directories || exit $? + if [ "$CTDB_SAMBA_SKIP_SHARE_CHECK" != "yes" ]; then + list_samba_shares | ctdb_check_directories || exit $? fi - if [ $ret -ne 0 ] ; then - testparm_background_update 10 + if [ $ret -ne 0 ]; then + testparm_background_update 10 fi ;; esac |