From 67a8a72779172611a82f1ade36fd8f0a1f414873 Mon Sep 17 00:00:00 2001 From: petrk94 Date: Wed, 15 Aug 2018 17:24:53 +0200 Subject: [PATCH] added updater.sh shell script --- updater.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 updater.sh diff --git a/updater.sh b/updater.sh new file mode 100644 index 00000000..d084b4c0 --- /dev/null +++ b/updater.sh @@ -0,0 +1,48 @@ +#phpservermonitor updater +# Developed by petrk94 - https://github.com/petrk94 +# +# requirements +# PHP +# cURL +# grep +# unzip +# +# used code: +# cURL github API url: https://stackoverflow.com/questions/24987542/is-there-a-link-to-github-for-downloading-a-file-in-the-latest-release-of-a-repo + +echo Save config.php +mv config.php config.php.keep +echo done! + +# remove old files except config.php.keep +echo remove old files +find . -type f ! -iname "*.keep" -delete +rm -rf cron/ docs/ puphpet/ src/ static/ + +echo Download latest Version of PHPServerMonitor +echo latest Version is: +curl -s https://api.github.com/repos/phpservermon/phpservermon/releases/latest | grep browser_download_url | cut -d '/' -f 8 + + +#Set if question whether ready to proceed update +echo Do you want download the update and install? Y/N + +#extract url from latest zip file to download +downloadfile=$(curl -s https://api.github.com/repos/phpservermon/phpservermon/releases/latest | grep "zipball" | cut -d '"' -f 4) + +#download latest version zip file and save it with wget as update.zip +wget -O update.zip "$downloadfile" +unzip update.zip + +# move all files and directories from new created phpservermon directory, to the directory above with the native phpservermon installation +mv phpservermon*/* . +# remove phpservermon directory +rm -rf phpservermon* +# restore original config.php back from config.php.keep +mv config.php.keep config.php + +# run php composer.phar install +php composer.phar install + +echo Update finished! +echo Please check the installation \ No newline at end of file