diff options
author | NeodarZ <neodarz@neodarz.net> | 2017-07-06 23:20:04 +0200 |
---|---|---|
committer | NeodarZ <neodarz@neodarz.net> | 2017-07-06 23:20:04 +0200 |
commit | cded819c74e40c2f43c155e19a1f84340c2987a2 (patch) | |
tree | 1ffdbd22518ba5ba5b6c03201859473ed9b3d297 /server_remove.sh | |
download | EphermalVPN-cded819c74e40c2f43c155e19a1f84340c2987a2.tar.xz EphermalVPN-cded819c74e40c2f43c155e19a1f84340c2987a2.zip |
Diffstat (limited to 'server_remove.sh')
-rwxr-xr-x | server_remove.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server_remove.sh b/server_remove.sh new file mode 100755 index 0000000..5e45843 --- /dev/null +++ b/server_remove.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# TODO: Test if $1 is OK before run this command ! + +SERVER_ID=$1 +SERVER_LIST="9fc55cd0|82b5bdd4|011b7885" + +if [[ $1 =~ ^[a-zA-Z0-9]{8,} && $(echo $@ | wc -w) == 1 ]]; then + scw stop $(echo $SERVER_ID) + scw wait $(echo $SERVER_ID) + scw rm $(echo $SERVER_ID) +elif [[ $1 == "all" ]]; then + SERVER_TO_RM=$(scw ps -a | awk "!/.*($SERVER_LIST).*/ {print \$1}" | awk '/^[a-zA-Z0-9]{8,}$/' | sed ':a;N;$!ba;s/\n/ /g') + scw stop $SERVER_TO_RM + scw wait $SERVER_TO_RM + scw rm $SERVER_TO_RM +else + echo "Syntax error !" + echo "Correct syntax => remove_server.sh [OPTION] SERVER_ID" + echo "The length of SERVER_ID is 1 word of 8 caractere" + echo "Option list" + echo " all Remove all server but not the server id who match with : $SERVER_LIST" +fi + + |