feat: add support for SVR.JS archives without "svr.compressed" and with "wwwroot"

This commit is contained in:
Dorian Niemiec 2025-01-05 09:32:58 +01:00
parent c3dfd2678b
commit 704b513d0b
2 changed files with 51 additions and 42 deletions

View file

@ -163,13 +163,18 @@ if [ "$SVRJSVERSION" != "" ]; then
echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
fi fi
unzip $SVRJSZIPARCHIVE -d /usr/lib/svrjs > /dev/null unzip $SVRJSZIPARCHIVE -d /usr/lib/svrjs > /dev/null
if [ -f /usr/lib/svrjs/svr.compressed ]; then
pushd . pushd .
cd /usr/lib/svrjs cd /usr/lib/svrjs
node svr.js > /dev/null node svr.js > /dev/null
popd popd
fi
ln -s /usr/lib/svrjs/log /var/log/svrjs ln -s /usr/lib/svrjs/log /var/log/svrjs
ln -s /usr/lib/svrjs/config.json /etc/svrjs-config.json ln -s /usr/lib/svrjs/config.json /etc/svrjs-config.json
node -e 'var fs=require("fs"),config=JSON.parse(fs.readFileSync("/usr/lib/svrjs/config.json").toString());config.wwwroot="/var/www/svrjs",fs.writeFileSync("/usr/lib/svrjs/config.json",JSON.stringify(config,null,2));' > /dev/null node -e 'var fs=require("fs"),config=JSON.parse(fs.readFileSync("/usr/lib/svrjs/config.json").toString());config.wwwroot="/var/www/svrjs",fs.writeFileSync("/usr/lib/svrjs/config.json",JSON.stringify(config,null,2));' > /dev/null
if [ -d /usr/lib/svrjs/wwwroot ]; then
mv /usr/lib/svrjs/wwwroot /var/www/svrjs
else
mkdir -p /var/www/svrjs mkdir -p /var/www/svrjs
mv /usr/lib/svrjs/index.html /var/www/svrjs mv /usr/lib/svrjs/index.html /var/www/svrjs
mv /usr/lib/svrjs/tests.html /var/www/svrjs mv /usr/lib/svrjs/tests.html /var/www/svrjs
@ -181,7 +186,7 @@ mv /usr/lib/svrjs/powered.png /var/www/svrjs
mv /usr/lib/svrjs/favicon.ico /var/www/svrjs 2>/dev/null mv /usr/lib/svrjs/favicon.ico /var/www/svrjs 2>/dev/null
mv /usr/lib/svrjs/views.txt /var/www/svrjs 2>/dev/null mv /usr/lib/svrjs/views.txt /var/www/svrjs 2>/dev/null
mv /usr/lib/svrjs/hviews.txt /var/www/svrjs 2>/dev/null mv /usr/lib/svrjs/hviews.txt /var/www/svrjs 2>/dev/null
cp -R /usr/lib/svrjs/.dirimages /var/www/svrjs fi
##Install SVR.JS utilities ##Install SVR.JS utilities
echo "Installing SVR.JS utilities..." echo "Installing SVR.JS utilities..."
@ -289,19 +294,21 @@ fi
##Copy SVR.JS files ##Copy SVR.JS files
echo "Copying SVR.JS files..." echo "Copying SVR.JS files..."
unzip -o $SVRJSZIPARCHIVE -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 2> /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 > /dev/null 2> /dev/null
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 > /dev/null 2> /dev/null
unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs logviewer.js loghighlight.js > /dev/null unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs logviewer.js loghighlight.js > /dev/null 2> /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 > /dev/null 2> /dev/null
chmod 775 /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js chmod 775 /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js > /dev/null 2> /dev/null
unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svrpasswd.js > /dev/null unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svrpasswd.js > /dev/null 2> /dev/null
chown svrjs:svrjs /usr/lib/svrjs/svrpasswd.js chown svrjs:svrjs /usr/lib/svrjs/svrpasswd.js > /dev/null 2> /dev/null
chmod 775 /usr/lib/svrjs/svrpasswd.js chmod 775 /usr/lib/svrjs/svrpasswd.js > /dev/null 2> /dev/null
if [ -f /usr/lib/svrjs/svr.compressed ]; then
pushd . pushd .
cd /usr/lib/svrjs cd /usr/lib/svrjs
node svr.js > /dev/null node svr.js > /dev/null
popd popd
fi
echo "Done! SVR.JS is updated successfully! You can now restart SVR.JS using \"/etc/init.d/svrjs restart\" or \"systemctl restart svrjs\"." echo "Done! SVR.JS is updated successfully! You can now restart SVR.JS using \"/etc/init.d/svrjs restart\" or \"systemctl restart svrjs\"."
EOF EOF

View file

@ -81,18 +81,20 @@ fi
##Copy SVR.JS files ##Copy SVR.JS files
echo "Copying SVR.JS files..." echo "Copying SVR.JS files..."
unzip -o $SVRJSZIPARCHIVE -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 2> /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 > /dev/null 2> /dev/null
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 > /dev/null 2> /dev/null
unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs logviewer.js loghighlight.js > /dev/null unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs logviewer.js loghighlight.js > /dev/null 2> /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 > /dev/null 2> /dev/null
chmod 775 /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js chmod 775 /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js > /dev/null 2> /dev/null
unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svrpasswd.js > /dev/null unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svrpasswd.js > /dev/null 2> /dev/null
chown svrjs:svrjs /usr/lib/svrjs/svrpasswd.js chown svrjs:svrjs /usr/lib/svrjs/svrpasswd.js > /dev/null 2> /dev/null
chmod 775 /usr/lib/svrjs/svrpasswd.js chmod 775 /usr/lib/svrjs/svrpasswd.js > /dev/null 2> /dev/null
if [ -f /usr/lib/svrjs/svr.compressed ]; then
pushd . pushd .
cd /usr/lib/svrjs cd /usr/lib/svrjs
node svr.js > /dev/null node svr.js > /dev/null
popd popd
fi
echo "Done! SVR.JS is updated successfully! You can now restart SVR.JS using \"/etc/init.d/svrjs restart\" or \"systemctl restart svrjs\"." echo "Done! SVR.JS is updated successfully! You can now restart SVR.JS using \"/etc/init.d/svrjs restart\" or \"systemctl restart svrjs\"."