Install pre-compiled binaries on Nodegrid OS
From time to time, customers have the requirement to expand Nodegrid OS build-in capabilities. Customers have two options to archive this goal.
- Run the additional software in a hypervisor environment, either docker (Recommended) or full VM
- Install pre-compiled linux binaries; this is only supported in some instances as Nodegrid does not offer a Linux package manager, and the software which should be installed must be fully self-contained.
Examples that can be installed through this method are:
- Splunk agent
- Influx DB kapacitor daemon
- docker-compose
Note: The recommended method to install additional software on a Nodegrid appliance is through the use of
docker
containers. This capability is available on all appliances.
This guide covers at a high level how customers can install and run pre-compiled Linux application on Nodegrid appliances and answer some of the most common questions. Nodegrid OS implements it's own Linux library which is related on the Debian LTS versions. Applications which are designed for Debian/Ubuntu distributions and dont require external dependencies maybe able to run on Nodegrid OS.
Depending on the use case, customers can install software binaries as part of a specific user or for global installation as root user. However, this guide assumes the packages will be installed by the default admin account as root user.
The following table outlines the most common details, which are
Setting | Value | Commands | Comments |
---|---|---|---|
install root directory | /var/opt/ | ||
install directory | /var/opt/<PACKAGE> | mkdir /var/opt/<PACKAGE> |
|
start at boot up | init.d script | vi /etc/init.d/<SERVICENAME> |
see below for example script and setup |
system path | create symlink | ln -s /var/opt/<PACKAGE> /usr/bin/<PACKAGE> |
see below for example script and setup |
Create init.d start-up script
- create an init.d start/stop script with
vi /etc/init.d/<SERVICENAME>
- File content, adjust the required sections
#!/bin/bash
### BEGIN INIT INFO
# Provides: myservice
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 5
# Default-Stop: 0 1 6
# Short-Description: My Service
# Description: This is an example init.d script for My Service.
# Update the section start()/stop()/status() as needed
### END INIT INFO
# Path to the service executable
SERVICE_PATH="/var/opt/<PACKAGE>"
SERVICE_NAME="My Service"
# Command to start the service
start() {
if [ -f "$SERVICE_PATH" ]; then
echo "Starting $SERVICE_NAME..."
"$SERVICE_PATH" > /dev/null 2>&1 &
else
echo "Service executable not found: $SERVICE_PATH"
fi
}
# Command to stop the service
stop() {
echo "Stopping $SERVICE_NAME..."
pkill -f "$SERVICE_PATH"
}
# Command to check the status of the service
status() {
if pgrep -f "$SERVICE_PATH" >/dev/null; then
echo "$SERVICE_NAME is running."
else
echo "$SERVICE_NAME is not running."
fi
}
# Handle command-line arguments
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Adding init.d start/stop/status script to system start-up
update-rc.d <SERVICENAME> defaults
Updating the users PATH variable to include the new application.
This must be executed for each user who requires access to the application. Update the setting <PACKAGE> as needed
new_path="/var/opt/<PACKAGE>"
if [[ ":$PATH:" == *":$new_path:"* ]]; then
echo "The new path is already in the PATH variable."
else
echo "export PATH=\"$new_path:\$PATH\"" >> ~/.bashrc
export PATH="$new_path:$PATH"
echo "The PATH variable has been updated."
fi