The following is a suggestion on how to set up InterFormNG2 on Linux. This has been tested on Ubuntu v20 and it also runs on e.g. Red Hat Linux 8, as long it is not the headless version.
Run as a service with systemd (HTTPS version)
If not already installed, install Java runtime v8 (Ubuntu example) or Java 17 for version 3.5.0 and newer:
sudo apt install openjdk-8-jre
For optimal security, it is recommended (but not required) to create a new user that is used exclusively to run InterFormNG:
To create a new user, run these commands:
sudo useradd -m ifng
sudo passwd ifng
Enter password when prompted
sudo usermod -aG sudo ifng
Switch to the newly created user:
sudo -u ifng -s
cd ~
Alternatively, log in as an existing user.
Download the application zip file:
wget http://download.interform400.com/shares/SW/InterFormNG2_Linux.zip
Unzip to an appropriate folder, in the example /opt/InterFormNG2_Linux is used:
sudo mkdir /opt/InterFormNG2_Linux
sudo chown ifng /opt/InterFormNG2_Linux/
unzip InterFormNG2_Linux.zip -d /opt/InterFormNG2_Linux
Within the folder, move the keystore to the correct location:
cd /opt/InterFormNG2_Linux
mkdir keystore
mv interformng2.p12 keystore/
Edit the file /opt/InterFormNG2_Linux/application-default.properties and add this line:
interformng2.privateKey=<RANDOM-STRING>
Where it says <RANDOM-STRING> insert your own randomly generated string of at least 32 characters. This is used as an encryption key, so it is very important to choose a long unique value for each installation.
Note: Instead of setting this value in application-default.properties, you can also set it as an environment variable. However the use of a dot (.) in the name may cause problems.
Ensure that only the user running the application can read the files:
chmod -R 500 /opt/InterFormNG2_Linux/
Create a new file /etc/systemd/system/iformng2.service with the following content (if using a text editor, run it with sudo since this location requires root access):
[Unit]
Description=InterFormNG2
After=syslog.target
[Service]
User=ifng
Environment="INTERFORMNG2_HOME=/home/ifng/NG2Home"
WorkingDirectory=/opt/InterFormNG2_Linux
ExecStart=/bin/java -Xms256M -Xmx4096M -jar /opt/InterFormNG2_Linux/InterformNG2-1.5.1.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
Finally set it to start up automatically after a system restart, and then start the service:
sudo systemctl enable iformng2
sudo service iformng2 start
In case of startup problems, view the console log:
sudo journalctl --unit=iformng2
It should be considered what users need access to the INTERFORMNG2_HOME directory, and file permissions should be set accordingly for optimal security.
In the example, the ifng user's home folder is used for the InterFormNG home folder (/home/ifng/NG2Home). This may not be a good choice if other users are meant to be able to access this via the file system.
In the example, the maximum memory allocation for InterFormNG2 is set to 4GB via -Xmx4096M. This can be adjusted as needed.
To upgrade the Linux installation to a newer version of InterFormNG2, without touching any configuration changes made to application-default.properties or keystores, follow this procedure (this assumes that the recommended installation procedure was followed):
Log in as the user running the application (typically user ifng).
Download the latest version of InterFormNG2:
wget http://download.interform400.com/shares/SW/InterFormNG2_Linux.zip
Unzip to a temporary folder:
unzip InterFormNG2_Linux.zip -d temp/
Stop the running service:
sudo service iformng2 stop
Make the installation folder writable:
chmod -R 700 /opt/InterFormNG2_Linux/
Delete old files (only these files, do not remove other files in the folder):
rm /opt/InterFormNG2_Linux/InterformNG2-x.y.z.jar
(replace x.y.z with the OLD InterFormNG2 version)
rm -r /opt/InterFormNG2_Linux/modules
Copy the new files from the temporary folder:
cp temp/InterformNG2-X.Y.Z.jar /opt/InterFormNG2_Linux/
(replace X.Y.Z with the NEW InterFormNG2 version)
cp -r temp/modules /opt/InterFormNG2_Linux/
If you have previously added extra .jar files to the Java 8 runtime folder jre/lib/ext, then make a copy of those .jar files to a temporary folder (do not copy the ones that are there by default in Java 8, only the ones you have added).
At this point, install Java 17 runtime with the below command and follow on-screen prompt
sudo apt install openjdk-17-jre
Ensure that the Java 17 is now the default by running:
java -version
The output should be:
openjdk version 17...
Create a new folder called libext in the installation folder:
mkdir /opt/InterFormNG2_Linux/libext
If you previously copied some extra .jar files from jre/lib/ext, then copy those into this new folder libext.
Now make the files read-only again:
chmod -R 500 /opt/InterFormNG2_Linux/
Edit the existing /etc/systemd/system/iformng2.service in a text editor and change the ExecStart line to:
ExecStart=/bin/java -Xms512M -Xmx4096M -Djava.locale.providers=COMPAT,CLDR -Djava.io.tmpdir=/home/ifng/NG2Home/temp -cp /opt/InterFormNG2_Linux/InterformNG2-3.5.0.jar:/opt/InterFormNG2_Linux/libext/* org.springframework.boot.loader.JarLauncher
Note: If you have previously changed the -Xmx parameter to a different value, then make sure to preserve that value.
Start the service again:
sudo systemctl daemon-reload
sudo service iformng2 start
On the Linux setup above you can change the recommended iformng2.service description above to include temp directory with the highlighted/bold text below:
ExecStart=/bin/java -Xms256M -Xmx4096M -Djava.io.tmpdir=/home/ifng/NG2Home/temp -jar /opt/InterFormNG2_Linux/InterformNG2-1.5.1.jar