Skip to content

Instantly share code, notes, and snippets.

View erikankrom's full-sized avatar

Erik Ankrom erikankrom

  • Amazon Web Services
  • Olathe, KS
  • 16:54 (UTC -05:00)
View GitHub Profile
@erikankrom
erikankrom / README.md
Last active June 1, 2020 13:09 — forked from 0x1b-xyz/eap_proxy-udmpro-health.sh
A script that manages the lifecycle of the eap_proxy-udmpro container on a UDM PRO between reboots or firmware updates. See https://github.com/pbrah/eap_proxy-udmpro for the upstream image.

This script is meant to be run from a secure host where you don't mind having your UDM root ssh password stored as cleartext. The script will build an image (lazily) on this secure host that contains an expect script that logs in to your UDM Pro and start (as needed) the pbrah/eap_proxy-udmpro:v1.1 image.

Env Default Desc
TARGET_HOST unifi UDM Pro IP or hostname
PASSWORD_FILE Required Clear text UDM Pro root password file
LOCAL_IMAGE_NAME eap_proxy-healthcheck Name of the image that is built on your secure host and executes the container with expect script against the UDM
UDM_CONTAINER_NAME eap_proxy-udmpro Name of the eap_proxy container that should be running on the UDM
EAP_PROXY_IMAGE pbrah/eap_proxy-udmpro:v1.1 Desired eap_proxy-udmpro Image
#!/bin/bash
NAME="unifi.example.com"
/usr/bin/letsencrypt renew
if test $(find /etc/letsencrypt/live/$NAME/cert.pem -mmin -60)
then
/bin/systemctl stop unifi.service
/usr/bin/openssl pkcs12 -export -inkey /etc/letsencrypt/live/$NAME/privkey.pem -in /etc/letsencrypt/live/$NAME/fullchain.pem -out /tmp/$NAME.p12 -name ubnt -password pass:temppass
/bin/keytool -importkeystore -deststorepass aircontrolenterprise -destkeypass aircontrolenterprise -destkeystore /opt/UniFi/data/keystore -srckeystore /tmp/$NAME.p12 -srcstoretype PKCS12 -srcstorepass temppass -alias ubnt -noprompt