2018-12-18 02:08:53 +01:00
|
|
|
#!/usr/bin/env bash
|
2018-02-09 02:29:41 +01:00
|
|
|
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
|
2020-10-15 04:55:57 +02:00
|
|
|
--help) usage ;;
|
|
|
|
-f | --force)
|
|
|
|
FORCE=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*) usage ;;
|
2018-02-09 02:29:41 +01:00
|
|
|
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 \
|
2020-10-15 04:55:57 +02:00
|
|
|
| perl -lane '$_ = $F[0]; print if (/^zulip-install-/ && !/-base$/)' \
|
|
|
|
| while read -r c; do
|
|
|
|
echo "$c"
|
|
|
|
lxc-destroy -f -n "$c"
|
|
|
|
done
|