summaryrefslogtreecommitdiff
path: root/install/ishtar-delete-instance
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-05-01 21:05:11 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-05-01 21:05:11 +0200
commit183591d0e09272c0eadb2fc928370ccd965bfd91 (patch)
tree7609fc700402e10f7fe27a2c7df751d6c8dc8a71 /install/ishtar-delete-instance
parente0cc2800330d92ad577384ea72659427918f589d (diff)
downloadIshtar-183591d0e09272c0eadb2fc928370ccd965bfd91.tar.bz2
Ishtar-183591d0e09272c0eadb2fc928370ccd965bfd91.zip
Update installation scripts
Diffstat (limited to 'install/ishtar-delete-instance')
-rwxr-xr-xinstall/ishtar-delete-instance85
1 files changed, 85 insertions, 0 deletions
diff --git a/install/ishtar-delete-instance b/install/ishtar-delete-instance
new file mode 100755
index 000000000..f67770d4d
--- /dev/null
+++ b/install/ishtar-delete-instance
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+set -e
+
+do_delete_instance() {
+ NGINX_AVAILABLE_PATH='/etc/nginx/sites-available'
+ NGINX_ENABLE_PATH='/etc/nginx/sites-enabled'
+ UWSGI_AVAILABLE_PATH='/etc/uwsgi/apps-available'
+ UWSGI_ENABLE_PATH='/etc/uwsgi/apps-enabled'
+
+ if [ ! -z '$CONFIG_PATH' ]; then
+ CONFIG_PATH="/etc/ishtar/"
+ fi
+
+ if [ ! -f $CONFIG_PATH/config ]; then
+ echo "";
+ echo ""$CONFIG_PATH" is not a valid config file."
+ echo "Have you properly install Ishtar sources?"
+ echo "Run ishtar-install before this script.";
+ echo "";
+ exit 1;
+ fi
+
+ source $CONFIG_PATH/config
+
+ INSTANCES_FILE=$CONFIG_PATH/instances
+ if [ ! -f $INSTANCES_FILE ]; then
+ echo "";
+ echo "No instance installated. Exiting."
+ echo "";
+ exit 1;
+ fi
+
+ cat >&2 <<-'EOF'
+
+*******************************************************************************
+++++++ Ishtar instance deletion script ++++++
+*******************************************************************************
+
+ Avalaible instances:
+
+EOF
+
+ cat $INSTANCES_FILE
+
+ to_delete=''
+ echo ""
+ while [ "$to_delete" == '' ]
+ do
+ read -p "* Which one would you like to delete? " choice
+ GRP=`cat $INSTANCES_FILE | grep "^$choice$"`
+ if [ "$GRP" != '' ]; then
+ to_delete=$choice
+ fi
+ done
+ echo ""
+ echo "Are you really sure to delete configuration, database and media attached to the "
+ echo "instance "$to_delete"?"
+ echo ""
+ read -p "* Type DELETE if you are sure: " choice
+ if [ "$choice" != "DELETE" ]; then
+ exit 1
+ fi
+
+ sed '/'$to_delete'/d' $INSTANCES_FILE > /tmp/new_instances
+ mv /tmp/new_instances $INSTANCES_FILE
+
+ INSTANCE=$to_delete
+ rm -rf $ISHTAR_PATH/$INSTANCE
+ rm -f "$NGINX_AVAILABLE_PATH/ishtar-$INSTANCE.conf"
+ rm -f "$NGINX_ENABLE_PATH/ishtar-$INSTANCE.conf"
+ rm -f "$UWSGI_AVAILABLE_PATH/ishtar-$INSTANCE.ini"
+ rm -f "$UWSGI_ENABLE_PATH/ishtar-$INSTANCE.ini"
+
+ DB_NAME="ishtar-$INSTANCE"
+ export DB_NAME
+ su postgres <<'EOF'
+ dropdb "$DB_NAME"
+ dropuser "$DB_NAME"
+EOF
+
+ echo $to_delete" have been completly removed"
+}
+
+do_delete_instance