Created
June 12, 2020 02:13
-
-
Save kiwi-cam/555df8c730d5881686ce66635ab37843 to your computer and use it in GitHub Desktop.
A simple bash script to email details of your Homebridge setup for backup/archiving. Takes a single argument, the email destination. Uses sendmail so some configuration may be required. Also assumes config.json is in /var/homebridge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if ! [[ "$1" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]] | |
then | |
echo "Email address $1 is invalid." | |
exit 1 | |
fi | |
npm=`npm list -g --depth=0 | sed 's/$/<br \/>/'` | |
config=`cat /var/homebridge/config.json | sed 's/$/<br \/>/'` | |
subject="Homebridge Backup" | |
from="[email protected]" | |
recipients="$1" | |
message="Below is a record of your Homebridge installation and configuration" | |
mail="subject:$subject\nfrom:$from\nto:$1\nContent-Type: text/html\nMIME-Version: 1.0\n\n<HTML><BODY>$message<br /><br /><b>NPM:</b><br />$npm<br /><b>Config:</b><br />$config</BODY></HTML>" | |
echo -e $mail | /usr/sbin/sendmail -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment