Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Last active November 24, 2025 03:46
Show Gist options
  • Select an option

  • Save dieseltravis/3071cc8950af60c2419a315b3f6420bd to your computer and use it in GitHub Desktop.

Select an option

Save dieseltravis/3071cc8950af60c2419a315b3f6420bd to your computer and use it in GitHub Desktop.
omg.lol letsencrypt certbot scripts
sudo apt install certbot
mkdir -p {.secrets,.config/letsencrypt}
sudo chmod -R 0700 {.secrets,.config/letsencrypt}
sudo chown pi:pi ~/.config/letsencrypt
#https://home.omg.lol/address/travis/dns/#dns-form
#https://toolbox.googleapps.com/apps/dig/#TXT/
#!/bin/bash
set -euo pipefail
#omg config
OMG_ADDRESS="travis"
OMG_EMAIL="[email protected]"
OMG_DNS="smartmirror2024"
OMG_DOMAIN="$OMG_DNS.$OMG_ADDRESS.omg.lol"
# magicmirror specific
CERT_USER="pi"
CERT_PATH="/home/$CERT_USER/.config/letsencrypt"
CERT_SOURCE="$CERT_PATH/live/$OMG_DOMAIN"
CERT_DEST_FILE="/etc/ssl/snakeoil.pem"
# https://eff-certbot.readthedocs.io/en/stable/using.html#certbot-command-line-options
certbot certonly -d $OMG_DOMAIN --config-dir $CERT_PATH --work-dir $CERT_PATH --logs-dir $CERT_PATH --email $OMG_EMAIL --agree-tos --no-eff-email --preferred-challenges dns --manual
# follow instructions to update the TXT record for "_acme-challenge.$OMG_DOMAIN"
# TODO: update the TXT via the omg API
# https://api.omg.lol/#token-patch-dns-edit-an-existing-dns-record
# restart magicmirror?
#sudo systemctl restart mmpm.service
#!/bin/bash
set -euo pipefail
#omg config
OMG_ADDRESS="travis"
OMG_EMAIL="[email protected]"
OMG_DNS="mealie"
OMG_DOMAIN="$OMG_DNS.$OMG_ADDRESS.omg.lol"
# alpine specific
CERT_USER="root"
CERT_PATH="~/.config/letsencrypt"
CERT_SOURCE="$CERT_PATH/live/$OMG_DOMAIN"
CERT_DEST_FILE="/etc/ssl/$OMG_DNS.pem"
certbot certonly -d $OMG_DOMAIN --config-dir $CERT_PATH --work-dir $CERT_PATH --logs-dir $CERT_PATH --email $OMG_EMAIL --agree-tos --no-eff-email --preferred-challenges dns --manual
cat "$CERT_SOURCE/cert.pem" > "$CERT_SOURCE/combined.pem"
cat "$CERT_SOURCE/privkey.pem" >> "$CERT_SOURCE/combined.pem"
cp "$CERT_SOURCE/combined.pem" $CERT_DEST_FILE
chown $CERT_USER:$CERT_USER $CERT_DEST_FILE
chmod 0700 $CERT_DEST_FILE
#!/bin/bash
set -euo pipefail
#omg config
OMG_ADDRESS="travis"
OMG_EMAIL="[email protected]"
OMG_DNS="octoprint"
OMG_DOMAIN="$OMG_DNS.$OMG_ADDRESS.omg.lol"
# octopi specific
CERT_USER="pi"
CERT_PATH="/home/$CERT_USER/.config/letsencrypt"
CERT_SOURCE="$CERT_PATH/live/$OMG_DOMAIN"
CERT_DEST_FILE="/etc/ssl/snakeoil.pem"
# https://eff-certbot.readthedocs.io/en/stable/using.html#certbot-command-line-options
certbot certonly -d $OMG_DOMAIN --config-dir $CERT_PATH --work-dir $CERT_PATH --logs-dir $CERT_PATH --email $OMG_EMAIL --agree-tos --no-eff-email --preferred-challenges dns --manual
# follow instructions to update the TXT record for "_acme-challenge.$OMG_DOMAIN"
# TODO: update the TXT via the omg API
# https://api.omg.lol/#token-patch-dns-edit-an-existing-dns-record
cat "$CERT_SOURCE/cert.pem" > "$CERT_SOURCE/combined.pem"
cat "$CERT_SOURCE/privkey.pem" >> "$CERT_SOURCE/combined.pem"
sudo cp "$CERT_SOURCE/combined.pem" $CERT_DEST_FILE
sudo chown $CERT_USER:$CERT_USER $CERT_DEST_FILE
sudo chmod 0700 $CERT_DEST_FILE
# restart octopi?
#sudo systemctl restart octopi.service
#!/bin/bash
set -euo pipefail
#omg config
OMG_ADDRESS="travis"
OMG_EMAIL="[email protected]"
OMG_DNS="pihole"
OMG_DOMAIN="$OMG_DNS.$OMG_ADDRESS.omg.lol"
# pihole specific
CERT_USER="pihole"
CERT_PATH="/home/$CERT_USER/.config/letsencrypt"
CERT_SOURCE="$CERT_PATH/live/$OMG_DOMAIN"
CERT_DEST_FILE="/etc/pihole/tls.pem"
# https://eff-certbot.readthedocs.io/en/stable/using.html#certbot-command-line-options
certbot certonly -d $OMG_DOMAIN --config-dir $CERT_PATH --work-dir $CERT_PATH --logs-dir $CERT_PATH --email $OMG_EMAIL --agree-tos --no-eff-email --preferred-challenges dns --manual
# follow instructions to update the TXT record for "_acme-challenge.$OMG_DOMAIN"
# TODO: update the TXT via the omg API
# https://api.omg.lol/#token-patch-dns-edit-an-existing-dns-record
cp "$CERT_SOURCE/cert.pem" $CERT_DEST_FILE
cat "$CERT_SOURCE/privkey.pem" >> $CERT_DEST_FILE
chown $CERT_USER:$CERT_USER $CERT_DEST_FILE
chmod 0700 $CERT_DEST_FILE
# restart pihole
sudo systemctl restart pihole-FTL.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment