Added ServerUpdateTools
This commit is contained in:
44
Server/ServerUpdateKickstart.sh
Normal file
44
Server/ServerUpdateKickstart.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
##Build of a release tag (Provided by installer)
|
||||
#RelVer=
|
||||
|
||||
##Build of a release tag (Manual)
|
||||
#RelVer=stable
|
||||
##Build of a master branch, but config is vaidated
|
||||
#RelVer=latest_Tested
|
||||
##Build of a master branch
|
||||
#RelVer=latest
|
||||
RunKs=1
|
||||
|
||||
#Getting build build nubers
|
||||
InstVer=$(cat/opt/ShellHub/build.ID)
|
||||
CurVer=$(wget -q -O- https://git.bprieshof.nl/ci/Releases/ShellHub/$RelVer/build.ID)
|
||||
|
||||
if (("$CurVer" < "$InstVer")); then
|
||||
echo "The installed version is newer!"
|
||||
fi
|
||||
|
||||
if (("$CurVer" <= "$InstVer")); then
|
||||
echo "No update avalible, Exiting"
|
||||
exit
|
||||
fi
|
||||
|
||||
while true; do
|
||||
read -p "Updating from build $InstVer to $CurVer, Do you want to Continue? (y/n)" yn
|
||||
case $yn in
|
||||
[Yy]* ) break;;
|
||||
[Nn]* ) echo "Exiting";exit;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "###############"
|
||||
echo "# WARNING #"
|
||||
echo "###############"
|
||||
echo "Update tool wil NOT update openresty and mongodb"
|
||||
echo "and might not (correctly) update their config files"
|
||||
echo "The installation might brake"
|
||||
|
||||
read -r -s -p $'Press enter to continue...'
|
||||
|
||||
#Getting update script form git repo
|
||||
bash <(curl -Ss "https://git.bprieshof.nl/Tools/ShellHubNative/raw/branch/main/Server/update.sh")
|
||||
@@ -72,8 +72,11 @@ wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/.env -O /opt/ShellH
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/ShellHubSSH-amd64 -O /opt/ShellHub/ShellHubSSH
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/ShellHubAPI-amd64 -O /opt/ShellHub/ShellHubAPI
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinAgent/ShellHubAgent-amd64 -O /opt/ShellHub/ui/agent-amd64
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/build.ID -O /opt/ShellHub/build.ID
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/webui.tar.gz -O /tmp/webui.tar.gz
|
||||
mv ../Agent/Kickstart_template /opt/ShellHub/ui/kickstart.sh
|
||||
mv ServerUpdateKickstart.sh /opt/ShellHub/UpdateKickstart.sh
|
||||
sed -i "0,/RelVer=/ s/.*RelVer=.*/RelVer=$RelVer/g" /opt/ShellHub/UpdateKickstart.sh
|
||||
chmod +x /opt/ShellHub/ShellHubAPI
|
||||
chmod +x /opt/ShellHub/ShellHubSSH
|
||||
tar -zxf /tmp/webui.tar.gz -C /opt/ShellHub/ui
|
||||
|
||||
42
Server/update.sh
Normal file
42
Server/update.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#Run check
|
||||
if [ -z ${RunKs+x} ]; then echo 'Update not started using UpdateKickstart.sh '; exit; fi
|
||||
|
||||
#Stoping service
|
||||
systemctl stop ShellHubAPI ShellHubSSH openresty
|
||||
|
||||
#Moving existing binaries to other foler
|
||||
[[ -d ~/ShellHubBackup ]] && rm -rf ~/ShellHubBackup
|
||||
mkdir ~/ShellHubBackup
|
||||
mv -t ~/ShellHubBackup /opt/ShellHub/nginx.env /opt/ShellHub/shellhub.env /opt/ShellHub/ShellHubSSH /opt/ShellHub/ShellHubAPI /opt/ShellHub/build.ID /opt/ShellHub/ui /opt/ShellHub/tools
|
||||
|
||||
#Updating binaries
|
||||
mkdir -p /opt/ShellHub/{ui,tools}
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/nginx.env -O /opt/ShellHub/nginx.env
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/.env -O /opt/ShellHub/shellhub.env
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/ShellHubSSH-amd64 -O /opt/ShellHub/ShellHubSSH
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/ShellHubAPI-amd64 -O /opt/ShellHub/ShellHubAPI
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinAgent/ShellHubAgent-amd64 -O /opt/ShellHub/ui/agent-amd64
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/build.ID -O /opt/ShellHub/build.ID
|
||||
#Updating Webui
|
||||
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/webui.tar.gz -O /tmp/SHR/webui.tar.gz
|
||||
tar -zxf /tmp/SHR/webui.tar.gz -C /opt/ShellHub/ui
|
||||
mv /tmp/SHR/Agent/Kickstart_template /opt/ShellHub/ui/kickstart.sh
|
||||
#Setting Permissions
|
||||
chmod +x /opt/ShellHub/ShellHubAPI
|
||||
chmod +x /opt/ShellHub/ShellHubSSH
|
||||
|
||||
#Updating tools
|
||||
git clone https://git.bprieshof.nl/Tools/ShellHubNative /tmp/SHR
|
||||
if [ "$RelVer" = "stable" ]; then
|
||||
mv /tmp/SHR/Server/Tools/stable/* /opt/ShellHub/tools/
|
||||
elif [ "$RelVer" = "latest" ] || [ "$RelVer" = "latest_Tested" ]; then
|
||||
mv /tmp/SHR/Server/Tools/latest/* /opt/ShellHub/tools/
|
||||
fi
|
||||
|
||||
#Cleanup
|
||||
rm -rf /tmp/SHR
|
||||
|
||||
#Updating Relvar in next, to ensure its correct for next update
|
||||
sed -i "0,/RelVer=/ s/.*RelVer=.*/RelVer=$RelVer/g" /opt/ShellHub/UpdateKickstart.sh
|
||||
#starting services
|
||||
systemctl start ShellHubAPI ShellHubSSH openresty
|
||||
Reference in New Issue
Block a user