mirror of
https://github.com/samba-team/samba.git
synced 2025-02-24 13:57:43 +03:00
selftest: Reformat shell scripts
shfmt -f selftest/ | xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
22eb76c6d0
commit
1399b2430a
@ -6,7 +6,7 @@ set -u
|
||||
|
||||
ACCOUNT_NAME="${SAMBA_CPS_ACCOUNT_NAME}"
|
||||
INVALIDPW="$1"
|
||||
NEWPW=`cat -`
|
||||
NEWPW=$(cat -)
|
||||
|
||||
echo -n "${NEWPW}" | grep -q "^${INVALIDPW}\$" && {
|
||||
echo "Found invalid password" >&1
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASENAME=`basename $0`
|
||||
BASENAME=$(basename $0)
|
||||
|
||||
unset LD_PRELOAD
|
||||
|
||||
@ -11,14 +11,13 @@ fi
|
||||
|
||||
if [ "x$PLEASE_NO_GDB_BACKTRACE" != "x" ]; then
|
||||
echo "${BASENAME}: Not running debugger because PLEASE_NO_GDB_BACKTRACE is set"
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# we want everything on stderr, so the program is not disturbed
|
||||
exec 1>&2
|
||||
|
||||
UNAME=`uname`
|
||||
UNAME=$(uname)
|
||||
|
||||
PID=$1
|
||||
BINARY=$2
|
||||
@ -30,31 +29,31 @@ test x"${PID}" = x"" && {
|
||||
|
||||
DB_LIST="gdb"
|
||||
case "${UNAME}" in
|
||||
#
|
||||
# on Tru64 we need to try ladebug first
|
||||
# because gdb crashes itself...
|
||||
#
|
||||
OSF1)
|
||||
DB_LIST="ladebug ${DB_LIST}"
|
||||
#
|
||||
# on Tru64 we need to try ladebug first
|
||||
# because gdb crashes itself...
|
||||
#
|
||||
OSF1)
|
||||
DB_LIST="ladebug ${DB_LIST}"
|
||||
;;
|
||||
#
|
||||
# On solaris dbx is working way more better than gdb
|
||||
# let's try it first
|
||||
#
|
||||
SunOS)
|
||||
DB_LIST="dbx ${DB_LIST}"
|
||||
#
|
||||
# On solaris dbx is working way more better than gdb
|
||||
# let's try it first
|
||||
#
|
||||
SunOS)
|
||||
DB_LIST="dbx ${DB_LIST}"
|
||||
;;
|
||||
#
|
||||
# FreeBSD comes with a flavor that works gdb66 and one that don't gdb
|
||||
# (gdb 6.1) let's try it first the one that works !
|
||||
#
|
||||
FreeBSD)
|
||||
DB_LIST="gdb66 ${DB_LIST}"
|
||||
#
|
||||
# FreeBSD comes with a flavor that works gdb66 and one that don't gdb
|
||||
# (gdb 6.1) let's try it first the one that works !
|
||||
#
|
||||
FreeBSD)
|
||||
DB_LIST="gdb66 ${DB_LIST}"
|
||||
;;
|
||||
esac
|
||||
|
||||
for DB in ${DB_LIST}; do
|
||||
DB_BIN=`which ${DB} 2>/dev/null | grep '^/'`
|
||||
DB_BIN=$(which ${DB} 2>/dev/null | grep '^/')
|
||||
test x"${DB_BIN}" != x"" && {
|
||||
break
|
||||
}
|
||||
@ -68,59 +67,59 @@ test x"${DB_BIN}" = x"" && {
|
||||
need_binary="no"
|
||||
case "${DB}" in
|
||||
# These debuggers need the process binary specified:
|
||||
ladebug)
|
||||
ladebug)
|
||||
need_binary="yes"
|
||||
;;
|
||||
gdb66)
|
||||
gdb66)
|
||||
need_binary="yes"
|
||||
;;
|
||||
dbx)
|
||||
dbx)
|
||||
need_binary="yes"
|
||||
;;
|
||||
esac
|
||||
|
||||
test x"${need_binary}" = x"yes" && {
|
||||
|
||||
# we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris
|
||||
# then fallback to the binary from the commandline
|
||||
# then we search for the commandline argument with
|
||||
# 'which'
|
||||
#
|
||||
# we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris
|
||||
# then fallback to the binary from the commandline
|
||||
# then we search for the commandline argument with
|
||||
# 'which'
|
||||
#
|
||||
test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe"
|
||||
test -f "/proc/${PID}/path/a.out" && BINARY=`ls -l /proc/${PID}/path/a.out |sed 's/.*-> //'`
|
||||
test -f "/proc/${PID}/path/a.out" && BINARY=$(ls -l /proc/${PID}/path/a.out | sed 's/.*-> //')
|
||||
test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe"
|
||||
test -f "${BINARY}" || BINARY=`which ${BINARY}`
|
||||
|
||||
test -f "${BINARY}" || BINARY=$(which ${BINARY})
|
||||
|
||||
test -f "${BINARY}" || {
|
||||
echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
|
||||
exit 1
|
||||
echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
BATCHFILE_PRE=`mktemp --tmpdir gdb_backtrace_pre.XXXXXXXXXX`
|
||||
BATCHFILE_PRE=$(mktemp --tmpdir gdb_backtrace_pre.XXXXXXXXXX)
|
||||
test -n "${BATCHFILE_PRE}" || {
|
||||
echo "mktemp doesn't work" 1>&2
|
||||
exit 1
|
||||
}
|
||||
BATCHFILE_MAIN=`mktemp --tmpdir gdb_backtrace_main.XXXXXXXXXX`
|
||||
BATCHFILE_MAIN=$(mktemp --tmpdir gdb_backtrace_main.XXXXXXXXXX)
|
||||
test -n "${BATCHFILE_MAIN}" || {
|
||||
echo "mktemp doesn't work" 1>&2
|
||||
exit 1
|
||||
}
|
||||
case "${DB}" in
|
||||
ladebug)
|
||||
cat << EOF > ${BATCHFILE_PRE}
|
||||
ladebug)
|
||||
cat <<EOF >${BATCHFILE_PRE}
|
||||
set \$stoponattach
|
||||
EOF
|
||||
|
||||
cat << EOF > ${BATCHFILE_MAIN}
|
||||
cat <<EOF >${BATCHFILE_MAIN}
|
||||
where
|
||||
quit
|
||||
EOF
|
||||
${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}"
|
||||
;;
|
||||
gdb66)
|
||||
cat << EOF > ${BATCHFILE_MAIN}
|
||||
gdb66)
|
||||
cat <<EOF >${BATCHFILE_MAIN}
|
||||
set height 1000
|
||||
bt full
|
||||
info locals
|
||||
@ -129,15 +128,15 @@ quit
|
||||
EOF
|
||||
${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}"
|
||||
;;
|
||||
gdb)
|
||||
cat << EOF > ${BATCHFILE_MAIN}
|
||||
gdb)
|
||||
cat <<EOF >${BATCHFILE_MAIN}
|
||||
set height 0
|
||||
bt full
|
||||
thread apply all bt full
|
||||
info locals
|
||||
quit
|
||||
EOF
|
||||
${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" < /dev/null
|
||||
${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" </dev/null
|
||||
;;
|
||||
dbx)
|
||||
${DB_BIN} "where;dump;kill;quit" "${BINARY}" "${PID}"
|
||||
|
@ -4,13 +4,13 @@ ENV="$1"
|
||||
|
||||
shift 1
|
||||
|
||||
TMPFILE=`mktemp --tmpdir gdb_run.XXXXXXXXXX`
|
||||
TMPFILE=$(mktemp --tmpdir gdb_run.XXXXXXXXXX)
|
||||
test -n "${TMPFILE}" || {
|
||||
echo "mktemp doesn't work" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cat << EOF > $TMPFILE
|
||||
cat <<EOF >$TMPFILE
|
||||
run
|
||||
bt
|
||||
EOF
|
||||
|
@ -7,12 +7,12 @@ SERVERNAME="$ENVNAME"
|
||||
basedir=$TMPDIR
|
||||
|
||||
[ -r $basedir/$SERVERNAME.pid ] && {
|
||||
for i in {2..100}; do
|
||||
if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then
|
||||
SERVERNAME="${SERVERNAME}-$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
for i in {2..100}; do
|
||||
if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then
|
||||
SERVERNAME="${SERVERNAME}-$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
rm -f $basedir/$SERVERNAME.{launch,log,parent.pid,pid,status}
|
||||
@ -20,11 +20,11 @@ rm -f $basedir/$SERVERNAME.{launch,log,parent.pid,pid,status}
|
||||
# set most of the environment vars we have in the screen session too
|
||||
_ENV=""
|
||||
printenv |
|
||||
egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
|
||||
egrep '^[A-Z]' |
|
||||
sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" > $basedir/$SERVERNAME.vars
|
||||
egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
|
||||
egrep '^[A-Z]' |
|
||||
sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" >$basedir/$SERVERNAME.vars
|
||||
|
||||
cat <<EOF > $basedir/$SERVERNAME.launch
|
||||
cat <<EOF >$basedir/$SERVERNAME.launch
|
||||
cd $PWD
|
||||
echo \$\$ > $basedir/$SERVERNAME.pid
|
||||
. $basedir/$SERVERNAME.vars
|
||||
@ -36,58 +36,59 @@ cd $PWD
|
||||
EOF
|
||||
pid=$$
|
||||
|
||||
cleanup() {
|
||||
trap "exit 1" SIGINT SIGTERM SIGPIPE
|
||||
[ -r $basedir/$SERVERNAME.status ] && {
|
||||
read status < $basedir/$SERVERNAME.status
|
||||
echo "$(date) samba exited with status $status" >> $basedir/$SERVERNAME.log
|
||||
exit $status
|
||||
}
|
||||
cleanup()
|
||||
{
|
||||
trap "exit 1" SIGINT SIGTERM SIGPIPE
|
||||
[ -r $basedir/$SERVERNAME.status ] && {
|
||||
read status <$basedir/$SERVERNAME.status
|
||||
echo "$(date) samba exited with status $status" >>$basedir/$SERVERNAME.log
|
||||
exit $status
|
||||
}
|
||||
|
||||
case $ENVNAME in
|
||||
*.nmbd|*.smbd|*.winbindd|*.samba|*.samba_dcerpcd)
|
||||
kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
|
||||
;;
|
||||
esac
|
||||
case $ENVNAME in
|
||||
*.nmbd | *.smbd | *.winbindd | *.samba | *.samba_dcerpcd)
|
||||
kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
|
||||
;;
|
||||
esac
|
||||
|
||||
read pid < $basedir/$SERVERNAME.pid
|
||||
echo "$(date) Killing samba pid $pid from $$" >> $basedir/$SERVERNAME.log
|
||||
if [ "$pid" = "$$" ]; then
|
||||
read pid <$basedir/$SERVERNAME.pid
|
||||
echo "$(date) Killing samba pid $pid from $$" >>$basedir/$SERVERNAME.log
|
||||
if [ "$pid" = "$$" ]; then
|
||||
exit 1
|
||||
fi
|
||||
kill -9 $pid 2>&1
|
||||
exit 1
|
||||
fi
|
||||
kill -9 $pid 2>&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo $$ > $basedir/$SERVERNAME.parent.pid
|
||||
echo $$ >$basedir/$SERVERNAME.parent.pid
|
||||
trap cleanup SIGINT SIGTERM SIGPIPE
|
||||
|
||||
if [[ "$TMUX" ]]; then
|
||||
TMUX_CMD=tmux
|
||||
if [[ $TMUX = *tmate* ]]; then
|
||||
TMUX_CMD=tmate
|
||||
fi
|
||||
TMUX_CMD=tmux
|
||||
if [[ $TMUX = *tmate* ]]; then
|
||||
TMUX_CMD=tmate
|
||||
fi
|
||||
|
||||
$TMUX_CMD new-window -n test:$SERVERNAME "bash $basedir/$SERVERNAME.launch"
|
||||
$TMUX_CMD new-window -n test:$SERVERNAME "bash $basedir/$SERVERNAME.launch"
|
||||
|
||||
# tmux seems to lag a bit for new sessions. Don't create them too
|
||||
# quickly one after another
|
||||
sleep .1
|
||||
# tmux seems to lag a bit for new sessions. Don't create them too
|
||||
# quickly one after another
|
||||
sleep .1
|
||||
else
|
||||
screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
|
||||
screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
|
||||
fi
|
||||
echo "$(date) waiting in $$" >> $basedir/$SERVERNAME.log
|
||||
echo "$(date) waiting in $$" >>$basedir/$SERVERNAME.log
|
||||
read stdin_var
|
||||
echo "$(date) EOF on stdin" >> $basedir/$SERVERNAME.log
|
||||
echo "$(date) EOF on stdin" >>$basedir/$SERVERNAME.log
|
||||
|
||||
case $ENVNAME in
|
||||
*.nmbd|*.smbd|*.winbindd|*.samba|*.samba_dcerpcd)
|
||||
*.nmbd | *.smbd | *.winbindd | *.samba | *.samba_dcerpcd)
|
||||
kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
|
||||
;;
|
||||
esac
|
||||
|
||||
read pid < $basedir/$SERVERNAME.pid
|
||||
echo "$(date) killing $pid" >> $basedir/$SERVERNAME.log
|
||||
kill $pid 2> /dev/null
|
||||
echo "$(date) exiting" >> $basedir/$SERVERNAME.log
|
||||
read pid <$basedir/$SERVERNAME.pid
|
||||
echo "$(date) killing $pid" >>$basedir/$SERVERNAME.log
|
||||
kill $pid 2>/dev/null
|
||||
echo "$(date) exiting" >>$basedir/$SERVERNAME.log
|
||||
exit 0
|
||||
|
@ -10,13 +10,11 @@ bridge=$2
|
||||
|
||||
# we need to wait for the child namespace to start up and add the new
|
||||
# interface back to our new namespace
|
||||
while ! ip link show $interface > /dev/null 2>&1
|
||||
do
|
||||
sleep 0.1
|
||||
echo "Waiting for $interface to be created..."
|
||||
while ! ip link show $interface >/dev/null 2>&1; do
|
||||
sleep 0.1
|
||||
echo "Waiting for $interface to be created..."
|
||||
done
|
||||
|
||||
# bring the bridge-end of the link up and add it to the bridge
|
||||
ip link set dev $interface up
|
||||
ip link set $interface master $bridge
|
||||
|
||||
|
@ -15,5 +15,3 @@ ip link add $br_name type bridge
|
||||
ip addr add $ip_addr/24 dev $br_name
|
||||
ip addr add $ipv6_addr/112 dev $br_name
|
||||
ip link set $br_name up
|
||||
|
||||
|
||||
|
@ -23,10 +23,9 @@ helper_script="$(dirname $0)/nsenter-helper.sh $exports_file"
|
||||
|
||||
# generate the dynamic script
|
||||
dyn_script="$(dirname $2)/nsenter.sh"
|
||||
echo "#!/bin/sh" > $dyn_script
|
||||
echo "$nsenter_cmd $helper_script" >> $dyn_script
|
||||
echo "#!/bin/sh" >$dyn_script
|
||||
echo "$nsenter_cmd $helper_script" >>$dyn_script
|
||||
chmod 755 $dyn_script
|
||||
|
||||
# return the script we created
|
||||
echo "$dyn_script"
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
# session to a given namespace testenv. This basically just sets up the same
|
||||
# environment variables as you normally get with selftest, for convenience.
|
||||
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo "Usage: $0 <exports-file>"
|
||||
exit 1
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <exports-file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# we get passed a exports file with all the environment variables defined
|
||||
@ -14,11 +14,11 @@ exports_file=$1
|
||||
|
||||
# read the exports file so the new shell has appropriate variables setup
|
||||
# (we export rather than sourcing here so they get inherited by the subshell)
|
||||
while read -r line ; do
|
||||
export $line
|
||||
# dump them for the user too
|
||||
echo $line
|
||||
done < $exports_file
|
||||
while read -r line; do
|
||||
export $line
|
||||
# dump them for the user too
|
||||
echo $line
|
||||
done <$exports_file
|
||||
|
||||
echo ""
|
||||
echo "Entered $NETBIOSNAME namespace, with above variables defined."
|
||||
@ -27,5 +27,3 @@ echo ""
|
||||
|
||||
# start a shell session in the new namespace
|
||||
$SHELL
|
||||
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
{
|
||||
vars=`set | \
|
||||
grep "^[a-zA-Z][^=]*='[^']*'$" | \
|
||||
grep -v '^IFS=' | \
|
||||
grep -v '^TERM' | \
|
||||
grep -v '^PPID' | \
|
||||
grep -v '^PS[1-9]=' | \
|
||||
cat `
|
||||
vars=$(set |
|
||||
grep "^[a-zA-Z][^=]*='[^']*'$" |
|
||||
grep -v '^IFS=' |
|
||||
grep -v '^TERM' |
|
||||
grep -v '^PPID' |
|
||||
grep -v '^PS[1-9]=' |
|
||||
cat)
|
||||
echo "${vars}"
|
||||
echo "${vars}" | sed -e 's!^\([a-zA-Z][^=]*\)=.*$!export \1!'
|
||||
} > bin/restore.env.source
|
||||
} >bin/restore.env.source
|
||||
|
||||
echo "RUN: '. bin/restore.env.source'"
|
||||
|
Loading…
x
Reference in New Issue
Block a user