revamp nixops structure(s)
This commit is contained in:
45
nixops/bin/teardown.sh
Executable file
45
nixops/bin/teardown.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TOP="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.."
|
||||
|
||||
reboot=no
|
||||
case $1 in
|
||||
--reboot) reboot=yes; shift ;;
|
||||
esac
|
||||
|
||||
if [ $# != 1 ]; then
|
||||
echo "usage: teardown.sh [--reboot] name"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
d=$1
|
||||
tmp=$TOP/.$d.$$
|
||||
|
||||
teardown () {
|
||||
mkdir -p $tmp
|
||||
cp -r $TOP/$d/* $tmp
|
||||
sed -i '/k8s *= *{/,+1 s/enable *= *true/enable = false/' $tmp/cluster.nix
|
||||
nixops modify -d $d $tmp
|
||||
nixops deploy -d $d
|
||||
[ $reboot = yes ] && nixops reboot -d $d
|
||||
nixops ssh-for-each -d $d \
|
||||
"rm -rf /var/run/kubernetes /var/lib/kubernetes /var/lib/etcd /var/lib/kubelet /var/lib/cfssl"
|
||||
rm -rf $tmp
|
||||
}
|
||||
cat << EOF
|
||||
|
||||
************************************************************************
|
||||
*** ***
|
||||
*** WARNING: This will irrevokably destroy the running cluster! ***
|
||||
*** ***
|
||||
************************************************************************
|
||||
|
||||
EOF
|
||||
|
||||
echo "Are you sure you want to tear down $d? (YES/no)"
|
||||
read a
|
||||
case $a in
|
||||
YES) teardown ;;
|
||||
*) echo "Bailing out." ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user