From f56de6aef4d6d2967c132b86dc21e40c5100023b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 3 May 2018 14:32:23 +0200 Subject: [PATCH] Implement optional changing of git remotes to HTTPS --- hack/bootstrap_tfw_dev.sh | 31 +++++++++++++++++++++++++++---- hack/oneline_install.sh | 2 +- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/hack/bootstrap_tfw_dev.sh b/hack/bootstrap_tfw_dev.sh index 7b81f5f..a1ea5d9 100755 --- a/hack/bootstrap_tfw_dev.sh +++ b/hack/bootstrap_tfw_dev.sh @@ -9,6 +9,7 @@ pushd() { command pushd "$@" > /dev/null; } popd() { command popd "$@" > /dev/null; } TFWDEV="${TFWDEV:-0}" +HTTPS_REMOTES="${HTTPS_REMOTES:-}" TFW_POSTFIX=tutorial-framework BASEDIR="$(pwd)" BASEIMAGE=baseimage-${TFW_POSTFIX} @@ -23,7 +24,7 @@ run() : > $LOGFILE check_dependencies - clone_repos + clone_repos_ask_ssh_or_https install_frontend_deps if [ "$TFWDEV" == "0" ]; then LATESTTAG="$(fetch_latest_tag)" @@ -73,12 +74,34 @@ check_dependencies() fi } +clone_repos_ask_ssh_or_https() +{ + if [[ -z "$HTTPS_REMOTES" ]]; then + read -p "Repos are pulled over SSH by default. Should I use HTTPS instead? [y/N]" -r -t 5 || : + echo + if [[ $REPLY =~ ^(y|Y|yes|Yes|YES)$ ]]; then + HTTPS_REMOTES=1 clone_repos + else + HTTPS_REMOTES=0 clone_repos + fi + else + clone_repos + fi +} + clone_repos() { + remotebase="git@github.com:" + spinned_or_not="spinned" + if [[ "$HTTPS_REMOTES" == "1" ]]; then + remotebase="https://github.com/" + spinned_or_not="" + fi + echo -n "Cloning TFW repositories... " - echo -n "baseimage... " && spinned logged git clone git@github.com:avatao-content/${BASEIMAGE}.git - echo -n "frontend... " && spinned logged git clone git@github.com:avatao-content/${FRONTEND}.git - echo -n "test... " && spinned logged git clone git@github.com:avatao-content/${TEST}.git + echo -n "baseimage... " && ${spinned_or_not} logged git clone ${remotebase}avatao-content/${BASEIMAGE}.git + echo -n "frontend... " && ${spinned_or_not} logged git clone ${remotebase}avatao-content/${FRONTEND}.git + echo -n "test... " && ${spinned_or_not} logged git clone ${remotebase}avatao-content/${TEST}.git echo "Done!" } diff --git a/hack/oneline_install.sh b/hack/oneline_install.sh index 0eb36b2..6658226 100644 --- a/hack/oneline_install.sh +++ b/hack/oneline_install.sh @@ -1 +1 @@ -URL=https://git.io/vxBfj SHA=ec150859770843f4f8b4f5a16e08cc133c003b209272e715cfcfcd465b3b36e6 bash -c 'cmd="$(curl -fsSL $URL)" && [ $(echo "$cmd" | sha256sum | cut -d " " -f1) == $SHA ] && echo "$cmd" | bash || echo Checksum mismatch!' +URL=https://git.io/vxBfj SHA=839906a1d2fce5a2fd4c01129dc03a90b520cf004009ebe431938e4ed835f240 bash -c 'cmd="$(curl -fsSL $URL)" && [ $(echo "$cmd" | sha256sum | cut -d " " -f1) == $SHA ] && echo "$cmd" | bash || echo Checksum mismatch!'