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

ctdb-scripts: Update script boilerplate to avoid shellcheck warnings

* Assign the output of dirname to temporary variable to avoid word
  splitting when directory name contains whitespace

* Drop export of CTDB_BASE to avoid masking broken return value -
  functions file does the export anyway

* Quote path when including functions file

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2016-06-29 17:36:05 +10:00 committed by Amitay Isaacs
parent 850863a15e
commit f227c26178
23 changed files with 55 additions and 47 deletions

View File

@ -5,9 +5,9 @@
#
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "$CTDB_BASE/functions"
. "${CTDB_BASE}/functions"
# If ctdb is running, just exit
if service ctdb status >/dev/null 2>&1 ; then

View File

@ -4,9 +4,9 @@
# for other operating systems.
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "$CTDB_BASE/functions"
. "${CTDB_BASE}/functions"
loadconfig ctdb

View File

@ -8,9 +8,9 @@
# rather than mutex locks.
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "$CTDB_BASE/functions"
. "${CTDB_BASE}/functions"
# Default fallback location for database directories.
# These can be overwritten from CTDB configuration

View File

@ -4,9 +4,10 @@
# elsewhere.
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig
ctdb_setup_service_state_dir "ctdb"

View File

@ -2,9 +2,10 @@
# script to check accessibility to the reclock file on a node
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig
# If CTDB_RECOVERY_LOCK specifies a helper then exit because this

View File

@ -2,9 +2,10 @@
# ctdb event script for checking local file system utilization
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig
ctdb_setup_service_state_dir "system-monitoring"

View File

@ -2,9 +2,9 @@
# script to manage nfs in a clustered environment
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
service_name="nfs"
loadconfig

View File

@ -8,9 +8,10 @@
# * For connection tracking/killing to work this script must be enabled.
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig
if [ -z "$CTDB_PUBLIC_ADDRESSES" ] ; then

View File

@ -6,9 +6,10 @@
# public interface
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig
[ -z "$CTDB_PUBLIC_ADDRESSES" ] && {

View File

@ -6,9 +6,9 @@
#
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
service_name=natgw

View File

@ -18,9 +18,10 @@
# bond1 10.3.3.0/24 10.0.0.1
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig
[ -f $CTDB_BASE/static-routes ] || {

View File

@ -1,9 +1,10 @@
#!/bin/sh
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig
service_name=per_ip_routing

View File

@ -7,13 +7,13 @@
#
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
service_name="multipathd"
loadconfig
loadconfig
[ -n "$CTDB_MONITOR_MPDEVICES" ] || exit 0

View File

@ -2,9 +2,9 @@
# event script to manage clamd in a cluster environment
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
detect_init_style

View File

@ -2,9 +2,9 @@
# event strict to manage vsftpd in a cluster environment
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
service_name="vsftpd"
# make sure the service is stopped first

View File

@ -2,9 +2,9 @@
# event script to manage httpd in a cluster environment
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
detect_init_style

View File

@ -2,9 +2,9 @@
# ctdb event script for winbind
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}

View File

@ -2,9 +2,9 @@
# ctdb event script for Samba
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
detect_init_style

View File

@ -2,9 +2,9 @@
# script to manage nfs in a clustered environment
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
service_name="nfs"
loadconfig

View File

@ -3,9 +3,9 @@
# CTDB event script for TGTD based iSCSI
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
service_name="iscsi"

View File

@ -2,9 +2,9 @@
# script to manage the lvs ip multiplexer for a single public address cluster
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
loadconfig ctdb

View File

@ -5,9 +5,10 @@
# the event timeout mechanism.
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
. $CTDB_BASE/functions
loadconfig ctdb
[ "$CTDB_RUN_TIMEOUT_MONITOR" = "yes" ] || exit 0

View File

@ -9,9 +9,9 @@
# STATD_HOSTNAME="myhostname -H /etc/ctdb/statd-callout"
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. $CTDB_BASE/functions
. "${CTDB_BASE}/functions"
# Overwrite this so we get some logging
die ()