added if statements
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y libsasl2-modules mailutils postfix postfix-pcre
|
||||
|
||||
echo "smtp.gmail.com notify.akanealw@gmail.com:leawkqqpthbwacrf" > /etc/postfix/sasl_passwd
|
||||
echo "/^From:.*/ REPLACE From: $(hostname) <notify.akanealw@gmail.com>" > /etc/postfix/smtp_header_checks
|
||||
|
||||
chmod 600 /etc/postfix/sasl_passwd
|
||||
|
||||
postmap hash:/etc/postfix/sasl_passwd
|
||||
postmap hash:/etc/postfix/smtp_header_checks
|
||||
|
||||
isInFile=$(cat /etc/postfix/main.cf | grep -c "gmail")
|
||||
if [ $isInFile -eq 0 ]
|
||||
then
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y libsasl2-modules mailutils postfix postfix-pcre
|
||||
echo "smtp.gmail.com notify.akanealw@gmail.com:leawkqqpthbwacrf" > /etc/postfix/sasl_passwd
|
||||
echo "/^From:.*/ REPLACE From: $(hostname) <notify.akanealw@gmail.com>" > /etc/postfix/smtp_header_checks
|
||||
chmod 600 /etc/postfix/sasl_passwd
|
||||
postmap hash:/etc/postfix/sasl_passwd
|
||||
postmap hash:/etc/postfix/smtp_header_checks
|
||||
sed -i 's@relayhost =@#relayhost = @g' /etc/postfix/main.cf
|
||||
sed -i 's@smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache@#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache@g' /etc/postfix/main.cf
|
||||
echo "" >> /etc/postfix/main.cf
|
||||
@@ -27,8 +23,6 @@ if [ $isInFile -eq 0 ]
|
||||
echo "smtp_tls_session_cache_timeout = 3600s" >> /etc/postfix/main.cf
|
||||
echo "smtp_header_checks = pcre:/etc/postfix/smtp_header_checks" >> /etc/postfix/main.cf
|
||||
echo "" >> /etc/postfix/main.cf
|
||||
postfix reload
|
||||
echo "This is a test message sent from postfix on $(hostname)" | mail -s "Test Email from $(hostname)" akanealw@gmail.com
|
||||
fi
|
||||
|
||||
postfix reload
|
||||
|
||||
echo "This is a test message sent from postfix on $(hostname)" | mail -s "Test Email from $(hostname)" akanealw@gmail.com
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
apt install -y apt-listchanges unattended-upgrades
|
||||
sed -i 's@// "origin=Debian,codename=${distro_codename}-updates";@ "origin=Debian,codename=${distro_codename}-updates";@g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
sed -i 's!//Unattended-Upgrade::Mail "";!Unattended-Upgrade::Mail "akanealw@gmail.com";!g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
sed -i 's@//Unattended-Upgrade::MailReport "on-change";@Unattended-Upgrade::MailReport "on-change";@g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
sed -i 's@//Unattended-Upgrade::Remove-Unused-Dependencies "false";@Unattended-Upgrade::Remove-Unused-Dependencies "true";@g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
echo "APT::Periodic::Update-Package-Lists \"1\";" > /etc/apt/apt.conf.d/20auto-upgrades
|
||||
echo "APT::Periodic::Unattended-Upgrade \"1\";" >> /etc/apt/apt.conf.d/20auto-upgrades
|
||||
systemctl enable unattended-upgrades
|
||||
systemctl start unattended-upgrades
|
||||
systemctl status unattended-upgrades
|
||||
isInFile=$(cat /etc/postfix/main.cf | grep -c "APT::Periodic::Unattended-Upgrade \"1\"")
|
||||
if [ $isInFile -eq 0 ]
|
||||
then
|
||||
apt install -y apt-listchanges unattended-upgrades
|
||||
sed -i 's@// "origin=Debian,codename=${distro_codename}-updates";@ "origin=Debian,codename=${distro_codename}-updates";@g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
sed -i 's!//Unattended-Upgrade::Mail "";!Unattended-Upgrade::Mail "akanealw@gmail.com";!g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
sed -i 's@//Unattended-Upgrade::MailReport "on-change";@Unattended-Upgrade::MailReport "on-change";@g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
sed -i 's@//Unattended-Upgrade::Remove-Unused-Dependencies "false";@Unattended-Upgrade::Remove-Unused-Dependencies "true";@g' /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
echo "APT::Periodic::Update-Package-Lists \"1\";" > /etc/apt/apt.conf.d/20auto-upgrades
|
||||
echo "APT::Periodic::Unattended-Upgrade \"1\";" >> /etc/apt/apt.conf.d/20auto-upgrades
|
||||
systemctl enable unattended-upgrades
|
||||
systemctl start unattended-upgrades
|
||||
systemctl status unattended-upgrades
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user