Files
zulip/tools/test-install/destroy-all
Anders Kaseorg c4ed4bc021 test-install: Fix shellcheck warnings.
In tools/test-install/destroy-all line 31:
  | while read c
          ^-- SC2162: read without -r will mangle backslashes.

In tools/test-install/install line 57:
    installer_dir="$(readlink -f $INSTALLER)"
                                 ^-- SC2086: Double quote to prevent globbing and word splitting.

In tools/test-install/lxc-wait line 30:
for i in {1..60}; do
^-- SC2034: i appears unused. Verify use (or export if used externally).

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2018-08-03 09:15:27 -07:00

37 lines
629 B
Bash
Executable File

#!/bin/bash
set -e
usage() {
echo "usage: destroy-all -f" >&2
exit 1
}
args="$(getopt -o +f --long help,force -- "$@")"
eval "set -- $args"
while true; do
case "$1" in
--help) usage;;
-f|--force) FORCE=1; shift;;
--) shift; break;;
*) usage;;
esac
done
if [ -z "$FORCE" ] || [ "$#" -gt 0 ]; then
usage
fi
if [ "$EUID" -ne 0 ]; then
echo "error: this script must be run as root" >&2
exit 1
fi
lxc-ls -f \
| perl -lane '$_ = $F[0]; print if (/^zulip-install-/ && !/-base$/)' \
| while read -r c
do
echo "$c"
lxc-stop -n "$c"
lxc-destroy -n "$c"
done