Last active
August 29, 2015 13:57
-
-
Save jinie/9453516 to your computer and use it in GitHub Desktop.
Startup script for UniFi Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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