aboutsummaryrefslogtreecommitdiff
path: root/server_remove.sh
diff options
context:
space:
mode:
Diffstat (limited to 'server_remove.sh')
-rwxr-xr-xserver_remove.sh25
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
+
+