From e72294d0392b5411f93d8279bf7ef9baccec9f57 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 20 Jun 2023 12:27:07 -0700 Subject: [PATCH] refactored repositories install methods --- extras/Slipstream.install | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/extras/Slipstream.install b/extras/Slipstream.install index 811134b..7d2bfb0 100755 --- a/extras/Slipstream.install +++ b/extras/Slipstream.install @@ -1,8 +1,9 @@ #!/bin/bash # CodeDog Bootstrap installer script # To run this script without cloning or downloading anything: -# bash <(curl -ks 'https://github.com/pyr0ball/PRbL-bashrc/raw/main/extras/Slipstream.install') +# curl -H 'Cache-Control: no-cache' -kLs 'https://github.com/pyr0ball/PRbL-bashrc/raw/main/extras/Slipstream.install' | bash -s -- -i # Bash expansions to get the name and location of this script when run +installdir="$HOME/.local/share/s3dk" scriptname="${BASH_SOURCE[0]##*/}" rundir="${BASH_SOURCE[0]%/*}" @@ -28,7 +29,6 @@ else fi logfile="${rundir}/${pretty_date}_${scriptname}.log" -installdir="$HOME/devl" # Dependencies sys_packages=( @@ -43,9 +43,9 @@ pip_packages=( ) repo_packages=( - https://github.com/BruceDLong/CodeDog.git - https://github.com/BruceDLong/Proteus.git - https://github.com/BruceDLong/Slipstream.git + BruceDLong/CodeDog + BruceDLong/Proteus + BruceDLong/Slipstream ) prbl_packages=( @@ -174,12 +174,30 @@ install(){ fi run mkdir -p $installdir pushd $installdir - for repo in ${repo_packages[@]} ; do - clone-repo $repo + for repo in "${repo_packages[@]}"; do + if ! check-git-repository "repositories/${repo#*/}"; then + if [ -d "repositories/${repo#*/}" ] ; then + warn "Existing repo ${repo#*/} is broken..." + return 1 + else + logger echo "Cloning ${repo} into ${installdir}/repositories/${repo#*/}" + clone-repo "https://github.com/$repo" "${installdir}/repositories/${repo#*/}" + fi + else + pushd "repositories/${repo#*/}" + if [[ ${VERSIONS[${repo#*/}]} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Version tag detected: ${VERSIONS[${repo#*/}]}" + git checkout "${VERSIONS[${repo#*/}]}" + else + echo "Commit hash detected: ${VERSIONS[${repo#*/}]}" + git checkout -q "${VERSIONS[${repo#*/}]}" + fi + popd + fi done popd pushd $installdir/Proteus - run sudo python3 ruleMgr.py + run sudo python3 ruleMgr.py && logger echo "Proteus Initialized..." popd pushd $installdir/Slipstream run $installdir/CodeDog/codeDog ./Slipstream.dog && logger echo "Slipstream app built at ${installdir}/Slipstream/LinuxBuild"