Added ServerUpdateTools

This commit is contained in:
2021-01-18 18:22:14 +01:00
parent 89786ee37b
commit 116f219bb7
4 changed files with 93 additions and 0 deletions

42
Server/update.sh Normal file
View 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