Add support for downloading the latest version from SVR.JS download servers

This commit is contained in:
Dorian Niemiec 2024-04-05 15:30:55 +02:00
parent be00d96e13
commit 604c42ee33
2 changed files with 119 additions and 19 deletions

View file

@ -1,8 +1,5 @@
#!/bin/bash #!/bin/bash
##Determine installer directory
installerroot=$(dirname $0)
##Print splash ##Print splash
echo '**********************************' echo '**********************************'
echo '**SVR.JS installer for GNU/Linux**' echo '**SVR.JS installer for GNU/Linux**'
@ -69,9 +66,60 @@ install_setcap() {
esac esac
} }
##Check if svrjs.zip exists ##Select SVR.JS installation type
if ! [ -f $installerroot/svrjs.zip ]; then echo 'Select your SVR.JS installation type. Valid SVR.JS installation types:'
echo 'Can'"'"'t find SVR.JS archive in "svrjs.zip"! Make sure to download SVR.JS archive file from https://svrjs.org and rename it to "svrjs.zip".' echo '0 - Latest stable version'
echo '1 - Latest LTS version'
echo '2 - Install and update manually'
echo -n 'Your SVR.JS installation type: '
read ITP
case $ITP in
0) INSTALLTYPE=stable;;
1) INSTALLTYPE=lts;;
2) INSTALLTYPE=manual;;
*) echo 'Invalid SVR.JS installation type!'; exit 1;;
esac
##Create .installer.prop file
echo $INSTALLTYPE > /usr/lib/svrjs/.installer.prop;
##Check the SVR.JS installation type
INSTALLTYPE="$(cat /usr/lib/svrjs/.installer.prop)"
if [ "$INSTALLTYPE" == "manual" ]; then
echo -n 'Path to SVR.JS zip archive: '
read SVRJSZIPARCHIVE
elif [ "$INSTALLTYPE" == "stable" ]; then
SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest.svrjs)"
if [ "$SVRJSVERSION" == "" ]; then
echo 'There was a problem while determining latest SVR.JS version!'
exit 1
fi
SVRJSZIPARCHIVE="$(mktemp /tmp/svrjs.XXXXX.zip)"
if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
echo 'There was a problem while downloading latest SVR.JS version!'
exit 1
fi
echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
elif [ "$INSTALLTYPE" == "lts" ]; then
SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest-lts.svrjs)"
if [ "$SVRJSVERSION" == "" ]; then
echo 'There was a problem while determining latest LTS SVR.JS version!'
exit 1
fi
SVRJSZIPARCHIVE="$(mktemp -d /tmp/svrjs.XXXXX.zip)"
if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
echo 'There was a problem while downloading latest LTS SVR.JS version!'
exit 1
fi
echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
else
echo 'There was a problem determining SVR.JS installation type!'
exit 1
fi
##Check if SVR.JS zip archive exists
if ! [ -f $SVRJSZIPARCHIVE ]; then
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".'
exit 1 exit 1
fi fi
@ -117,7 +165,7 @@ fi
##Copy SVR.JS files ##Copy SVR.JS files
echo "Copying SVR.JS files..." echo "Copying SVR.JS files..."
mkdir /usr/lib/svrjs mkdir /usr/lib/svrjs
unzip $installerroot/svrjs.zip -d /usr/lib/svrjs > /dev/null unzip $SVRJSZIPARCHIVE -d /usr/lib/svrjs > /dev/null
pushd . pushd .
cd /usr/lib/svrjs cd /usr/lib/svrjs
node svr.js > /dev/null node svr.js > /dev/null

View file

@ -1,8 +1,5 @@
#!/bin/bash #!/bin/bash
##Determine installer directory
installerroot=$(dirname $0)
##Print splash ##Print splash
echo '********************************' echo '********************************'
echo '**SVR.JS updater for GNU/Linux**' echo '**SVR.JS updater for GNU/Linux**'
@ -15,27 +12,82 @@ if [ "$(id -u)" != "0" ]; then
exit 1 exit 1
fi fi
##Check if svrjs.zip exists
if ! [ -f $installerroot/svrjs.zip ]; then
echo 'Can'"'"'t find SVR.JS archive in "svrjs.zip"! Make sure to download SVR.JS archive file from https://svrjs.org and rename it to "svrjs.zip".'
exit 1
fi
##Check if SVR.JS is installed ##Check if SVR.JS is installed
if ! [ -d /usr/lib/svrjs ]; then if ! [ -d /usr/lib/svrjs ]; then
echo 'SVR.JS isn'"'"'t installed (or it'"'"'s installed without using SVR.JS installer)!' echo 'SVR.JS isn'"'"'t installed (or it'"'"'s installed without using SVR.JS installer)!'
exit 1 exit 1
fi fi
##Create .installer.prop file, if it doesn't exist
if ! [ -f /usr/lib/svrjs/.installer.prop ]; then
echo manual > /usr/lib/svrjs/.installer.prop;
fi
##Check the SVR.JS installation type
INSTALLTYPE="$(cat /usr/lib/svrjs/.installer.prop)"
if [ "$INSTALLTYPE" == "manual" ]; then
echo -n 'Path to SVR.JS zip archive: '
read SVRJSZIPARCHIVE
elif [ "$INSTALLTYPE" == "stable" ]; then
SVRJSOLDVERSION=""
SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest.svrjs)"
if [ "$SVRJSVERSION" == "" ]; then
echo 'There was a problem while determining latest SVR.JS version!'
exit 1
fi
if [ -f /usr/lib/svrjs/.installer.version ]; then
SVRJSOLDVERSION="$(cat /usr/lib/svrjs/.installer.version)"
fi
if [ "$SVRJSOLDVERSION" == "$SVRJSVERSION" ]; then
echo 'Your SVR.JS version is up to date!'
exit 0
fi
SVRJSZIPARCHIVE="$(mktemp /tmp/svrjs.XXXXX.zip)"
if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
echo 'There was a problem while downloading latest SVR.JS version!'
exit 1
fi
echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
elif [ "$INSTALLTYPE" == "lts" ]; then
SVRJSOLDVERSION=""
SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest-lts.svrjs)"
if [ "$SVRJSVERSION" == "" ]; then
echo 'There was a problem while determining latest LTS SVR.JS version!'
exit 1
fi
if [ -f /usr/lib/svrjs/.installer.version ]; then
SVRJSOLDVERSION="$(cat /usr/lib/svrjs/.installer.version)"
fi
if [ "$SVRJSOLDVERSION" == "$SVRJSVERSION" ]; then
echo 'Your SVR.JS version is up to date!'
exit 0
fi
SVRJSZIPARCHIVE="$(mktemp -d /tmp/svrjs.XXXXX.zip)"
if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
echo 'There was a problem while downloading latest LTS SVR.JS version!'
exit 1
fi
echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
else
echo 'There was a problem determining SVR.JS installation type!'
exit 1
fi
##Check if SVR.JS zip archive exists
if ! [ -f $SVRJSZIPARCHIVE ]; then
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".'
exit 1
fi
##Copy SVR.JS files ##Copy SVR.JS files
echo "Copying SVR.JS files..." echo "Copying SVR.JS files..."
unzip -o svrjs.zip -d /usr/lib/svrjs svr.compressed modules.compressed svr.js > /dev/null unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svr.compressed modules.compressed svr.js > /dev/null
chown svrjs:svrjs /usr/lib/svrjs/svr.compressed /usr/lib/svrjs/modules.compressed /usr/lib/svrjs/svr.js chown svrjs:svrjs /usr/lib/svrjs/svr.compressed /usr/lib/svrjs/modules.compressed /usr/lib/svrjs/svr.js
chmod 775 /usr/lib/svrjs/svr.compressed /usr/lib/svrjs/modules.compressed /usr/lib/svrjs/svr.js chmod 775 /usr/lib/svrjs/svr.compressed /usr/lib/svrjs/modules.compressed /usr/lib/svrjs/svr.js
unzip -o svrjs.zip -d /usr/lib/svrjs logviewer.js loghighlight.js > /dev/null unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs logviewer.js loghighlight.js > /dev/null
chown svrjs:svrjs /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js chown svrjs:svrjs /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js
chmod 775 /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js chmod 775 /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js
unzip -o svrjs.zip -d /usr/lib/svrjs svrpasswd.js > /dev/null unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svrpasswd.js > /dev/null
chown svrjs:svrjs /usr/lib/svrjs/svrpasswd.js chown svrjs:svrjs /usr/lib/svrjs/svrpasswd.js
chmod 775 /usr/lib/svrjs/svrpasswd.js chmod 775 /usr/lib/svrjs/svrpasswd.js
pushd . pushd .