Skip to content

Instantly share code, notes, and snippets.

@jinie
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jinie/9453516 to your computer and use it in GitHub Desktop.
Save jinie/9453516 to your computer and use it in GitHub Desktop.
Startup script for UniFi Controller
#!/bin/sh
### BEGIN INIT INFO
# Provides: unifi
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the UniFi admin interface
# Description: Starts the UniFi admin interface.
### END INIT INFO
DAEMON=/usr/bin/java
DAEMON_ARGS="-jar /opt/UniFi/lib/ace.jar start"
start() {
echo "Starting unifi"
start-stop-daemon -b -o -c unifi -S -u unifi -x $DAEMON -- $DAEMON_ARGS
}
stop() {
dbpid=`pgrep -fu unifi $DAEMON`
if [ ! -z "$dbpid" ]; then
echo "Stopping unifi"
start-stop-daemon -o -c unifi -K -u unifi -x $DAEMON -- $DAEMON_ARGS
fi
}
status() {
dbpid=`pgrep -fu unifi $DAEMON`
if [ -z "$dbpid" ]; then
echo "unifi: not running."
else
echo "unifi: running (pid $dbpid)"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
stop
start
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/unifi {start|stop|reload|force-reload|restart|status}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment