From 90f3627f6a70442f6305bd4d7ad47acba91a11ec Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:24:41 -0800 Subject: [PATCH 01/14] Create README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..1aad8d3 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# ubnt-linux-utils +Helpful Linux / Unix scripts for admins of UBNT products + +# unifi_ssl_import.sh +Import and use SSL certificates (including Let's Encrypt) with the Ubiquiti UniFi Controller on Unix/Linux Systems + From 8751f8b75e66fe93de7861c9192ca167e62e8763 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:25:03 -0800 Subject: [PATCH 02/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1aad8d3..856b5ef 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ubnt-linux-utils -Helpful Linux / Unix scripts for admins of UBNT products +A collection of helpful Linux / Unix scripts for admins of UBNT products # unifi_ssl_import.sh Import and use SSL certificates (including Let's Encrypt) with the Ubiquiti UniFi Controller on Unix/Linux Systems From 9c5452c5b09887bf3436fb67f2c83f2859f6d0ad Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:34:11 -0800 Subject: [PATCH 03/14] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 856b5ef..7680e41 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # ubnt-linux-utils A collection of helpful Linux / Unix scripts for admins of UBNT products -# unifi_ssl_import.sh -Import and use SSL certificates (including Let's Encrypt) with the Ubiquiti UniFi Controller on Unix/Linux Systems +## unifi_ssl_import.sh +Imports SSL certificates (including Let's Encrypt) for the UBNT UniFi Controller on Linux / Unix Systems +## upgrade_unifi_controller.sh +Automates upgrade of UBNT UniFi Controller software on Linux / Unix Systems From 93852129b3de01f99c88596e3c2f30834454b7ac Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:37:05 -0800 Subject: [PATCH 04/14] Create UniFi.service --- UniFi.service | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 UniFi.service diff --git a/UniFi.service b/UniFi.service new file mode 100644 index 0000000..d0161c2 --- /dev/null +++ b/UniFi.service @@ -0,0 +1,24 @@ +# UniFi Controller systemd Service File +# by Steve Jenkins +# Last updated July 15, 2016 + +# Instructions: +# 1. Install Java, MongoDB, and UniFi Controller +# 2. Save this file as /etc/systemd/system/UniFi.service +# 3. Create 'ubnt' user on your system +# 4. Run 'systemctl enable UniFi.service' + +[Unit] +Description=Ubiquiti UniFi Controller +After=syslog.target network.target + +[Service] +ExecStart=/usr/bin/java -Xmx1024M -jar /opt/UniFi/lib/ace.jar start +ExecStop=/usr/bin/java -jar /opt/UniFi/lib/ace.jar stop +Type=simple +User=ubnt +WorkingDirectory=/opt/UniFi +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target From bf8d49ec32d4c912fdd27404c3225733a8c99e02 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:38:24 -0800 Subject: [PATCH 05/14] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7680e41..78597fb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # ubnt-linux-utils -A collection of helpful Linux / Unix scripts for admins of UBNT products +A collection of helpful Linux / Unix scripts and utilities for admins of UBNT products ## unifi_ssl_import.sh Imports SSL certificates (including Let's Encrypt) for the UBNT UniFi Controller on Linux / Unix Systems ## upgrade_unifi_controller.sh Automates upgrade of UBNT UniFi Controller software on Linux / Unix Systems + +##UniFi.service +UBNT UniFi controller service file for systemd Linux / Unix systems From 87a7ee573ca00f9b70b93456ea1e16754b720fdb Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:41:17 -0800 Subject: [PATCH 06/14] Rename UniFi.service to startup-scripts/UniFi.service --- UniFi.service => startup-scripts/UniFi.service | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename UniFi.service => startup-scripts/UniFi.service (100%) diff --git a/UniFi.service b/startup-scripts/UniFi.service similarity index 100% rename from UniFi.service rename to startup-scripts/UniFi.service From 5f34413dba4ab5725290ae2912a1a64c4c068c17 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:41:56 -0800 Subject: [PATCH 07/14] Create UniFi --- startup-scripts/UniFi | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 startup-scripts/UniFi diff --git a/startup-scripts/UniFi b/startup-scripts/UniFi new file mode 100644 index 0000000..82fe2ea --- /dev/null +++ b/startup-scripts/UniFi @@ -0,0 +1,74 @@ +#!/bin/bash +# +# UniFi Start and stop the UBNT UniFi Controller +# chkconfig: 2345 95 20 +# description: UniFi Controller +# pidfile: /var/run/UniFi.pid + +# Script by Steve Jenkins (SteveJenkins.com) +# Last Updated June 15, 2016 + +. /etc/rc.d/init.d/functions + +SERVICE_NAME="UniFi Controller" +PATH_TO_JAVA=/usr/bin/java +PATH_TO_JAR=/opt/UniFi/lib/ace.jar +MEM_LIMIT=1024M +PID_FILE=/var/run/UniFi.pid + +start() { + if [ ! -f $PID_FILE ]; then + echo -n "Starting $SERVICE_NAME: " + $PATH_TO_JAVA -Xmx$MEM_LIMIT -jar $PATH_TO_JAR start &> /dev/null & + echo $! > $PID_FILE + echo_success + echo + else + echo -n "$SERVICE_NAME is already running" + echo_failure + echo + fi +} + +stop() { + if [ -f $PID_FILE ]; then + PID=$(cat $PID_FILE); + echo -n "Stopping $SERVICE_NAME: " + $PATH_TO_JAVA -jar $PATH_TO_JAR stop &> /dev/null & + rm $PID_FILE + echo_success + echo + else + echo -n "$SERVICE_NAME is not running" + echo_failure + echo + fi +} + +case $1 in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + if [ -f $PID_FILE ]; then + PID=$(cat $PID_FILE); + echo "$SERVICE_NAME running as process $PID" + else + echo "$SERVICE_NAME is not running" + fi + ;; +*) + +echo "usage: service UniFi {start|stop|restart|status}" +exit 1 +;; + +esac +exit 0 From 0e2378336414461d5b908134d884d59109abd597 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:43:18 -0800 Subject: [PATCH 08/14] Create README.md --- startup-scripts/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 startup-scripts/README.md diff --git a/startup-scripts/README.md b/startup-scripts/README.md new file mode 100644 index 0000000..02c29d0 --- /dev/null +++ b/startup-scripts/README.md @@ -0,0 +1,5 @@ +# UBNT Linux / Unix Startup Scripts + +## UniFi.service + +## UniFi From 61847d51810d8453a2bf9d75176ad5a0e61b9795 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:44:05 -0800 Subject: [PATCH 09/14] Delete README.md --- startup-scripts/README.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 startup-scripts/README.md diff --git a/startup-scripts/README.md b/startup-scripts/README.md deleted file mode 100644 index 02c29d0..0000000 --- a/startup-scripts/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# UBNT Linux / Unix Startup Scripts - -## UniFi.service - -## UniFi From 2632fe76d8ff6e79a89948b9dc7cc3209842a0bc Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:45:00 -0800 Subject: [PATCH 10/14] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 78597fb..af23194 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,8 @@ Imports SSL certificates (including Let's Encrypt) for the UBNT UniFi Controller ## upgrade_unifi_controller.sh Automates upgrade of UBNT UniFi Controller software on Linux / Unix Systems -##UniFi.service +##/startup-scripts/UniFi.service UBNT UniFi controller service file for systemd Linux / Unix systems + +##/startup-scripts/UniFi +UBNT UniFi controller service file for SysV Linux / Unix systems From 629db4608dd8ffd916cc319f92e9c75f324e537b Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:45:34 -0800 Subject: [PATCH 11/14] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index af23194..c7ba674 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ Imports SSL certificates (including Let's Encrypt) for the UBNT UniFi Controller ## upgrade_unifi_controller.sh Automates upgrade of UBNT UniFi Controller software on Linux / Unix Systems -##/startup-scripts/UniFi.service +## UniFi Controller Startup Scripts +###/startup-scripts/UniFi.service UBNT UniFi controller service file for systemd Linux / Unix systems -##/startup-scripts/UniFi +###/startup-scripts/UniFi UBNT UniFi controller service file for SysV Linux / Unix systems From 836cac06ed5e3fa48a62fb13015c20834cd051c4 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:49:22 -0800 Subject: [PATCH 12/14] Create uap-reboot.sh --- uap-reboot.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 uap-reboot.sh diff --git a/uap-reboot.sh b/uap-reboot.sh new file mode 100644 index 0000000..62b7e46 --- /dev/null +++ b/uap-reboot.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# A simple script for remotely rebooting a Ubiquiti UniFi access point +# Version 1.0 (Dec 15, 2015) +# by Steve Jenkins (http://www.stevejenkins.com/) + +# Requires sshpass (https://sourceforge.net/projects/sshpass/) which +# is probably available via dnf, yum, or apt on your *nix distro. + +# USAGE +# Update the user-configurable settings below, then run ./uap-reboot.sh from +# the command line. To reboot on a schedule, create a cronjob such as: +# 45 3 * * * /usr/local/bin/uap-reboot.sh > /dev/null 2>&1 #Reboot UniFi AP +# The above example will reboot the UniFi access point every morning at 3:45 AM. + +# USER-CONFIGURABLE SETTINGS +username=ubnt +password=ubnt +known_hosts_file=/dev/null +uap_ip=192.168.1.11 + +# SHOULDN'T NEED TO CHANGE ANYTHING PAST HERE +echo "Rebooting UniFi access point at $uap_ip..." + +if sshpass -p $password ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=$known_hosts_file $username@$uap_ip reboot; then + echo "Reboot complete!" 1>&2 + exit 0 +else + echo "Could not reboot UniFi access point. Please check your settings." 1>&2 + exit 1 +fi From 65b43d1452b581eb111c6587b248b7c1d4aa36db Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:50:49 -0800 Subject: [PATCH 13/14] Update README.md --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c7ba674..263c4bd 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,18 @@ -# ubnt-linux-utils -A collection of helpful Linux / Unix scripts and utilities for admins of UBNT products +# unifi-linux-utils +A collection of helpful Linux / Unix scripts and utilities for admins of UBNT UniFi products + +## uap-reboot.sh +Remotely reboots a Ubiquiti (UBNT) UniFi access point ## unifi_ssl_import.sh -Imports SSL certificates (including Let's Encrypt) for the UBNT UniFi Controller on Linux / Unix Systems +Imports SSL certificates (including Let's Encrypt) for the Ubiquiti (UBNT) UniFi Controller on Linux / Unix Systems ## upgrade_unifi_controller.sh -Automates upgrade of UBNT UniFi Controller software on Linux / Unix Systems +Automates upgrade of Ubiquiti (UBNT) UniFi Controller software on Linux / Unix Systems ## UniFi Controller Startup Scripts ###/startup-scripts/UniFi.service -UBNT UniFi controller service file for systemd Linux / Unix systems +Ubiquiti (UBNT) UniFi controller service file for systemd Linux / Unix systems ###/startup-scripts/UniFi -UBNT UniFi controller service file for SysV Linux / Unix systems +Ubiquiti (UBNT) UniFi controller service file for SysV Linux / Unix systems From e963ec3f8a079d027481769b1cabbd7868ddc529 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:51:04 -0800 Subject: [PATCH 14/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 263c4bd..4975453 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # unifi-linux-utils -A collection of helpful Linux / Unix scripts and utilities for admins of UBNT UniFi products +A collection of helpful Linux / Unix scripts and utilities for admins of Ubiquiti (UBNT) UniFi products ## uap-reboot.sh Remotely reboots a Ubiquiti (UBNT) UniFi access point