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