Skip to content

Run on Synology NAS

BWS Systems edited this page Jul 30, 2019 · 1 revision

Instructions on how to run on the Synology NAS

  1. Install Java on NAS from package centre app
  2. Put jar file onto NAS in a folder of your choice
  3. Run JAR file from terminal using command line: nohup java -jar ha-bridge.jar &
  4. Make sure your in the folder with the ha-bridge.jar file when running the command as you may think you are but type dir to check as you may be in a folder with the same name that is virtual.

Example Start Stop Script

#!/bin/sh
PATH=$PATH:/var/packages/Java8/target/j2sdk-image/bin:/var/packages/Java8/target/j2sdk-image/jre/bin
BASEPATH=$(dirname $0)
mkdir -p $BASEPATH/data
JARFILE="ha-bridge.jar"
LOGFILE="$BASEPATH/${JARFILE}.log"
JAVA="ava8"
PIDFILE="/var/run/ha-bridge.pid"
cd $BASEPATH

start(){
	if [ "$JAVA" != "$(which java|grep -oP $JAVA)" ]; then
		echo "Java8 not found - please install first"
		exit 1
	fi
	if [ -f $JARFILE ]; then
		java -jar $JARFILE &> $LOGFILE &
		echo $! > $PIDFILE
	else
		echo "HA Bridge JAR file not found. Download from https://github.com/bwssytems/ha-bridge/releases"
		echo "Rename or link it to '$JARFILE'"
		exit 1
	fi
}
stop(){
	kill $(cat $PIDFILE)
}

case $1 in
	start)
		start
		;;
	stop)
		stop
		;;
	*)
		echo "usage: $0 {start|stop}"
		;;
esac