From 836cac06ed5e3fa48a62fb13015c20834cd051c4 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Sun, 27 Nov 2016 07:49:22 -0800 Subject: [PATCH] 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