This commit is contained in:
Brian Zalewski 2023-08-01 06:34:52 +00:00
parent 1dfd4ad9b1
commit d654073009

View file

@ -73,8 +73,6 @@ if command -v postfix > /dev/null; then
logg warn 'Unable to identify root user home directory' logg warn 'Unable to identify root user home directory'
fi fi
### Forward user e-mails
### Ensure /etc/postfix/header_checks exists ### Ensure /etc/postfix/header_checks exists
if [ ! -d /etc/postfix/header_checks ]; then if [ ! -d /etc/postfix/header_checks ]; then
logg info 'Creating /etc/postfix/header_checks since it does not exist' logg info 'Creating /etc/postfix/header_checks since it does not exist'
@ -90,25 +88,32 @@ if command -v postfix > /dev/null; then
### Update aliases ### Update aliases
if [ -f /etc/aliases ]; then if [ -f /etc/aliases ]; then
logg info 'Forward root e-mails to {{ .user.email }}' logg info 'Forward root e-mails to {{ .user.email }}'
sudo sed s/#root.*/root:\ {{ .user.email }}/ -i /etc/aliases && sudo newaliases sudo sed s/#root.*/root:\ {{ .user.email }}/ -i /etc/aliases
if ! cat /etc/aliases | grep '{{ .user.username }}: root' > /dev/null; then if ! cat /etc/aliases | grep '{{ .user.username }}: root' > /dev/null; then
logg info 'Forward user e-mail to root@localhost' logg info 'Forward user e-mail to root@localhost'
echo '{{ .user.username }}: root' | sudo tee -a /etc/aliases > /dev/null echo '{{ .user.username }}: root' | sudo tee -a /etc/aliases > /dev/null
fi fi
logg info 'Running `newaliases` to regenerate the alias database'
sudo newaliases
else
logg warn '/etc/aliases does not appear to exist'
fi fi
if [ -d /Applications ] && [ -d /System ]; then if [ -d /Applications ] && [ -d /System ]; then
### macOS ### macOS
# Source: https://budiirawan.com/install-mail-server-mac-osx/ # Source: https://budiirawan.com/install-mail-server-mac-osx/
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/postfix/com.apple.postfix.master.plist" ]; then if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/postfix/com.apple.postfix.master.plist" ] && ! sudo launchctl list | grep 'postfix.master' > /dev/null; then
logg info 'Copying com.apple.postfix.master.plist' logg info 'Copying com.apple.postfix.master.plist'
sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/postfix/com.apple.postfix.master.plist" /System/Library/LaunchDaemons/com.apple.postfix.master.plist sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/postfix/com.apple.postfix.master.plist" /System/Library/LaunchDaemons/com.apple.postfix.master.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.postfix.master.plist && logg success 'launchctl load of com.apple.postfix.master successful' sudo launchctl load /System/Library/LaunchDaemons/com.apple.postfix.master.plist && logg success 'launchctl load of com.apple.postfix.master successful'
fi fi
if ! sudo postfix status > /dev/null; then
logg info 'Starting postfix' logg info 'Starting postfix'
sudo postfix start sudo postfix start
else
logg info 'Reloading postfix' logg info 'Reloading postfix'
sudo postfix reload sudo postfix reload
fi
else else
### Enable / restart postfix on Linux ### Enable / restart postfix on Linux
logg info 'Enabling / restarting postfix' logg info 'Enabling / restarting postfix'