Skip to content

Instantly share code, notes, and snippets.

@shbatm
Last active October 24, 2017 12:51
Show Gist options
  • Save shbatm/7d539dc53fdc9023e4a19bda192ab70d to your computer and use it in GitHub Desktop.
Save shbatm/7d539dc53fdc9023e4a19bda192ab70d to your computer and use it in GitHub Desktop.
Setting up NodeLink as service on Raspberry Pi

NodeLink AutoStart on Raspberry Pi (Raspbian Stretch)

The scripts included in this Gist are designed to start io_guy's NodeLink.exe as a startup service on a Raspberry Pi running Rasbian Stretch.

Installation

  1. Follow the installation instructions for setting up NodeLink here.
  2. STOP when you get to "Setting up rc.local"
  3. Copy the contents of the file below to a file called installService.sh in the same folder as NodeLink.exe on your RPi:
  4. Install the systemd service by running:
    cd /path/to/NodeLink.exe  # Replace with actual folder you put NodeLink.exe and installService.sh in
    chmod +x installService.sh
    ./installService.sh
  1. You should now be able to start/stop NodeLink.exe with:
    sudo systemctl start nodelink.service
    sudo systemctl stop nodelink.service

About

Thank you to io_guy for his awesome piece of software. I am in no way affiliated with automationshack.com, but created this script for my own benefit and wanted to make it available to anyone who could make use of it.

#! /bin/bash
CWD=$(pwd)
echo "Setting up NodeLink service in $CWD..."
MONO_PATH=$(command -v mono)
if command -v mono > /dev/null 2>&1; then
echo "Mono found at: $MONO_PATH."
else
echo "ERROR: Mono not found. Aborting"
exit 1
fi
cat > $CWD/nodelink.service <<EOF
# Simple NodeLink Startup Script
#
# By shbatm (http://shbatm.com)
#
[Unit]
Description=NodeLink ISY Node Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
# Start main service
ExecStart=$CWD/startNodeLink.sh
GuessMainPID=no
StandardInput=null
Type=forking
EOF
cat > $CWD/startNodeLink.sh <<EOF
#!/bin/bash
NLPATH=$CWD/NodeLink.exe
MONOPATH=$MONO_PATH
echo \$(date +"%D %T")" Starting NodeLink.exe..."
( exec \$MONOPATH \$NLPATH > /dev/null 2>&1 ) &
exit 0
EOF
chmod +x $CWD/startNodeLink.sh
sudo systemctl enable $CWD/nodelink.service
sudo systemctl start nodelink.service
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment