Updated Builder-GetResources and SW-updateScripts

GetExternalResources has function for geting release version from github

PhpMyadmin and elkarbackup(alpine) now have update tools
This commit is contained in:
2021-11-19 01:05:50 +00:00
parent 44ff96bbbd
commit c935713877
8 changed files with 74 additions and 16 deletions

3
.gitignore vendored
View File

@@ -15,4 +15,5 @@ CT-Files/mailbackup/OfflineIMAP3-installed
CT-Files/mailbackup/rainloop-installed
CT-Files/mailbackup/MailBackup-sys
CT-Files/elkarbackupDEB/rsnapshot.deb
CT-Files/elkarbackupALP/Elkarbackup-installed
CT-Files/elkarbackupALP/Elkarbackup-installed
CT-Files/mysql/phpmyadminVersion

View File

@@ -1026,6 +1026,7 @@ packages:
- tvheadend
- x2go
- aptcacherng
- mysql
#Minimal pkgs
- packages:

View File

@@ -22,7 +22,9 @@ rm -f /opt/Setup/elkb.tar.gz
chown -R nginx:nginx /opt/elkarbackup
sudo -u nginx php /opt/composer/composer.phar install -n --working-dir=/opt/elkarbackup/srv --no-dev
mv /opt/Setup/Configs/elkarbackupconf.yaml /opt/elkarbackup/srv/config/parameters.yaml
mv /opt/Setup/Elkarbackup-installed /opt/Elkarbackup-installed
sed -i 's#/var/cache/nginx#/opt/elkarbackup/home#g' /etc/passwd
mv /opt/Setup/Scripts/updateElkarbackup.sh /opt/updateElkarbackup.sh
#Configure Nginx
rm -rf /etc/nginx/conf.d

View File

@@ -0,0 +1,23 @@
#!/bin/ash
NewElkarbackupVersion=$(curl -s https://api.github.com/repos/elkarbackup/elkarbackup/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
if test "$NewElkarbackupVersion" = "$(cat /opt/Elkarbackup-installed)" ; then
echo 'Elkarbackup up-to-date'
exit
else
echo 'Backin-up current version'
rm -rf /opt/elkarbackup/srv.bck
mv /opt/elkarbackup/srv /opt/elkarbackup/srv.bck
echo 'Updating Elkarbackup'
curl --retry 7 --retry-delay 5 -s -L https://github.com/elkarbackup/elkarbackup/archive/refs/tags/$NewElkarbackupVersion.tar.gz -o /tmp/elbck.tar.gz
mkdir /opt/elkarbackup/srv
tar -C /opt/elkarbackup/srv -xzf /tmp/elbck.tar.gz --strip 1
rm -rf /tmp/elbck.tar.gz
chown -R nginx:nginx /opt/elkarbackup
sudo -u nginx php /opt/composer/composer.phar install -n --working-dir=/opt/elkarbackup/srv --no-dev
cp /opt/elkarbackup/srv.bck/config/parameters.yaml /opt/elkarbackup/srv/config/parameters.yaml
sudo -u nginx APP_ENV=prod APP_DEBUG=0 php /opt/elkarbackup/srv/bin/console cache:clear
mv /opt/Elkarbackup-installed /opt/srv.bck/Elkarbackup-Ver-ThisFolder
echo $NewElkarbackupVersion > /opt/srv.bck/Elkarbackup-installed
fi

View File

@@ -11,5 +11,7 @@ tar -C /opt/PhpMyAdmin -xzf /opt/Setup/phpmyadmin.tar.gz --strip 1
rm -rf /opt/Setup/phpmyadmin.tar.gz
mv /opt/Setup/Configs/config.inc.php /opt/PhpMyAdmin/config.inc.php
mv /opt/Setup/Configs/phpmyadmin.service /etc/systemd/system/phpmyadmin.service
mv /opt/Setup/phpmyadminVersion /opt/phpmyadmin-installed
mv /opt/Setup/Scripts/UpdatePhpMyadmin.sh /opt/UpdatePhpMyadmin.sh
chmod +x /etc/systemd/system/phpmyadmin.service
ln -s /etc/systemd/system/phpmyadmin.service /etc/systemd/system/multi-user.target.wants/phpmyadmin.service

View File

@@ -0,0 +1,19 @@
#!/bin/bash
NewPhpMyAdminVersion=$(curl -s https://api.github.com/repos/phpmyadmin/phpmyadmin/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
if test "$NewPhpMyAdminVersion" = "$(cat /opt/phpmyadmin-installed)" ; then
echo 'PhpMyAdmin up-to-date'
exit
else
echo 'Updating PhpMyAdmin'
service phpmyadmin stop
mv /opt/PhpMyAdmin/config.inc.php /tmp/phpmyadmin.config
curl --retry 7 --retry-delay 5 -s -L https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.gz -o /tmp/phpmya.tar.gz
tar -C /opt/PhpMyAdmin -xzf /tmp/phpmya.tar.gz --strip 1
rm -rf /tmp/phpmya.tar.gz
mv /tmp/phpmyadmin.config /opt/PhpMyAdmin/config.inc.php
echo $NewPhpMyAdminVersion > /opt/phpmyadmin-installed
service phpmyadmin start
fi

View File

@@ -1,9 +1,7 @@
#!/bin/ash
. /opt/transfer.sh/Version
CurtransfershVersion=$(curl -s https://api.github.com/repos/dutchcoders/transfer.sh/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
if test "$CurtransfershVersion" = "$transfershVersion" ; then
if test "$CurtransfershVersion" = "$(cat /opt/transfer.sh/Version)" ; then
echo 'Transfer.sh up-to-date'
exit
else
@@ -13,6 +11,6 @@ else
curl -L -o /opt/transfer.sh/transfersh-linux-amd64 https://github.com/dutchcoders/transfer.sh/releases/download/"$CurtransfershVersion"/transfersh-"$CurtransfershVersion"-linux-amd64
chmod +x /opt/transfer.sh/transfersh-linux-amd64
chown transfersh:transfersh /opt/transfer.sh/transfersh-linux-amd64
echo "transfershVersion=$CurtransfershVersion" > /opt/transfer.sh/Version
echo "$CurtransfershVersion" > /opt/transfer.sh/Version
service transfersh start
fi

View File

@@ -2,6 +2,11 @@
#Goto ProjectRoot
cd "$( cd "$( dirname "$0" )" &> /dev/null && pwd )/.."
#Function Syntax/Usage
# GetResource <imageVariant> <NameDownloadedFile> <DownloadURL>
#NOTE: GetGithubRelease will set a variable with version of software as $<NameOfSoftware>Ver
# GetGithubRelease <imageVariant> <NameOfSoftware> <GithubUserName/GithubRepo> <VersionFileName>
GetResource () {
local Variant=$1
local FileName=$2
@@ -9,33 +14,40 @@ GetResource () {
echo "Getting $FileName for $Variant"
curl -L --retry 7 --retry-delay 5 "$GetAddr" -o "CT-Files/$Variant/$FileName"
}
GetGithubRelease () {
#Alternative for update script: curl -s https://api.github.com/repos/<user>/<Repo>/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " "
local Variant=$1
local SoftwareName=$2
local GithubRepo=$3
local VersionFile=$4
echo "Getting $SoftwareName version for $Variant"
local CurrentVersion=$(curl -s https://api.github.com/repos/$GithubRepo/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
export "$SoftwareName"Ver=$CurrentVersion
echo $CurrentVersion > "CT-Files/$Variant/$VersionFile"
}
GetGithubRelease mysql phpmyadmin phpmyadmin/phpmyadmin phpmyadminVersion
GetResource mysql phpmyadmin.tar.gz https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.gz
#GetResource nginx nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub
GetResource nginx acmesh.tar.gz https://codeload.github.com/acmesh-official/acme.sh/tar.gz/master
GetResource domoticz domoticz.tgz https://releases.domoticz.com/releases/release/domoticz_linux_x86_64.tgz
transfershVersion=$(curl -s https://api.github.com/repos/dutchcoders/transfer.sh/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
echo "transfershVersion=$transfershVersion" > CT-Files/transfersh/transfershVersion
GetResource transfersh transfersh-linux-amd64 https://github.com/dutchcoders/transfer.sh/releases/download/"$transfershVersion"/transfersh-"$transfershVersion"-linux-amd64
GetGithubRelease transfersh transfersh dutchcoders/transfer.sh transfershVersion
GetResource transfersh transfersh-linux-amd64 https://github.com/dutchcoders/transfer.sh/releases/download/"$transfershVer"/transfersh-"$transfershVer"-linux-amd64
GetResource transfersh CustomTheme.tar.gz https://git.bprieshof.nl/attachments/217475f6-76cd-4648-be2c-7d7098f23739
GetResource omadaV3 omada.deb https://static.tp-link.com/2020/202012/20201225/Omada_v3.2.14_linux_x64.deb
#GetResource nextcloud nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub
GetResource nextcloud nextcloud.tar.bz2 https://download.nextcloud.com/server/releases/latest.tar.bz2
GetResource aptcacherng alpine_mirrors http://dl-4.alpinelinux.org/alpine/MIRRORS.txt
curl -L --retry 7 --retry-delay 5 https://www.centos.org/download/full-mirrorlist.csv | sed 's/^.*"http:/http:/' | sed 's/".*$//' | grep ^http > CT-Files/aptcacherng/centos_mirrors
OfflineIMAPVer=$(curl -s https://api.github.com/repos/OfflineIMAP/offlineimap3/tags | grep 'name.*' |head -n 1 | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
echo "$(curl -s https://api.github.com/repos/RainLoop/rainloop-webmail/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")" > CT-Files/mailbackup/rainloop-installed
echo "$OfflineIMAPVer" > CT-Files/mailbackup/OfflineIMAP3-installed
GetResource mailbackup rlcl.zip http://www.rainloop.net/repository/webmail/rainloop-community-latest.zip
GetResource mailbackup olim3.tar.gz https://github.com/OfflineIMAP/offlineimap3/archive/refs/tags/$OfflineIMAPVer.tar.gz -o /tmp/
GetGithubRelease mailbackup elkarbackup RainLoop/rainloop-webmail rainloop-installed
GetResource mailbackup rlcl.zip http://www.rainloop.net/repository/webmail/rainloop-community-latest.zip
git clone https://git.bprieshof.nl/Tools/MailBackup-sys.git CT-Files/mailbackup/MailBackup-sys
GetResource elkarbackupDEB rsnapshot.deb http://ftp.debian.org/debian/pool/main/r/rsnapshot/rsnapshot_1.4.2-1_all.deb
elkarbackupVER="$(curl -s https://api.github.com/repos/elkarbackup/elkarbackup/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")"
echo "$elkarbackupVER" > CT-Files/elkarbackupALP/Elkarbackup-installed
GetResource elkarbackupALP elkb.tar.gz https://github.com/elkarbackup/elkarbackup/archive/refs/tags/$elkarbackupVER.tar.gz -o /tmp/
GetGithubRelease elkarbackupALP elkarbackup elkarbackup/elkarbackup Elkarbackup-installed
GetResource elkarbackupALP elkb.tar.gz https://github.com/elkarbackup/elkarbackup/archive/refs/tags/$elkarbackupVer.tar.gz -o /tmp/