added primitive protocol switcher for submodules

This commit is contained in:
mrfry 2023-04-11 08:37:01 +02:00
parent 8647088faf
commit 7d1bddd7e2
6 changed files with 75 additions and 10 deletions

View file

@ -7,9 +7,11 @@ hr() { [ -t 0 ] && printf '\033[0;32m%*s\033[0m\n' "$(tput cols)" '' | tr ' ' '=
log() { hr; echo -e "\033[0;34m${1}\033[0m"; hr; }
error() { echo -e "\033[0;41m${1}\033[0m"; }
checkFile() {
if [ ! -f "${1}" ]; then
echo -e "\033[0;41m${1} does not exist!\033[0m"
error "${1} does not exist!"
exit 1
fi
}
@ -37,7 +39,7 @@ checkFile "$PWD/src/server.ts"
checkFile "$PWD/package.json"
checkFile "$PWD/package-lock.json"
if [ ! -f "${domainPath}" ]; then
echo -e "\033[0;41m${domainPath} does not exist!\033[0m"
error "${domainPath} does not exist!"
echo "Please create it, and re-run this script."
echo "Expected content: domain, ex.:'frylabs.net' (without http:// and /)"
exit 1
@ -62,6 +64,10 @@ cp -vrn ./defaultPublicFiles/* ./publicDirs/qminingPublic/
# ------------------------------------------------------------------------------------
# Git submodules
# ------------------------------------------------------------------------------------
if [ ! -z "$CLONE_WITH_HTTPS" ]; then
./scripts/switchGitProtocol.sh "https"
fi
log 'Updating / Cloning project'
git pull || exit 1
git submodule update --init --recursive --remote || exit 1

22
scripts/switchGitProtocol.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
gitDir=".git"
gitmoduleFile=".gitmodules"
sshGitmodulesFile=".gitmodules.ssh"
httpsGitmodulesFile=".gitmodules.https"
function error() { echo -e "\033[0;41m${1}\033[0m"; exit 1; }
if [ ! -d "${gitDir}" ]; then
error "${gitDir} does not exist! Maybe you ran this script in the wrong directory"
fi
if [ "$1" != "ssh" ] && [ "$1" != "https" ]; then
error "Invalid param! Valid params are: 'ssh', 'https'"
fi
if [ "$1" == "ssh" ]; then
cp -v "$sshGitmodulesFile" "$gitmoduleFile"
elif [ "$1" == "https" ]; then
cp -v "$httpsGitmodulesFile" "$gitmoduleFile"
fi