mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
test-install: Add command destroy-all to clean up test containers.
This is just the one-liner I've been keeping in my shell history, cleaned up a bit (newlines!) and with 28 lines of CLI boilerplate added in front.
This commit is contained in:
36
tools/test-install/destroy-all
Executable file
36
tools/test-install/destroy-all
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/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 c
|
||||
do
|
||||
echo "$c"
|
||||
lxc-stop -n "$c"
|
||||
lxc-destroy -n "$c"
|
||||
done
|
||||
Reference in New Issue
Block a user