forked from alfiyansys/phpservermon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updater.sh
executable file
·88 lines (73 loc) · 2.21 KB
/
updater.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
#
# phpservermonitor updater
# Developed by petrk94 - https://github.com/petrk94
# Worked on by fr32k - https://github.com/fr32k
#
# 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 .......... PHPSERVERMON UPDATER ..........
# Check requirements
# unzip
if ! type -p unzip; then
echo "unzip not installed. exit"
exit 1
fi
# grep
if ! type -p grep; then
echo "grep not installed. exit"
exit 1
fi
# cURL
if ! type -p curl; then
echo "cURL not installed. exit"
exit 1
fi
# check if updater is executed from within the phpservermon directory
if [ ! -f ./updater.sh ]; then
echo STOPPED: don\'t execute the updater from another directory!
exit 1
else
echo Start updating
fi
# get latest version
version=$(curl -s https://api.github.com/repos/phpservermon/phpservermon/releases/latest | grep tag_name | cut -d ':' -f 2 | cut -d ',' -f 1 | cut -d '"' -f 2)
echo Downloading latest Version of PHPServerMonitor \($version\)
# get download URL
downloadfile=$(curl -s https://api.github.com/repos/phpservermon/phpservermon/releases/latest | grep "browser_download_url" | grep "zip\"" | cut -d ' ' -f 8 | cut -d '"' -f 2)
echo Using url $downloadfile
# download latest release
curl -sLo update.zip.keep $downloadfile
echo Save config.php
mv config.php config.php.keep
echo done!
# remove old files except config.php.keep
echo Removing old files...
find . -type f ! -iname "*.keep" -delete
rm -rf cron/ docs/ puphpet/ src/ static/
echo OK
# unzip update file
mv update.zip.keep update.zip
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*
# remove zip file
rm update.zip
# restore original config.php back from config.php.keep
mv config.php.keep config.php
# run php composer.phar install or update
if [ -d "vendor" ]; then
php composer.phar update
else
php composer.phar install
fi
echo Update finished!
echo Please finish the installation in your browser.