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):
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/
Make the files read-only again:
chmod -R 500 /opt/InterFormNG2_Linux/
Edit the existing /etc/systemd/system/iformng2.service (with sudo) and change the version number on InterformNG2-x.y.z.jar to the new version number.
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