Преглед изворни кода

Change exim relay when changing network

Bob Mottram пре 8 година
родитељ
комит
84adebc17b
2 измењених фајлова са 20 додато и 4 уклоњено
  1. 17
    4
      src/freedombone-base-email
  2. 3
    0
      src/freedombone-controlpanel

+ 17
- 4
src/freedombone-base-email Прегледај датотеку

@@ -804,7 +804,9 @@ function install_email {
804 804
     echo "dc_readhost=''" >> /etc/exim4/update-exim4.conf.conf
805 805
     echo "dc_relay_domains=''" >> /etc/exim4/update-exim4.conf.conf
806 806
     echo "dc_minimaldns='false'" >> /etc/exim4/update-exim4.conf.conf
807
-    RELAY_NETS='192.168.1.0/24'
807
+    IPv4_address=$(get_ipv4_address)
808
+    IPv4_address_base=$(echo "$IPv4_address" | awk -F '.' '{print $1"."$2"."$3}')
809
+    RELAY_NETS="${IPv4_address_base}.0/24"
808 810
     if [ $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
809 811
         RELAY_NETS=$(echo $LOCAL_NETWORK_STATIC_IP_ADDRESS | awk -F '.' '{print $1 "." $2 "." $3 ".0/24"}')
810 812
     fi
@@ -832,9 +834,9 @@ function install_email {
832 834
 
833 835
     sed -i '/login_saslauthd_server/,/.endif/ s/# *//' /etc/exim4/exim4.conf.template
834 836
     if ! grep -q "MAIN_TLS_ENABLE = true" /etc/exim4/exim4.conf.template; then
835
-        sed -i "/.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME/i\MAIN_HARDCODE_PRIMARY_HOSTNAME = $DEFAULT_DOMAIN_NAME\nMAIN_TLS_ENABLE = true" /etc/exim4/exim4.conf.template
837
+        sed -i "/.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME/i\MAIN_HARDCODE_PRIMARY_HOSTNAME =\nMAIN_TLS_ENABLE = true" /etc/exim4/exim4.conf.template
836 838
     else
837
-        sed -i "s|MAIN_HARDCODE_PRIMARY_HOSTNAME =.*|MAIN_HARDCODE_PRIMARY_HOSTNAME = $DEFAULT_DOMAIN_NAME|g" /etc/exim4/exim4.conf.template
839
+        sed -i "s|MAIN_HARDCODE_PRIMARY_HOSTNAME =.*|MAIN_HARDCODE_PRIMARY_HOSTNAME =|g" /etc/exim4/exim4.conf.template
838 840
     fi
839 841
     sed -i "s|SMTPLISTENEROPTIONS=''|SMTPLISTENEROPTIONS='-oX 465:25:587 -oP /var/run/exim4/exim.pid'|g" /etc/default/exim4
840 842
     if ! grep -q "tls_on_connect_ports=465" /etc/exim4/exim4.conf.template; then
@@ -847,6 +849,9 @@ function install_email {
847 849
     adduser $MY_USERNAME sasl
848 850
     addgroup Debian-exim sasl
849 851
     systemctl restart exim4
852
+    if [ ! -d /etc/skel/log ]; then
853
+        mkdir -m 700 /etc/skel/log
854
+    fi
850 855
     if [ ! -d /etc/skel/Maildir ]; then
851 856
         mkdir -m 700 /etc/skel/.mutt
852 857
         mkdir -m 700 /etc/skel/Maildir
@@ -897,6 +902,14 @@ function install_email {
897 902
     mark_completed $FUNCNAME
898 903
 }
899 904
 
905
+function email_change_relay {
906
+    curr_ip_address="$1"
907
+    email_relay_base=$(echo "$curr_ip_address" | awk -F '.' '{print $1"."$2"."$3}')
908
+    RELAY_NETS="${email_relay_base}.0/24"
909
+    sed -i "s|dc_relay_nets=.*|dc_relay_nets='$RELAY_NETS'|g" /etc/exim4/update-exim4.conf.conf
910
+    dpkg-reconfigure --frontend noninteractive exim4-config
911
+}
912
+
900 913
 function create_procmail {
901 914
     if [ ! -d /etc/exim4 ]; then
902 915
         return
@@ -1094,7 +1107,7 @@ function spam_filtering {
1094 1107
     # this must be accessible by root
1095 1108
     chown -R $MY_USERNAME:root /home/$MY_USERNAME/.spamassassin
1096 1109
 
1097
-    systemctl restart spamassassin
1110
+    systemctl start spamassassin
1098 1111
     systemctl restart exim4
1099 1112
     systemctl restart cron
1100 1113
 

+ 3
- 0
src/freedombone-controlpanel Прегледај датотеку

@@ -1344,6 +1344,9 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_
1344 1344
             write_config_param "NETWORK_IS_STATIC" "1"
1345 1345
             write_config_param "STATIC_IP_ADDRESS" "$NEW_STATIC_IP"
1346 1346
             write_config_param "ROUTER_IP_ADDRESS" "$NEW_STATIC_GATEWAY"
1347
+
1348
+            email_change_relay "$NEW_STATIC_IP"
1349
+
1347 1350
             if [[ $(config_param_exists "WIFI_INTERFACE") == "0" ]]; then
1348 1351
                 # wired network
1349 1352
                 echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces