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

Tests - eventscripts - ctdb stub - implement scriptstatus, tweaks

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit edc34d01a1ad83b1335c976593a006166b196569)
This commit is contained in:
Martin Schwenke 2011-08-30 16:27:04 +10:00
parent 84c67c378e
commit 91d5edee80

View File

@ -11,10 +11,13 @@ Usage: $prog [-Y] cmd
A fake CTDB stub that prints items depending on the variables
FAKE_CTDB_PNN (default 0) depending on command-line options.
Note that -Y is ignored.
EOF
exit 1
}
not_implemented ()
{
echo "${prog}: command \"$1\" not implemented in stub" >&2
exit $not_implemented_exit_code
}
@ -25,10 +28,11 @@ _temp=$(getopt -n "$prog" -o "Yvh" -l help -- "$@") || \
eval set -- "$_temp"
verbose=false
machine_readable=false
while true ; do
case "$1" in
-Y) shift ;;
-Y) machine_readable=true ; shift ;;
-v) verbose=true ; shift ;;
--) shift ; break ;;
-h|--help|*) usage ;; # * shouldn't happen, so this is reasonable.
@ -54,8 +58,7 @@ setup_pstore ()
# For testing backward compatibility...
for i in $CTDB_NOT_IMPLEMENTED ; do
if [ "$i" = "$1" ] ; then
echo "${prog}: command \"$i\" not implemented" >&2
usage
not_implemented "$i"
fi
done
@ -194,8 +197,24 @@ EOF
exit 0
;;
scriptstatus)
$machine_readable || not_implemented "$1, without -Y"
[ "$2" != "all" ] || not_implemented "scriptstatus all"
# For now just assume everything is good.
_d1=$(date '+%s.%N')
_d2=$(date '+%s.%N')
echo ":Type:Name:Code:Status:Start:End:Error Output...:"
for _i in "$CTDB_BASE/events.d/"*.* ; do
_b="${_i##*/}" # basename
_status="OK"
_code="0"
if [ ! -x "$_i" ] ; then
_status="DISABLED"
_code="-8"
fi
echo ":${2:-monitor}:${_b}:${_code}:${_status}:${_d1}:${_d2}::"
done
;;
*)
echo "${prog}: command \"$1\" not implemented in stub"
usage
not_implemented "$1"
esac