1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

ctdb-tests: Reformat script

Samba is reformatting shell scripts using

  shfmt -w -p -i 0 -fn

so update this one before editing.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2022-03-18 10:53:45 +11:00 committed by Amitay Isaacs
parent 8458449ddf
commit a43a1ebe51

View File

@ -28,7 +28,7 @@ systemd-*)
nfs_rquotad_config="" # Not use with systemd, restart via service
case "$nfs_distro_style" in
*-redhat|*-suse)
*-redhat | *-suse)
: # Defaults only
;;
*-debian)
@ -37,6 +37,7 @@ systemd-*)
*)
echo "Internal error"
exit 1
;;
esac
;;
@ -65,22 +66,24 @@ sysvinit-*)
*)
echo "Internal error"
exit 1
;;
esac
;;
*)
echo "Internal error"
exit 1
;;
esac
# Override for unit testing
if [ -z "$PROCFS_PATH" ] ; then
if [ -z "$PROCFS_PATH" ]; then
PROCFS_PATH="/proc"
fi
##################################################
usage ()
usage()
{
_c=$(basename "$0")
cat <<EOF
@ -94,11 +97,11 @@ EOF
##################################################
nfs_load_config ()
nfs_load_config()
{
_config="${1:-${nfs_config}}"
if [ -r "$_config" ] ; then
if [ -r "$_config" ]; then
. "$_config"
fi
}
@ -106,22 +109,22 @@ nfs_load_config ()
##################################################
# Basic service stop and start
basic_stop ()
basic_stop()
{
case "$1" in
nfs)
if [ -n "$nfs_rquotad_service" ] ; then
if [ -n "$nfs_rquotad_service" ]; then
service "$nfs_rquotad_service" stop
fi
service "$nfs_service" stop
if [ -n "$nfs_lock_service" ] ; then
if [ -n "$nfs_lock_service" ]; then
service "$nfs_lock_service" stop
fi
;;
nfslock)
if [ -n "$nfs_lock_service" ] ; then
if [ -n "$nfs_lock_service" ]; then
service "$nfs_lock_service" stop
else
service "$nfs_service" stop
@ -129,25 +132,26 @@ basic_stop ()
;;
*)
usage
;;
esac
}
basic_start ()
basic_start()
{
case "$1" in
nfs)
if [ -n "$nfs_lock_service" ] ; then
if [ -n "$nfs_lock_service" ]; then
service "$nfs_lock_service" start
fi
service "$nfs_service" start
if [ -n "$nfs_rquotad_service" ] ; then
if [ -n "$nfs_rquotad_service" ]; then
service "$nfs_rquotad_service" start
fi
;;
nfslock)
if [ -n "$nfs_lock_service" ] ; then
if [ -n "$nfs_lock_service" ]; then
service "$nfs_lock_service" start
else
service "$nfs_service" start
@ -155,13 +159,14 @@ basic_start ()
;;
*)
usage
;;
esac
}
##################################################
# service "stop" and "start" options for restarting
service_stop ()
service_stop()
{
case "$1" in
nfs)
@ -173,7 +178,7 @@ service_stop ()
basic_stop "nfslock" >/dev/null 2>&1 || true
;;
mountd)
if [ -n "$nfs_mountd_service" ] ; then
if [ -n "$nfs_mountd_service" ]; then
service "$nfs_mountd_service" stop
return
fi
@ -182,7 +187,7 @@ service_stop ()
killall -q -9 rpc.mountd
;;
rquotad)
if [ -n "$nfs_rquotad_service" ] ; then
if [ -n "$nfs_rquotad_service" ]; then
service "$nfs_rquotad_service" stop
return
fi
@ -191,7 +196,7 @@ service_stop ()
killall -q -9 rpc.rquotad
;;
status)
if [ -n "$nfs_status_service" ] ; then
if [ -n "$nfs_status_service" ]; then
service "$nfs_status_service" stop
return
fi
@ -201,10 +206,11 @@ service_stop ()
;;
*)
usage
;;
esac
}
service_start ()
service_start()
{
case "$1" in
nfs)
@ -214,35 +220,35 @@ service_start ()
basic_start "nfslock"
;;
mountd)
if [ -n "$nfs_mountd_service" ] ; then
if [ -n "$nfs_mountd_service" ]; then
service "$nfs_mountd_service" start
return
fi
# Default to starting by hand
nfs_load_config
if [ -z "$RPCMOUNTDOPTS" ] ; then
if [ -z "$RPCMOUNTDOPTS" ]; then
RPCMOUNTDOPTS="${MOUNTD_PORT:+-p }$MOUNTD_PORT"
fi
# shellcheck disable=SC2086
rpc.mountd $RPCMOUNTDOPTS
;;
rquotad)
if [ -n "$nfs_rquotad_service" ] ; then
if [ -n "$nfs_rquotad_service" ]; then
service "$nfs_rquotad_service" start
return
fi
# Default to starting by hand
nfs_load_config "$nfs_rquotad_config"
if [ -z "$RPCRQUOTADOPTS" ] ; then
if [ -z "$RPCRQUOTADOPTS" ]; then
RPCRQUOTADOPTS="${RQUOTAD_PORT:+-p }$RQUOTAD_PORT"
fi
# shellcheck disable=SC2086
rpc.rquotad $RPCRQUOTADOPTS
;;
status)
if [ -n "$nfs_status_service" ] ; then
if [ -n "$nfs_status_service" ]; then
service "$nfs_status_service" start
return
fi
@ -251,7 +257,7 @@ service_start ()
nfs_load_config
# Red Hat uses STATDARG, Debian uses STATDOPTS
opts="${STATDARG:-${STATDOPTS:-''}}"
if [ -z "$opts" ] ; then
if [ -z "$opts" ]; then
# shellcheck disable=SC2086
set -- \
${STATD_HA_CALLOUT:+-H} $STATD_HA_CALLOUT \
@ -265,23 +271,24 @@ service_start ()
;;
*)
usage
;;
esac
}
##################################################
# service init startup and final shutdown
nfs_shutdown ()
nfs_shutdown()
{
basic_stop "nfs"
}
nfs_startup ()
nfs_startup()
{
basic_stop "nfs" || true
basic_start "nfs"
_f="${PROCFS_PATH}/sys/net/ipv4/tcp_tw_recycle"
if [ -f "$_f" ] ; then
if [ -f "$_f" ]; then
echo 1 >"$_f"
fi
}
@ -289,7 +296,7 @@ nfs_startup ()
##################################################
# monitor-post support
nfs_check_thread_count ()
nfs_check_thread_count()
{
# Load NFS configuration to get desired number of threads.
nfs_load_config
@ -299,7 +306,7 @@ nfs_check_thread_count ()
# assume that those using the default don't care about the number
# of threads and that they have switched on this feature in error.
_configured_threads="${RPCNFSDCOUNT:-${USE_KERNEL_NFSD_NUMBER}}"
if [ -z "$_configured_threads" ] && type nfsconf >/dev/null 2>&1 ; then
if [ -z "$_configured_threads" ] && type nfsconf >/dev/null 2>&1; then
_configured_threads=$(nfsconf --get nfsd threads) || true
fi
[ -n "$_configured_threads" ] || return 0
@ -316,7 +323,7 @@ nfs_check_thread_count ()
# Intentionally not arithmetic comparison - avoids extra errors
# when above read fails in an unexpected way...
if [ "$_running_threads" != "$_configured_threads" ] ; then
if [ "$_running_threads" != "$_configured_threads" ]; then
echo "Attempting to correct number of nfsd threads from ${_running_threads} to ${_configured_threads}"
echo "$_configured_threads" >"$_threads_file"
fi
@ -325,18 +332,18 @@ nfs_check_thread_count ()
##################################################
# list share directories
nfs_monitor_list_shares ()
nfs_monitor_list_shares()
{
_cache_file="${CTDB_NFS_CALLOUT_STATE_DIR}/list_shares_cache"
# -nt operator is well supported in Linux: dash, bash, ksh, ...
# shellcheck disable=SC2039,SC3013
if [ ! -r "$nfs_exports_file" ] || [ ! -r "$_cache_file" ] || \
[ "$nfs_exports_file" -nt "$_cache_file" ] ; then
if [ ! -r "$nfs_exports_file" ] || [ ! -r "$_cache_file" ] ||
[ "$nfs_exports_file" -nt "$_cache_file" ]; then
mkdir -p "$CTDB_NFS_CALLOUT_STATE_DIR"
# We could just use the contents of $nfs_exports_file.
# However, let's regard that file as internal to NFS and use
# exportfs, which is the public API.
if ! _exports=$(exportfs -v) ; then
if ! _exports=$(exportfs -v); then
echo "WARNING: failed to run exportfs to list NFS shares" >&2
return
fi
@ -352,7 +359,7 @@ nfs_monitor_list_shares ()
##################################################
nfs_register ()
nfs_register()
{
cat <<EOF
shutdown
@ -367,31 +374,32 @@ EOF
##################################################
case "$1" in
shutdown)
shutdown)
nfs_shutdown
;;
startup)
startup)
nfs_startup
;;
stop)
stop)
service_stop "$2"
;;
start)
start)
service_start "$2"
;;
monitor-list-shares)
monitor-list-shares)
nfs_monitor_list_shares
;;
monitor-post)
monitor-post)
nfs_check_thread_count
;;
register)
register)
nfs_register
;;
monitor-pre|releaseip|takeip|releaseip-pre|takeip-pre)
monitor-pre | releaseip | takeip | releaseip-pre | takeip-pre)
# Not required/implemented
:
;;
*)
*)
usage
;;
esac