Last active
March 20, 2018 07:02
-
-
Save absurd/ea4d5f8dd5d35cd4098279d780690879 to your computer and use it in GitHub Desktop.
Emalias -- shell script to quickly generate Postfix email aliases
This file contains 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
#!/usr/local/bin/zsh | |
default_address="you@example.com" | |
if [ -t 0 ]; then | |
# read more about heredocs (the <<ENDSSH ... ENDSSH part): https://en.wikipedia.org/wiki/Here_document | |
ssh you@$EMAIL_SERVER_IP <<ENDSSH | |
echo "$1@example.com $default_address" | sudo tee -a /etc/postfix/virtual \ | |
&& sudo postmap /etc/postfix/virtual \ | |
&& sudo service postfix restart | |
ENDSSH | |
# assumes passwordless sudo. See here if you need to set this up: https://askubuntu.com/questions/147241/execute-sudo-without-password | |
else | |
echo "oops" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment