Skip to content

Instantly share code, notes, and snippets.

@sjwilliams
Forked from stevejenkins/uap-reboot.sh
Created September 26, 2016 00:28
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sjwilliams/2ab579cd4d96129f73bc34e181bc9ea4 to your computer and use it in GitHub Desktop.
Save sjwilliams/2ab579cd4d96129f73bc34e181bc9ea4 to your computer and use it in GitHub Desktop.
Simple shell script to remotely reboot a Ubiquiti UBNT UniFi Access Point (UAP, UAP-PRO, UAP-AC, etc.)
#!/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
@tute123456
Copy link

thx!

@stzoran1
Copy link

Thnx... I used this to make a PHP script to execute reboot and to email me once it is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment