4 echo '********************************'
5 echo '**SVR.JS updater for GNU/Linux**'
6 echo '********************************'
9 ##Check if user is root
10 if [ "$(id -u)" != "0" ]; then
11 echo 'You need to have root privileges to update SVR.JS'
15 ##Check if SVR.JS is installed
16 if ! [ -d /usr
/lib
/svrjs
]; then
17 echo 'SVR.JS isn'"'"'t installed (or it'"'"'s installed without using SVR.JS installer)!'
21 ##Create .installer.prop file, if it doesn't exist
22 if ! [ -f /usr
/lib
/svrjs
/.installer.prop
]; then
23 echo manual
> /usr
/lib
/svrjs
/.installer.prop
;
26 ##Check the SVR.JS installation type
27 INSTALLTYPE
="$(cat /usr/lib/svrjs/.installer.prop)"
28 if [ "$INSTALLTYPE" == "manual" ]; then
29 echo -n 'Path to SVR.JS zip archive: '
31 elif [ "$INSTALLTYPE" == "stable" ]; then
33 SVRJSVERSION
="$(curl -fsL https://downloads.svrjs.org/latest.svrjs)"
34 if [ "$SVRJSVERSION" == "" ]; then
35 echo 'There was a problem while determining latest SVR.JS version!'
38 if [ -f /usr
/lib
/svrjs
/.installer.version
]; then
39 SVRJSOLDVERSION
="$(cat /usr/lib/svrjs/.installer.version)"
41 if [ "$SVRJSOLDVERSION" == "$SVRJSVERSION" ]; then
42 echo 'Your SVR.JS version is up to date!'
45 SVRJSZIPARCHIVE
="$(mktemp /tmp/svrjs.XXXXX.zip)"
46 if ! curl
-fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
47 echo 'There was a problem while downloading latest SVR.JS version!'
50 echo "$SVRJSVERSION" > /usr
/lib
/svrjs
/.installer.version
51 elif [ "$INSTALLTYPE" == "lts" ]; then
53 SVRJSVERSION
="$(curl -fsL https://downloads.svrjs.org/latest-lts.svrjs)"
54 if [ "$SVRJSVERSION" == "" ]; then
55 echo 'There was a problem while determining latest LTS SVR.JS version!'
58 if [ -f /usr
/lib
/svrjs
/.installer.version
]; then
59 SVRJSOLDVERSION
="$(cat /usr/lib/svrjs/.installer.version)"
61 if [ "$SVRJSOLDVERSION" == "$SVRJSVERSION" ]; then
62 echo 'Your SVR.JS version is up to date!'
65 SVRJSZIPARCHIVE
="$(mktemp /tmp/svrjs.XXXXX.zip)"
66 if ! curl
-fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
67 echo 'There was a problem while downloading latest LTS SVR.JS version!'
70 echo "$SVRJSVERSION" > /usr
/lib
/svrjs
/.installer.version
72 echo 'There was a problem determining SVR.JS installation type!'
76 ##Check if SVR.JS zip archive exists
77 if ! [ -f $SVRJSZIPARCHIVE ]; then
78 echo 'Can'"'"'t find SVR.JS archive! Make sure to download SVR.JS archive file from https://svrjs.org and rename it to "svrjs.zip".'
83 echo "Copying SVR.JS files..."
84 unzip -o $SVRJSZIPARCHIVE -d /usr
/lib
/svrjs svr.compressed modules.compressed svr.js
> /dev
/null
2> /dev
/null
85 chown svrjs
:svrjs
/usr
/lib
/svrjs
/svr.compressed
/usr
/lib
/svrjs
/modules.compressed
/usr
/lib
/svrjs
/svr.js
> /dev
/null
2> /dev
/null
86 chmod 775 /usr
/lib
/svrjs
/svr.compressed
/usr
/lib
/svrjs
/modules.compressed
/usr
/lib
/svrjs
/svr.js
> /dev
/null
2> /dev
/null
87 unzip -o $SVRJSZIPARCHIVE -d /usr
/lib
/svrjs logviewer.js loghighlight.js
> /dev
/null
2> /dev
/null
88 chown svrjs
:svrjs
/usr
/lib
/svrjs
/logviewer.js
/usr
/lib
/svrjs
/loghighlight.js
> /dev
/null
2> /dev
/null
89 chmod 775 /usr
/lib
/svrjs
/logviewer.js
/usr
/lib
/svrjs
/loghighlight.js
> /dev
/null
2> /dev
/null
90 unzip -o $SVRJSZIPARCHIVE -d /usr
/lib
/svrjs svrpasswd.js
> /dev
/null
2> /dev
/null
91 chown svrjs
:svrjs
/usr
/lib
/svrjs
/svrpasswd.js
> /dev
/null
2> /dev
/null
92 chmod 775 /usr
/lib
/svrjs
/svrpasswd.js
> /dev
/null
2> /dev
/null
93 if [ -f /usr
/lib
/svrjs
/svr.compressed
]; then
96 node svr.js
> /dev
/null
100 echo "Done! SVR.JS is updated successfully! You can now restart SVR.JS using \"/etc/init.d/svrjs restart\" or \"systemctl restart svrjs\"."