20482: Makes installer.sh compatible with older (Ubuntu 18.04) git versions.
[arvados.git] / tools / salt-install / installer.sh
index 000ed32929d892dd7515cd0beb70a302fcde0ba2..5a55e337da3248e22c335f5ac7d9be3e020d9ae6 100755 (executable)
@@ -202,11 +202,12 @@ case "$subcmd" in
        if [[ -n "$TERRAFORM" ]] ; then
            mkdir $SETUPDIR/terraform
            cp -r $TERRAFORM/* $SETUPDIR/terraform/
        if [[ -n "$TERRAFORM" ]] ; then
            mkdir $SETUPDIR/terraform
            cp -r $TERRAFORM/* $SETUPDIR/terraform/
-               cp $TERRAFORM/.gitignore $SETUPDIR/terraform/
        fi
 
        cd $SETUPDIR
        echo '*.log' > .gitignore
        fi
 
        cd $SETUPDIR
        echo '*.log' > .gitignore
+       echo '**/.terraform' >> .gitignore
+       echo '**/.infracost' >> .gitignore
 
        if [[ -n "$TERRAFORM" ]] ; then
                git add terraform
 
        if [[ -n "$TERRAFORM" ]] ; then
                git add terraform
@@ -235,6 +236,13 @@ case "$subcmd" in
        (cd terraform/services && echo -n 'letsencrypt_iam_secret_access_key = ' && terraform output letsencrypt_iam_secret_access_key) 2>&1 | tee -a $logfile
        ;;
 
        (cd terraform/services && echo -n 'letsencrypt_iam_secret_access_key = ' && terraform output letsencrypt_iam_secret_access_key) 2>&1 | tee -a $logfile
        ;;
 
+    terraform-destroy)
+       logfile=terraform-$(date -Iseconds).log
+       (cd terraform/services && terraform destroy) 2>&1 | tee -a $logfile
+       (cd terraform/data-storage && terraform destroy) 2>&1 | tee -a $logfile
+       (cd terraform/vpc && terraform destroy) 2>&1 | tee -a $logfile
+       ;;
+
     generate-tokens)
        for i in BLOB_SIGNING_KEY MANAGEMENT_TOKEN SYSTEM_ROOT_TOKEN ANONYMOUS_USER_TOKEN WORKBENCH_SECRET_KEY DATABASE_PASSWORD; do
            echo ${i}=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32 ; echo '')
     generate-tokens)
        for i in BLOB_SIGNING_KEY MANAGEMENT_TOKEN SYSTEM_ROOT_TOKEN ANONYMOUS_USER_TOKEN WORKBENCH_SECRET_KEY DATABASE_PASSWORD; do
            echo ${i}=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32 ; echo '')
@@ -256,7 +264,7 @@ case "$subcmd" in
            exit 1
        fi
 
            exit 1
        fi
 
-       BRANCH=$(git branch --show-current)
+       BRANCH=$(git rev-parse --abbrev-ref HEAD)
 
        set -x
 
 
        set -x
 
@@ -341,6 +349,7 @@ case "$subcmd" in
        echo ""
        echo "initialize        initialize the setup directory for configuration"
        echo "terraform         create cloud resources using terraform"
        echo ""
        echo "initialize        initialize the setup directory for configuration"
        echo "terraform         create cloud resources using terraform"
+       echo "terraform-destroy destroy cloud resources created by terraform"
        echo "generate-tokens   generate random values for tokens"
        echo "deploy            deploy the configuration from the setup directory"
        echo "diagnostics       check your install using diagnostics"
        echo "generate-tokens   generate random values for tokens"
        echo "deploy            deploy the configuration from the setup directory"
        echo "diagnostics       check your install using diagnostics"