Last active
January 11, 2018 18:52
-
-
Save afresh1/b46a2ed87c48a708cfca to your computer and use it in GitHub Desktop.
Command-line interface for the OpenBSD Ubiquiti [unifi port](http://ports.su/net/unifi)
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 | |
basename $0 |& | |
IFS=- read -p name cmd | |
if [ -z "$cmd" -a $# -gt 0 ]; then | |
cmd=$1 | |
shift | |
fi | |
cmd=${cmd%svc} | |
defines='' | |
#defines="-Dlog4j.debug" | |
case "$cmd" in | |
start|stop|restart|check) | |
exec /etc/rc.d/$name $cmd | |
;; | |
""|discover|info) | |
defines="$defines -Dlog4j.configuration=/dev/null" | |
;; | |
esac | |
daemon="/usr/local/share/unifi/lib/ace.jar" | |
java="$(/usr/local/bin/javaPathHelper -c unifi)" | |
# with some filehandle trickery to do substition on stderr | |
# 3>&1 - fh3 -> fh1 (stdout) | |
# 1>&2 - fh1 -> fh2 (stderr) | |
# 2>&3 - fh2 -> fh3 (stdout) | |
# 3>&- - fh3 -> close | |
(${java} ${defines} -jar ${daemon} $cmd "$@" 3>&1 1>&2 2>&3 | | |
sed -e "s,java -jar lib/ace.jar,$name," \ | |
-e "s,installsvc/.*,restart: restart the UniFi controller\\ | |
check : check status of the UniFi controller\\ | |
start/stop/restart/check : forwarded to /etc/rc.d/$name," | |
) 3>&1 1>&2 2>&3 3>&- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment