====== Installing Deployments from TransSECS Servers or Devices on a Raspberry Pi ====== Complete [[BaseRaspberryPiSetupBookworm] | Raspberry Pi Base Setup]] first. These instructions apply to both **TransSECS Devices** and **TransSECS Servers**. The examples assume: /home/mix/secs If your login user is ''%%pi%%'', the equivalent location is ''%%/home/pi/secs%%''. ===== 1. Copy the TransSECS deployment to the Pi ===== The deployment normally contains ''%%run.sh%%'', one or more ''%%.jar%%'' files, ''%%log4j.xml%%'', and ''%%ErgoTechConfiguration.properties%%''. Use SFTP or SCP rather than ordinary FTP. SSH/SFTP uses port 22 and does not require a separate FTP server on the Pi. ==== Using scp ==== From a PC in the directory which contains the ''%%secs%%'' deployment folder: scp -r secs mix@192.168.1.50:/home/mix/ Replace the IP address with the Pi’s actual address. ==== Using sftp ==== sftp mix@192.168.1.50 put -r secs quit ==== Using a graphical file-transfer program ==== WinSCP or FileZilla can also be used. Choose: ^Setting ^Value ^ |Protocol|SFTP | |Host |Pi IP address or ''%%mix.local%%''| |Port |22 | |User |''%%mix%%'' | |Password|''%%ErgoErgo%%'' | Copy the complete ''%%secs%%'' folder into ''%%/home/mix%%''. ===== 2. Test the deployment manually ===== In the SSH session: cd /home/mix/secs chmod +x run.sh ./run.sh On the first start, TransSECS should report a **prelicense key**. Send this number to ErgoTech. Press **Ctrl+C** to stop the application after recording the key. If the message contains ''%%prelicense code:%%'' but no number, contact ErgoTech. The deployment may need to be rebuilt for the Raspberry Pi before it can be licensed. ==== Serial or SECS-I equipment ==== For a serial connection, the Pi’s serial library is normally under ''%%/usr/lib/jni%%''. Edit: nano run.sh Set the library path to: export LD_LIBRARY_PATH=./:../lib/:/usr/lib/jni Save with **Ctrl+O**, **Enter**, **Ctrl+X**. HSMS network connections do not require this change. ===== 3. Install the license ===== ErgoTech will provide: ErgoIOTLicense.lic Copy it into the TransSECS deployment folder: scp ErgoIOTLicense.lic mix@192.168.1.50:/home/mix/secs/ Run the deployment once more: cd /home/mix/secs ./run.sh It should start without the missing-license message. Press **Ctrl+C** to stop it. The next step configures automatic startup. ===== 4. Run TransSECS automatically as a Linux service ===== Linux uses **systemd** to manage background services. Running TransSECS as a service means it starts automatically when the Pi boots and can restart automatically if the process stops. It is also important to send Java console output to a dedicated TransSECS log. Otherwise Linux may copy repeated application messages into ''%%syslog%%'' or ''%%daemon.log%%'', which can consume a large amount of SD-card space. Create the log directory: mkdir -p /home/mix/secs/logs Create the service: sudo nano /etc/systemd/system/transsecs.service Paste: [Unit] Description=TransSECS After=network-online.target Wants=network-online.target [Service] User=mix WorkingDirectory=/home/mix/secs ExecStart=/bin/sh /home/mix/secs/run.sh Restart=always RestartSec=10 StandardOutput=append:/home/mix/secs/logs/transsecs-console.log StandardError=append:/home/mix/secs/logs/transsecs-console.log [Install] WantedBy=multi-user.target Save with **Ctrl+O**, **Enter**, **Ctrl+X**. Tell systemd about the new service, enable it for future boots, and start it now: sudo systemctl daemon-reload sudo systemctl enable transsecs sudo systemctl start transsecs sudo systemctl status transsecs Look for: active (running) Press **q** to leave the status display. Check the application console log: tail -n 20 /home/mix/secs/logs/transsecs-console.log You should see recent TransSECS startup messages. If you use ''%%tail -f%%'' instead, the command deliberately stays open and shows new messages as they arrive. Press **Ctrl+C** to return to the command prompt. ===== 5. Limit the TransSECS console log ===== Create: sudo nano /etc/logrotate.d/transsecs-console Paste: /home/mix/secs/logs/transsecs-console.log { size 5M rotate 5 compress delaycompress missingok notifempty copytruncate create 0644 mix mix } Save with **Ctrl+O**, **Enter**, **Ctrl+X**. Check the configuration safely: sudo logrotate -d /etc/logrotate.d/transsecs-console The output should mention the TransSECS console log, a 5 MB threshold, and 5 rotations. There should be no error messages. ''%%copytruncate%%'' allows logrotate to rotate the file without stopping TransSECS. ''%%SECSMessages.log%%'' is already limited by the ''%%log4j.xml%%'' supplied with the deployment and does not need another logrotate rule. ===== 6. Reboot and verify ===== sudo reboot Reconnect after about a minute and run: systemctl status transsecs tail -n 20 /home/mix/secs/logs/transsecs-console.log df -h / ls -lh /var/log Verify: * TransSECS is ''%%active (running)%%''. * The console log contains recent application messages. * The SD card has plenty of free space. * Linux logs such as ''%%syslog%%'' and ''%%daemon.log%%'' are remaining reasonably small.