Skip to content

Instantly share code, notes, and snippets.

@Code-Tap
Created January 1, 2022 18:59
Show Gist options
  • Save Code-Tap/2bc54d8d84512c4b6532150e786c7f74 to your computer and use it in GitHub Desktop.
Save Code-Tap/2bc54d8d84512c4b6532150e786c7f74 to your computer and use it in GitHub Desktop.
bash script to toggle Unifi AP led
#!/bin/sh
username=user #Replace with your admin user
password=pass #Replace with your admin pass
baseurl=https://localhost:8443 #Replace localhost with the ip or hostname of your unifi controller
site=default
cookie=/tmp/unifi_cookie
if [ $1 = true ] || [ $1 = false ]; then
curl_cmd="curl --tlsv1 --silent --cookie ${cookie} --cookie-jar ${cookie} --insecure "
${curl_cmd} --data "{'username':'$username', 'password':'$password'}" $baseurl/api/login
${curl_cmd} --data "{ 'led_enabled': $1 }" $baseurl/api/s/$site/set/setting/mgmt
else
echo "Invalid state: $1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment