From 015cfedc5c6f5a0bedd5d32f82c532af5aed7be3 Mon Sep 17 00:00:00 2001 From: Michael William Le Nguyen Date: Sat, 8 Feb 2020 18:42:04 -0500 Subject: [PATCH 1/6] Add support for AFS deployment --- deploy.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index 92b03e78..eae9df99 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,3 +1,4 @@ +#!/bin/bash # To run this script you must have 'aklog' written in ~/.bash_environment # (or the environment file for whatever shell you use) # and 'sipb' and 'athena' written in ~/.xlog (both of these files should be in your athena locker). @@ -5,17 +6,39 @@ # even if you are on courseroad-dev. #syntax: ./deploy.sh [dev or prod] [kerberos] +set -e + npm run build-$1 if [ "$1" = "prod" ]; then echo -n "You are about to deploy to the production site, are you sure? (y/n)? " read answer - if [ "$answer" != "${answer#[Yy]}" ] ;then - scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ + if [ "$answer" != "${answer#[Yy]}" ]; then + echo "Checking for OpenAFS on this system" + if which aklog; then + echo "OpenAFS detected, using OpenAFS for deployment" + kinit -f -l 1h $2 + aklog sipb + rsync --delete --progress --checksum -r dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/ + kdestroy + else + echo "Could not locate OpenAFS, using SSH for deployment" + scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ + fi else - echo cancelled + echo "Cancelled" fi -elif [ "$1" = "dev" ]; then +elif [ "$1" == "dev" ]; then + echo "Checking for OpenAFS on this system" + if which aklog; then + echo "OpenAFS detected, using OpenAFS for deployment" + kinit -f -l 1h $2 + aklog sipb + rsync --delete --progress --checksum -r dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/dev/ + kdestroy + else + echo "Could not locate OpenAFS, using SSH for deployment" scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/dev/ + fi else echo "Invalid build location" fi From a522ea6dc79d4d82f583b5a3a3ab8946de009e8a Mon Sep 17 00:00:00 2001 From: Miriam Rittenberg Date: Tue, 25 Feb 2020 18:37:58 -0500 Subject: [PATCH 2/6] Use kdo if it exists --- deploy.sh | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/deploy.sh b/deploy.sh index eae9df99..3af48d65 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,4 +1,6 @@ -#!/bin/bash +if [ $SHELL = "/bin/zsh" ]; then + source ~/.zshrc +fi # To run this script you must have 'aklog' written in ~/.bash_environment # (or the environment file for whatever shell you use) # and 'sipb' and 'athena' written in ~/.xlog (both of these files should be in your athena locker). @@ -13,30 +15,38 @@ if [ "$1" = "prod" ]; then echo -n "You are about to deploy to the production site, are you sure? (y/n)? " read answer if [ "$answer" != "${answer#[Yy]}" ]; then - echo "Checking for OpenAFS on this system" - if which aklog; then - echo "OpenAFS detected, using OpenAFS for deployment" - kinit -f -l 1h $2 - aklog sipb + echo "Checking for AFS on this system" + if which aklog &>/dev/null; then + echo "AFS detected, using AFS for deployment" + if which kdo &>/dev/null; then + echo "Using kdo" + kdo $2 aklog sipb + else + kinit -f -l 1h $2 + aklog sipb + fi rsync --delete --progress --checksum -r dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/ - kdestroy else - echo "Could not locate OpenAFS, using SSH for deployment" + echo "Could not locate AFS, using SSH for deployment" scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ fi else echo "Cancelled" fi -elif [ "$1" == "dev" ]; then - echo "Checking for OpenAFS on this system" - if which aklog; then - echo "OpenAFS detected, using OpenAFS for deployment" - kinit -f -l 1h $2 - aklog sipb +elif [ "$1" = "dev" ]; then + echo "Checking for AFS on this system" + if which aklog &>/dev/null; then + echo "AFS detected, using AFS for deployment" + if which kdo &>/dev/null; then + echo "Using kdo" + kdo $2 aklog sipb + else + kinit -f -l 1h $2 + aklog sipb + fi rsync --delete --progress --checksum -r dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/dev/ - kdestroy else - echo "Could not locate OpenAFS, using SSH for deployment" + echo "Could not locate AFS, using SSH for deployment" scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/dev/ fi else From 7865e810bf0f999c0fdc92fea6d9098a511451b2 Mon Sep 17 00:00:00 2001 From: Miriam Rittenberg Date: Tue, 25 Feb 2020 19:08:57 -0500 Subject: [PATCH 3/6] Also copy htaccess --- deploy.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index 3af48d65..6acf7ba4 100755 --- a/deploy.sh +++ b/deploy.sh @@ -25,10 +25,10 @@ if [ "$1" = "prod" ]; then kinit -f -l 1h $2 aklog sipb fi - rsync --delete --progress --checksum -r dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/ + rsync --delete --progress --checksum -r deploy/development/.htaccess dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/ else echo "Could not locate AFS, using SSH for deployment" - scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ + scp -r deploy/development/.htaccess dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ fi else echo "Cancelled" @@ -44,10 +44,10 @@ elif [ "$1" = "dev" ]; then kinit -f -l 1h $2 aklog sipb fi - rsync --delete --progress --checksum -r dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/dev/ + rsync --delete --progress --checksum -r deploy/development/.htaccess dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/dev/ else echo "Could not locate AFS, using SSH for deployment" - scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/dev/ + scp -r deploy/development/.htaccess dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/dev/ fi else echo "Invalid build location" From ede7801a02b4b5f66af0bbc06e79e4e74c1a2a51 Mon Sep 17 00:00:00 2001 From: Nate Foss Date: Sat, 29 Feb 2020 16:57:27 -0500 Subject: [PATCH 4/6] fix prod dir typo --- deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 6acf7ba4..cf705bc0 100755 --- a/deploy.sh +++ b/deploy.sh @@ -25,10 +25,10 @@ if [ "$1" = "prod" ]; then kinit -f -l 1h $2 aklog sipb fi - rsync --delete --progress --checksum -r deploy/development/.htaccess dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/ + rsync --delete --progress --checksum -r deploy/production/.htaccess dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/ else echo "Could not locate AFS, using SSH for deployment" - scp -r deploy/development/.htaccess dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ + scp -r deploy/production/.htaccess dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ fi else echo "Cancelled" From d3b7a4a04e6dbff6c6b37946c2a64fd2cae4056f Mon Sep 17 00:00:00 2001 From: Nate Foss Date: Sat, 29 Feb 2020 17:10:47 -0500 Subject: [PATCH 5/6] add some comments --- deploy.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/deploy.sh b/deploy.sh index cf705bc0..2568e94b 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,13 +1,17 @@ +# To run this script you must have *in your athena locker*: +# - 'aklog' written in ~/.bash_environment (or the environment file for whatever shell you use) +# - 'sipb' and 'athena' written in ~/.xlog. +# Otherwise, you will not have permission to access the courseroad locker, +# even if you are on courseroad-dev@. + +#syntax: ./deploy.sh [dev|prod] [kerberos] + +# this section is for Miriam's kdo setup if [ $SHELL = "/bin/zsh" ]; then source ~/.zshrc fi -# To run this script you must have 'aklog' written in ~/.bash_environment -# (or the environment file for whatever shell you use) -# and 'sipb' and 'athena' written in ~/.xlog (both of these files should be in your athena locker). -# Otherwise, you will not have permission to access the courseroad locker, -# even if you are on courseroad-dev. -#syntax: ./deploy.sh [dev or prod] [kerberos] +# exit if anything errors set -e npm run build-$1 @@ -19,15 +23,16 @@ if [ "$1" = "prod" ]; then if which aklog &>/dev/null; then echo "AFS detected, using AFS for deployment" if which kdo &>/dev/null; then - echo "Using kdo" + echo "Using kdo" kdo $2 aklog sipb else - kinit -f -l 1h $2 - aklog sipb + kinit -f -l 1h $2 + aklog sipb fi rsync --delete --progress --checksum -r deploy/production/.htaccess dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/ else echo "Could not locate AFS, using SSH for deployment" + # this is what happens without any fancy setup scp -r deploy/production/.htaccess dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/ fi else @@ -47,6 +52,7 @@ elif [ "$1" = "dev" ]; then rsync --delete --progress --checksum -r deploy/development/.htaccess dist/* /afs/sipb.mit.edu/project/courseroad/web_scripts/courseroad/dev/ else echo "Could not locate AFS, using SSH for deployment" + # this is what happens without any fancy setup scp -r deploy/development/.htaccess dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/dev/ fi else From 8fa8d13f96ce46abf439debe45af9e3ab54e2075 Mon Sep 17 00:00:00 2001 From: Nate Foss Date: Tue, 3 Mar 2020 19:59:41 -0500 Subject: [PATCH 6/6] add shebang --- deploy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy.sh b/deploy.sh index 2568e94b..71884193 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,3 +1,4 @@ +#!/bin/bash # To run this script you must have *in your athena locker*: # - 'aklog' written in ~/.bash_environment (or the environment file for whatever shell you use) # - 'sipb' and 'athena' written in ~/.xlog.