astroport/git-update.sh

32 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
{ # this ensures the entire script is downloaded #
# Check if astroport folder exist
[[ -d astroport ]] && rm -rf astroport && echo "astroport folder has been deleted."
[[ -z $(which git) ]] && echo "installation de git..." && sudo apt install git
isp2plegal=$(nc -zv -w 1 192.168.9.19 3000 2<&1)
if [[ "$isp2plegal" =~ "(?) open" ]]; then
isp2plegalbool=true
giturl="http://192.168.9.19:3000"
else
isp2plegalbool=false
giturl="https://git.p2p.legal"
fi
[[ ${PWD##*/} != astroport ]] && git clone $giturl/axiom-team/astroport.git && cd astroport
[[ $isp2plegalbool == true ]] && sed -i 's/https:\/\/git.p2p.legal/http:\/\/192.168.9.19:3000/g' .gitmodules && echo "Infra p2p.legal detected, switch remotes submodules"
echo -e '#!/bin/bash\n./git-update.sh' > .git/hooks/post-merge
git submodule update --init --recursive
#source ./git-update.sh
echo "Updating git submodules ..."
git submodule foreach git pull origin master
echo "Astroport updated!"
echo "Astroport ready to go!"
exit 0
} # this ensures the entire script is downloaded #