Fix problems installing and updating LTS versions
[svrjs-installer-linux.git] / installer.sh
blob1852b53656a4572d9a880a8061b4db003bb76868
1 #!/bin/bash
3 ##Print splash
4 echo '**********************************'
5 echo '**SVR.JS installer for GNU/Linux**'
6 echo '**********************************'
7 echo
9 ##Check if user is root
10 if [ "$(id -u)" != "0" ]; then
11 echo 'You need to have root privileges to install SVR.JS'
12 exit 1
15 ##Determine the OS
16 OS="$(uname -s)"
17 if [ "$OS" == "Linux" ]; then
18 if [ -f /etc/redhat-release ] ; then
19 DISTRO=rhel
20 elif [ -f /etc/SuSE-release ] ; then
21 DISTRO=suse
22 elif [ -f /etc/debian_version ] ; then
23 DISTRO=debian
24 elif [ -f /etc/arch-release ] ; then
25 DISTRO=arch
26 else
27 DISTRO=other
29 elif [ "$OS" == "FreeBSD" ]; then
30 DISTRO=freebsd
31 else
32 DISTRO=other
35 ##Define depedency installation functions
36 install_nodejs() {
37 case "$DISTRO" in
38 "debian") apt install nodejs;;
39 "rhel") yum install nodejs;;
40 "suse") zypper install nodejs;;
41 "arch") pacman -S nodejs;;
42 "freebsd") pkg install node;;
43 *) echo "You need to install Node.JS manually"
44 esac
47 install_unzip() {
48 case "$DISTRO" in
49 "debian") apt install unzip;;
50 "rhel") yum install unzip;;
51 "suse") zypper install unzip;;
52 "arch") pacman -S unzip;;
53 "freebsd") pkg install unzip;;
54 *) echo "You need to install unzip manually"
55 esac
58 install_setcap() {
59 case "$DISTRO" in
60 "debian") apt install libcap2-bin;;
61 "rhel") yum install libcap;;
62 "suse") zypper install libcap-progs;;
63 "arch") pacman -S libcap;;
64 "freebsd") echo "Your OS doesn't support setcap";;
65 *) echo "You need to install setcap manually"
66 esac
69 ##Select SVR.JS installation type
70 echo 'Select your SVR.JS installation type. Valid SVR.JS installation types:'
71 echo '0 - Latest stable version'
72 echo '1 - Latest LTS version'
73 echo '2 - Install and update manually'
74 echo -n 'Your SVR.JS installation type: '
75 read ITP
76 case $ITP in
77 0) INSTALLTYPE=stable;;
78 1) INSTALLTYPE=lts;;
79 2) INSTALLTYPE=manual;;
80 *) echo 'Invalid SVR.JS installation type!'; exit 1;;
81 esac
83 if [ "$INSTALLTYPE" == "manual" ]; then
84 echo -n 'Path to SVR.JS zip archive: '
85 read SVRJSZIPARCHIVE
86 elif [ "$INSTALLTYPE" == "stable" ]; then
87 SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest.svrjs)"
88 if [ "$SVRJSVERSION" == "" ]; then
89 echo 'There was a problem while determining latest SVR.JS version!'
90 exit 1
92 SVRJSZIPARCHIVE="$(mktemp /tmp/svrjs.XXXXX.zip)"
93 if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
94 echo 'There was a problem while downloading latest SVR.JS version!'
95 exit 1
97 elif [ "$INSTALLTYPE" == "lts" ]; then
98 SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest-lts.svrjs)"
99 if [ "$SVRJSVERSION" == "" ]; then
100 echo 'There was a problem while determining latest LTS SVR.JS version!'
101 exit 1
103 SVRJSZIPARCHIVE="$(mktemp /tmp/svrjs.XXXXX.zip)"
104 if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
105 echo 'There was a problem while downloading latest LTS SVR.JS version!'
106 exit 1
108 else
109 echo 'There was a problem determining SVR.JS installation type!'
110 exit 1
113 ##Check if SVR.JS zip archive exists
114 if ! [ -f $SVRJSZIPARCHIVE ]; then
115 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".'
116 exit 1
119 ##Check if unzip is installed
120 echo "Checking for unzip..."
121 unziputil=$(whereis -b -B $(echo $PATH | sed 's|:| |g') -f unzip | awk '{ print $2}' | xargs)
122 if [ "$unziputil" == "" ]; then
123 install_unzip #Install unzip
125 unziputil=$(whereis -b -B $(echo $PATH | sed 's|:| |g') -f unzip | awk '{ print $2}' | xargs)
126 if [ "$unziputil" == "" ]; then
127 echo 'Can'"'"'t locate unzip!'
128 exit 1
131 ##Check if Node.JS is installed
132 echo "Checking for Node.JS..."
133 nodejs=$(whereis -b -B $(echo $PATH | sed 's|:| |g') -f node | awk '{ print $2}' | xargs)
134 if [ "$nodejs" == "" ]; then
135 install_nodejs #Install Node.JS
137 nodejs=$(whereis -b -B $(echo $PATH | sed 's|:| |g') -f node | awk '{ print $2}' | xargs)
138 if [ "$nodejs" == "" ]; then
139 echo 'Can'"'"'t locate Node.JS!'
140 exit 1
143 ##Check if setcap is installed
144 echo "Checking for setcap..."
145 setcapis=$(whereis -b -B $(echo $PATH | sed 's|:| |g') -f setcap | awk '{ print $2}' | xargs)
146 if [ "$setcapis" == "" ]; then
147 install_setcap #Install Node.JS
149 setcapis=$(whereis -b -B $(echo $PATH | sed 's|:| |g') -f setcap | awk '{ print $2}' | xargs)
150 if [ "$setcapis" == "" ]; then
151 echo 'Can'"'"'t locate setcap, you need to grant networking permissions manually'
152 else
153 ##Grant networking permissions to Node.JS
154 echo "Granting networking permissions..."
155 sudo setcap cap_net_bind_service=+ep $nodejs
158 ##Copy SVR.JS files
159 echo "Copying SVR.JS files..."
160 mkdir /usr/lib/svrjs
161 echo $INSTALLTYPE > /usr/lib/svrjs/.installer.prop;
162 if [ "$SVRJSVERSION" != "" ]; then
163 echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
165 unzip $SVRJSZIPARCHIVE -d /usr/lib/svrjs > /dev/null
166 pushd .
167 cd /usr/lib/svrjs
168 node svr.js > /dev/null
169 popd
170 ln -s /usr/lib/svrjs/log /var/log/svrjs
171 ln -s /usr/lib/svrjs/config.json /etc/svrjs-config.json
172 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));' > /dev/null
173 mkdir -p /var/www/svrjs
174 mv /usr/lib/svrjs/index.html /var/www/svrjs
175 mv /usr/lib/svrjs/tests.html /var/www/svrjs
176 mv /usr/lib/svrjs/licenses /var/www/svrjs
177 mv /usr/lib/svrjs/testdir /var/www/svrjs
178 mv /usr/lib/svrjs/serverSideScript.js /var/www/svrjs
179 mv /usr/lib/svrjs/logo.png /var/www/svrjs
180 mv /usr/lib/svrjs/powered.png /var/www/svrjs
181 mv /usr/lib/svrjs/favicon.ico /var/www/svrjs 2>/dev/null
182 mv /usr/lib/svrjs/views.txt /var/www/svrjs 2>/dev/null
183 mv /usr/lib/svrjs/hviews.txt /var/www/svrjs 2>/dev/null
184 cp -R /usr/lib/svrjs/.dirimages /var/www/svrjs
186 ##Install SVR.JS utilities
187 echo "Installing SVR.JS utilities..."
188 echo '#!/bin/bash' > /tmp/svrjs-utiltemplate
189 echo 'PARAMETERS=$(printf "%q " "$@")' >> /tmp/svrjs-utiltemplate
190 echo >> /tmp/svrjs-utiltemplate
191 echo 'if [ "$PARAMETERS" == "'"'""'"' " ]; then' >> /tmp/svrjs-utiltemplate
192 echo ' PARAMETERS=""' >> /tmp/svrjs-utiltemplate
193 echo 'fi' >> /tmp/svrjs-utiltemplate
194 echo >> /tmp/svrjs-utiltemplate
195 echo 'cd /usr/lib/svrjs' >> /tmp/svrjs-utiltemplate
196 cp /tmp/svrjs-utiltemplate /usr/bin/svrjs-loghighlight
197 echo 'node loghighlight.js $PARAMETERS' >> /usr/bin/svrjs-loghighlight
198 chmod a+x /usr/bin/svrjs-loghighlight
199 cp /tmp/svrjs-utiltemplate /usr/bin/svrjs-logviewer
200 echo 'node logviewer.js $PARAMETERS' >> /usr/bin/svrjs-logviewer
201 chmod a+x /usr/bin/svrjs-logviewer
202 cp /tmp/svrjs-utiltemplate /usr/bin/svrpasswd
203 echo 'node svrpasswd.js $PARAMETERS' >> /usr/bin/svrpasswd
204 chmod a+x /usr/bin/svrpasswd
205 cp /tmp/svrjs-utiltemplate /usr/bin/svrjs
206 echo 'node svr.js $PARAMETERS' >> /usr/bin/svrjs
207 chmod a+x /usr/bin/svrjs
208 cat > /usr/bin/svrjs-updater << 'EOF'
209 #!/bin/bash
211 ##Print splash
212 echo '********************************'
213 echo '**SVR.JS updater for GNU/Linux**'
214 echo '********************************'
215 echo
217 ##Check if user is root
218 if [ "$(id -u)" != "0" ]; then
219 echo 'You need to have root privileges to update SVR.JS'
220 exit 1
223 ##Check if SVR.JS is installed
224 if ! [ -d /usr/lib/svrjs ]; then
225 echo 'SVR.JS isn'"'"'t installed (or it'"'"'s installed without using SVR.JS installer)!'
226 exit 1
229 ##Create .installer.prop file, if it doesn't exist
230 if ! [ -f /usr/lib/svrjs/.installer.prop ]; then
231 echo manual > /usr/lib/svrjs/.installer.prop;
234 ##Check the SVR.JS installation type
235 INSTALLTYPE="$(cat /usr/lib/svrjs/.installer.prop)"
236 if [ "$INSTALLTYPE" == "manual" ]; then
237 echo -n 'Path to SVR.JS zip archive: '
238 read SVRJSZIPARCHIVE
239 elif [ "$INSTALLTYPE" == "stable" ]; then
240 SVRJSOLDVERSION=""
241 SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest.svrjs)"
242 if [ "$SVRJSVERSION" == "" ]; then
243 echo 'There was a problem while determining latest SVR.JS version!'
244 exit 1
246 if [ -f /usr/lib/svrjs/.installer.version ]; then
247 SVRJSOLDVERSION="$(cat /usr/lib/svrjs/.installer.version)"
249 if [ "$SVRJSOLDVERSION" == "$SVRJSVERSION" ]; then
250 echo 'Your SVR.JS version is up to date!'
251 exit 0
253 SVRJSZIPARCHIVE="$(mktemp /tmp/svrjs.XXXXX.zip)"
254 if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
255 echo 'There was a problem while downloading latest SVR.JS version!'
256 exit 1
258 echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
259 elif [ "$INSTALLTYPE" == "lts" ]; then
260 SVRJSOLDVERSION=""
261 SVRJSVERSION="$(curl -fsL https://downloads.svrjs.org/latest-lts.svrjs)"
262 if [ "$SVRJSVERSION" == "" ]; then
263 echo 'There was a problem while determining latest LTS SVR.JS version!'
264 exit 1
266 if [ -f /usr/lib/svrjs/.installer.version ]; then
267 SVRJSOLDVERSION="$(cat /usr/lib/svrjs/.installer.version)"
269 if [ "$SVRJSOLDVERSION" == "$SVRJSVERSION" ]; then
270 echo 'Your SVR.JS version is up to date!'
271 exit 0
273 SVRJSZIPARCHIVE="$(mktemp /tmp/svrjs.XXXXX.zip)"
274 if ! curl -fsSL "https://downloads.svrjs.org/svr.js.$SVRJSVERSION.zip" > $SVRJSZIPARCHIVE; then
275 echo 'There was a problem while downloading latest LTS SVR.JS version!'
276 exit 1
278 echo "$SVRJSVERSION" > /usr/lib/svrjs/.installer.version
279 else
280 echo 'There was a problem determining SVR.JS installation type!'
281 exit 1
284 ##Check if SVR.JS zip archive exists
285 if ! [ -f $SVRJSZIPARCHIVE ]; then
286 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".'
287 exit 1
290 ##Copy SVR.JS files
291 echo "Copying SVR.JS files..."
292 unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svr.compressed modules.compressed svr.js > /dev/null
293 chown svrjs:svrjs /usr/lib/svrjs/svr.compressed /usr/lib/svrjs/modules.compressed /usr/lib/svrjs/svr.js
294 chmod 775 /usr/lib/svrjs/svr.compressed /usr/lib/svrjs/modules.compressed /usr/lib/svrjs/svr.js
295 unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs logviewer.js loghighlight.js > /dev/null
296 chown svrjs:svrjs /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js
297 chmod 775 /usr/lib/svrjs/logviewer.js /usr/lib/svrjs/loghighlight.js
298 unzip -o $SVRJSZIPARCHIVE -d /usr/lib/svrjs svrpasswd.js > /dev/null
299 chown svrjs:svrjs /usr/lib/svrjs/svrpasswd.js
300 chmod 775 /usr/lib/svrjs/svrpasswd.js
301 pushd .
302 cd /usr/lib/svrjs
303 node svr.js > /dev/null
304 popd
306 echo "Done! SVR.JS is updated successfully! You can now restart SVR.JS using \"/etc/init.d/svrjs restart\" or \"systemctl restart svrjs\"."
308 chmod a+x /usr/bin/svrjs-updater
310 ##Create user for running SVR.JS and assign permissions of files
311 echo "Creating user for running SVR.JS..."
312 useradd -r -d /usr/lib/svrjs svrjs
313 echo "Assigning SVR.JS permissions..."
314 chown -hR svrjs:svrjs /usr/lib/svrjs
315 chown -hR svrjs:svrjs /var/log/svrjs
316 chown -hR svrjs:svrjs /var/www/svrjs
317 find /usr/lib/svrjs -type d -exec chmod 755 {} \;
318 find /usr/lib/svrjs -type f -exec chmod 644 {} \;
319 find /var/log/svrjs -type d -exec chmod 755 {} \;
320 find /var/log/svrjs -type f -exec chmod 644 {} \;
321 find /var/www/svrjs -type d -exec chmod 755 {} \;
322 find /var/www/svrjs -type f -exec chmod 644 {} \;
324 ##Install SVR.JS service
325 echo "Installing SVR.JS service..."
326 systemddetect=$(whereis -b -B $(echo $PATH | sed 's|:| |g') -f systemctl | awk '{ print $2}' | xargs)
327 if [ "$systemddetect" == "" ]; then
328 echo '#!/bin/bash' > /etc/init.d/svrjs
329 echo '### BEGIN INIT INFO' >> /etc/init.d/svrjs
330 echo '# Provides: svrjs' >> /etc/init.d/svrjs
331 echo '# Required-Start: $local_fs $remote_fs $network $syslog $named' >> /etc/init.d/svrjs
332 echo '# Required-Stop: $local_fs $remote_fs $network $syslog $named' >> /etc/init.d/svrjs
333 echo '# Default-Start: 2 3 4 5' >> /etc/init.d/svrjs
334 echo '# Default-Stop: 0 1 6' >> /etc/init.d/svrjs
335 echo '# X-Interactive: true' >> /etc/init.d/svrjs
336 echo '# Short-Description: SVR.JS web server' >> /etc/init.d/svrjs
337 echo '# Description: Start the web server' >> /etc/init.d/svrjs
338 echo '# This script will start the SVR.JS web server.' >> /etc/init.d/svrjs
339 echo '### END INIT INFO' >> /etc/init.d/svrjs
340 echo >> /etc/init.d/svrjs
341 echo 'server="/usr/lib/svrjs/svr.js"' >> /etc/init.d/svrjs
342 echo 'servicename="SVR.JS web server"' >> /etc/init.d/svrjs
343 echo >> /etc/init.d/svrjs
344 echo 'user="svrjs"' >> /etc/init.d/svrjs
345 echo 'nodejs=$(whereis -b -B $(echo $PATH | sed '"'"'s|:| |g'"'"') -f node | awk '"'"'{ print $2}'"'"' | xargs)' >> /etc/init.d/svrjs
346 echo >> /etc/init.d/svrjs
347 echo 'script="$(basename $0)"' >> /etc/init.d/svrjs
348 echo 'lockfile="/var/lock/$script"' >> /etc/init.d/svrjs
349 echo ' ' >> /etc/init.d/svrjs
350 echo '. /etc/rc.d/init.d/functions 2>/dev/null || . /etc/rc.status 2>/dev/null || . /lib/lsb/init-functions 2>/dev/null' >> /etc/init.d/svrjs
351 echo >> /etc/init.d/svrjs
352 echo 'ulimit -n 12000 2>/dev/null' >> /etc/init.d/svrjs
353 echo 'RETVAL=0' >> /etc/init.d/svrjs
354 echo >> /etc/init.d/svrjs
355 echo 'privilege_check()' >> /etc/init.d/svrjs
356 echo '{' >> /etc/init.d/svrjs
357 echo ' if [ "$(id -u)" != "0" ]; then' >> /etc/init.d/svrjs
358 echo ' echo '"'"'You need to have root privileges to manage SVR.JS service'"'" >> /etc/init.d/svrjs
359 echo ' exit 1' >> /etc/init.d/svrjs
360 echo ' fi' >> /etc/init.d/svrjs
361 echo '}' >> /etc/init.d/svrjs
362 echo >> /etc/init.d/svrjs
363 echo 'do_start()' >> /etc/init.d/svrjs
364 echo '{' >> /etc/init.d/svrjs
365 echo ' if [ ! -f "$lockfile" ] ; then' >> /etc/init.d/svrjs
366 echo ' echo -n $"Starting $servicename: "' >> /etc/init.d/svrjs
367 echo ' runuser -l "$user" -c "$nodejs $server > /dev/null &" && echo_success || echo_failure' >> /etc/init.d/svrjs
368 echo ' RETVAL=$?' >> /etc/init.d/svrjs
369 echo ' echo' >> /etc/init.d/svrjs
370 echo ' [ $RETVAL -eq 0 ] && touch "$lockfile"' >> /etc/init.d/svrjs
371 echo ' else' >> /etc/init.d/svrjs
372 echo ' echo "$servicename is locked."' >> /etc/init.d/svrjs
373 echo ' RETVAL=1' >> /etc/init.d/svrjs
374 echo ' fi' >> /etc/init.d/svrjs
375 echo '}' >> /etc/init.d/svrjs
376 echo >> /etc/init.d/svrjs
377 echo 'echo_failure() {' >> /etc/init.d/svrjs
378 echo ' echo -n "fail"' >> /etc/init.d/svrjs
379 echo '}' >> /etc/init.d/svrjs
380 echo >> /etc/init.d/svrjs
381 echo 'echo_success() {' >> /etc/init.d/svrjs
382 echo ' echo -n "success"' >> /etc/init.d/svrjs
383 echo '}' >> /etc/init.d/svrjs
384 echo >> /etc/init.d/svrjs
385 echo 'echo_warning() {' >> /etc/init.d/svrjs
386 echo ' echo -n "warning"' >> /etc/init.d/svrjs
387 echo '}' >> /etc/init.d/svrjs
388 echo >> /etc/init.d/svrjs
389 echo 'do_stop()' >> /etc/init.d/svrjs
390 echo '{' >> /etc/init.d/svrjs
391 echo ' echo -n $"Stopping $servicename: "' >> /etc/init.d/svrjs
392 echo ' pid=`ps -aefw | grep "$nodejs $server" | grep -v " grep " | awk '"'"'{print $2}'"'"'`' >> /etc/init.d/svrjs
393 echo ' kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure' >> /etc/init.d/svrjs
394 echo ' RETVAL=$?' >> /etc/init.d/svrjs
395 echo ' echo' >> /etc/init.d/svrjs
396 echo ' [ $RETVAL -eq 0 ] && rm -f "$lockfile"' >> /etc/init.d/svrjs
397 echo >> /etc/init.d/svrjs
398 echo ' if [ "$pid" = "" -a -f "$lockfile" ]; then' >> /etc/init.d/svrjs
399 echo ' rm -f "$lockfile"' >> /etc/init.d/svrjs
400 echo ' echo "Removed lockfile ( $lockfile )"' >> /etc/init.d/svrjs
401 echo ' fi' >> /etc/init.d/svrjs
402 echo '}' >> /etc/init.d/svrjs
403 echo >> /etc/init.d/svrjs
404 echo 'do_status()' >> /etc/init.d/svrjs
405 echo '{' >> /etc/init.d/svrjs
406 echo ' pid=`ps -aefw | grep "$nodejs $server" | grep -v " grep " | awk '"'"'{print $2}'"'"' | head -n 1`' >> /etc/init.d/svrjs
407 echo ' if [ "$pid" != "" ]; then' >> /etc/init.d/svrjs
408 echo ' echo "$servicename (pid $pid) is running..."' >> /etc/init.d/svrjs
409 echo ' else' >> /etc/init.d/svrjs
410 echo ' echo "$servicename is stopped"' >> /etc/init.d/svrjs
411 echo ' fi' >> /etc/init.d/svrjs
412 echo '}' >> /etc/init.d/svrjs
413 echo >> /etc/init.d/svrjs
414 echo 'case "$1" in' >> /etc/init.d/svrjs
415 echo ' start)' >> /etc/init.d/svrjs
416 echo ' privilege_check' >> /etc/init.d/svrjs
417 echo ' do_start' >> /etc/init.d/svrjs
418 echo ' ;;' >> /etc/init.d/svrjs
419 echo ' stop)' >> /etc/init.d/svrjs
420 echo ' privilege_check' >> /etc/init.d/svrjs
421 echo ' do_stop' >> /etc/init.d/svrjs
422 echo ' ;;' >> /etc/init.d/svrjs
423 echo ' status)' >> /etc/init.d/svrjs
424 echo ' do_status' >> /etc/init.d/svrjs
425 echo ' ;;' >> /etc/init.d/svrjs
426 echo ' restart)' >> /etc/init.d/svrjs
427 echo ' privilege_check' >> /etc/init.d/svrjs
428 echo ' do_stop' >> /etc/init.d/svrjs
429 echo ' do_start' >> /etc/init.d/svrjs
430 echo ' RETVAL=$?' >> /etc/init.d/svrjs
431 echo ' ;;' >> /etc/init.d/svrjs
432 echo ' *)' >> /etc/init.d/svrjs
433 echo ' echo "Usage: $0 {start|stop|status|restart}"' >> /etc/init.d/svrjs
434 echo ' RETVAL=1' >> /etc/init.d/svrjs
435 echo 'esac' >> /etc/init.d/svrjs
436 echo >> /etc/init.d/svrjs
437 echo 'exit $RETVAL' >> /etc/init.d/svrjs
438 chmod a+x /etc/init.d/svrjs
439 update-rc.d svrjs defaults
440 /etc/init.d/svrjs start
441 else
442 echo '[Unit]' > /etc/systemd/system/svrjs.service
443 echo 'Description=SVR.JS web server' >> /etc/systemd/system/svrjs.service
444 echo 'After=network.target' >> /etc/systemd/system/svrjs.service
445 echo >> /etc/systemd/system/svrjs.service
446 echo '[Service]' >> /etc/systemd/system/svrjs.service
447 echo 'Type=simple' >> /etc/systemd/system/svrjs.service
448 echo 'User=svrjs' >> /etc/systemd/system/svrjs.service
449 echo 'ExecStart=/usr/bin/env node /usr/lib/svrjs/svr.js' >> /etc/systemd/system/svrjs.service
450 echo 'Restart=on-failure' >> /etc/systemd/system/svrjs.service
451 echo >> /etc/systemd/system/svrjs.service
452 echo '[Install]' >> /etc/systemd/system/svrjs.service
453 echo 'WantedBy=multi-user.target' >> /etc/systemd/system/svrjs.service
454 systemctl enable svrjs
455 systemctl start svrjs
458 echo "Done! SVR.JS is installed successfully!"