Ubuntu: JavaScript Processor manual install
Prerequisites
The JavaScript Processor can be installed on any Linux (and Windows) system and requires about 300 MB of physical memory.
Install Dependencies
Install haveged
sudo apt-get update
sudo apt-get install haveged
Install OpenJDK 11
Get the Java Installation Kit
wget https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz
Install OpenJDK Java 11
gunzip openjdk-11.0.1_linux-x64_bin.tar.gz
tar -xvf openjdk-11.0.1_linux-x64_bin.tar
rm openjdk-11.0.1_linux-x64_bin.tar
sudo bash
mkdir /opt/OpenJDK
mv jdk-11.0.1 /opt/OpenJDK
cd /opt/OpenJDK
ls -al
chown root -R jdk-11.0.1
chgrp root -R jdk-11.0.1
Execute the following commands (still as sudo bash):
update-alternatives --install "/usr/bin/java" "java" "/opt/OpenJDK/jdk-11.0.1/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/opt/OpenJDK/jdk-11.0.1/bin/javac" 1
update-alternatives --install "/usr/bin/keytool" "keytool" "/opt/OpenJDK/jdk-11.0.1/bin/keytool" 1
update-alternatives --install "/usr/bin/jar" "jar" "/opt/OpenJDK/jdk-11.0.1/bin/jar" 1
update-alternatives --set "java" "/opt/OpenJDK/jdk-11.0.1/bin/java"
update-alternatives --set "javac" "/opt/OpenJDK/jdk-11.0.1/bin/javac"
update-alternatives --set "keytool" "/opt/OpenJDK/jdk-11.0.1/bin/keytool"
update-alternatives --set "jar" "/opt/OpenJDK/jdk-11.0.1/bin/jar"
exit # end sudo bash
Verify the Java 11 installation.
java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
Install the JavaScript Processor
Create the DKFQS account which is running the JavaScript Processor
sudo adduser dkfqs # follow the questions, remember or write down the password
Install the JavaScript Processor
Login with the dkfqs account (SSH) - or - Enter: sudo -u dkfqs bash | OR: Install Samba to get convenient access to /home/dkfqs as Samba dkfqs user
Create the directory /home/dkfqs/javascript (as dkfqs user):
cd /home/dkfqs
mkdir javascript
Create the following sub-directories at /home/dkfqs/javascript (as dkfqs user):
- bin
- config
- internalData
- log
cd /home/dkfqs/javascript
mkdir bin config internalData log
Copy the following files to the bin directory /home/dkfqs/javascript/bin
- bcpkix-jdk15on-160.jar
- bcprov-jdk15on-160.jar
- bctls-jdk15on-160.jar
- com.dkfqs.javascriptprocessor.jar
Copy the following files to the config directory /home/dkfqs/javascript/config
- javascript-processor.properties
Modify the javascript-processor.properties file. Set the following properties:
- HttpsPort (the JavaScript Processor port)
- HttpsCertificateCN (set the public DNS name or the IP address for the automatically generated SSL/TLS server certificate)
- HttpsCertificateIP (set the public IP address for the automatically generated SSL/TLS server certificate)
- AuthTokenValue (the value of the JavaScript Processor authentication token)
- JavaScriptHTTPClientEnabled (true or false), this controls whether HTTP requests can be made from JavaScripts.
- JavaScriptStartOsProcessesEnabled (true or false), this controls whether OS processes can be started from JavaScripts. OS processes that were not started as daemons are automatically killed after the end of the stript execution (if they still exist then).
- JavaScriptStartOsProcessesAsDaemonEnabled (true or false), this controls whether OS processes can be started as daemon from JavaScripts.
Example: javascript-processor.properties
# The JavaScript processor server settings
HttpsPort=8098
HttpsCertificateCN=192.168.0.50
HttpsCertificateIP=192.168.0.50
# Authentication Token enabled for inbound IP connections: true or false
AuthTokenEnabled=true
# If AuthTokenEnabled is true, but AuthTokenValue is undefined or an empty string, then the (permanent) AuthTokenValue is automatically generated and printed at the log output
AuthTokenValue=b***********
# The JavaScript processor log level
LogLevel=info
# The internal data directory of the JavaScript processor
InternalDataDirectory=/home/dkfqs/javascript/internalData
# The default abort timeout for processing a JavaScript
JavaScriptAbortProcessingTimeoutSeconds=10
# The JavaScript processor features
JavaScriptHTTPClientEnabled=true
JavaScriptHTTPClientMaxConcurrentInstances=4
JavaScriptHTTPClientMaxStoredResponseContentSize=10000000
JavaScriptStartOsProcessesEnabled=true
JavaScriptStartOsProcessesMaxInstances=3
JavaScriptStartOsProcessesAsDaemonEnabled=true
# Network security: the IP black list block time in seconds
SecurityIpBlacklistBlockTime=300
# Network security: the max. HTTP request size
MaxHttpRequestSize=2000000
# WebSockets security settings
MaxWebSocketConnectTimeSeconds=3600
MaxInboundWebSocketTrafficPerConnection=20000000000
MaxInboundWebSocketPayloadPerFrame=10000000
MaxInboundWebSocketFramesPerIPTimeFrame=10
MaxInboundWebSocketFramesPerIPLimit=1000
# The max age in seconds for static HTML content
StaticContentMaxAgeTime=7200
Create the JavaScript Processor Startup Script (as root)
sudo bash # become root
cd /etc/init.d
vi JavaScriptProcessor
Edit - create /etc/init.d/JavaScriptProcessor
#!/bin/sh
# /etc/init.d/JavaScriptProcessor
# install with: update-rc.d JavaScriptProcessor defaults
### BEGIN INIT INFO
# Provides: JavaScriptProcessor
# Required-Start: $local_fs $network $time $syslog
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start JavaScriptProcessor at boot time
# Description: JavaScriptProcessor
### END INIT INFO
case "$1" in
start)
if [ -f /home/dkfqs/javascript/log/JavaScriptProcessor.log ]; then
mv /home/dkfqs/javascript/log/JavaScriptProcessor.log /home/dkfqs/javascript/log/JavaScriptProcessor.log_$(date +"%Y_%m_%d_%H_%M")
fi
sudo -H -u dkfqs bash -c 'CLASSPATH=/home/dkfqs/javascript/bin/bcpkix-jdk15on-160.jar:/home/dkfqs/javascript/bin/bcprov-jdk15on-160.jar:/home/dkfqs/javascript/bin/bctls-jdk15on-160.jar:/home/dkfqs/javascript/bin/com.dkfqs.javascriptprocessor.jar;export CLASSPATH;nohup java -Xmx256m -DjavaScriptProcessorProperties=/home/dkfqs/javascript/config/javascript-processor.properties -Dnashorn.args="--no-deprecation-warning" com.dkfqs.javascriptprocessor.internal.StartJavaScriptProcessor 1>/home/dkfqs/javascript/log/JavaScriptProcessor.log 2>&1 &'
;;
stop)
PID=`ps -o pid,args -e | grep "StartJavaScriptProcessor" | egrep -v grep | awk '{print $1}'`
if [ ! -z "$PID" ] ; then
echo "JavaScriptProcessor stopped with pid(s) : $PID"
kill -9 ${PID} 1> /dev/null 2>&1
fi
;;
status)
PID=`ps -o pid,args -e | grep "StartJavaScriptProcessor" | egrep -v grep | awk '{print $1}'`
if [ ! -z "$PID" ] ; then
echo "JavaScriptProcessor running with pid(s) : $PID"
else
echo "No JavaScriptProcessor running"
fi
;;
*)
echo "Usage: /etc/init.d/JavaScriptProcessor {start|stop|status}"
exit 1
;;
esac
exit 0
Change owner and file protection of /etc/init.d/JavaScriptProcessor (root at /etc/init.d):
chown root JavaScriptProcessor
chgrp root JavaScriptProcessor
chmod 755 JavaScriptProcessor
Register /etc/init.d/JavaScriptProcessor to be started at system boot (root at /etc/init.d):
update-rc.d JavaScriptProcessor defaults
Reboot the system. Login as dkfqs and check /home/dkfqs/javascript/log/JavaScriptProcessor.log
Verify the JavaScript Processor installation
- Start a Firefox web browser and connect to the JavaScript Processor at HTTPS port.
- Enter and execute a JavaScript.