瀏覽代碼

Dynamic dns

Bob Mottram 10 年之前
父節點
當前提交
276efa67c3
共有 1 個文件被更改,包括 45 次插入4 次删除
  1. 45
    4
      install-freedombone.sh

+ 45
- 4
install-freedombone.sh 查看文件

1
 #!/bin/bash
1
 #!/bin/bash
2
 # Freedombone install script intended for use with Debian Jessie
2
 # Freedombone install script intended for use with Debian Jessie
3
-
3
+#
4
+# Note on dynamic dns
5
+# ===================
6
+#
7
+# I'm not particularly trying to promote freedns.afraid.org
8
+# as a service, it just happens to be a dynamic DNS system which
9
+# provides free (as in beer) accounts, and I'm trying to make the
10
+# process of setting up a working server as trivial as possible.
11
+# Other dynamic DNS systems are available, and if you're using
12
+# something different then comment out the section within
13
+# argument check and the call to dynamic_dns_freedns.
14
+#
15
+# Prerequisites
16
+# =============
17
+#
4
 # cd ~/
18
 # cd ~/
5
 # wget http://freedombone.uk.to/debian-jessie-console-armhf-2014-08-13.tar.xz
19
 # wget http://freedombone.uk.to/debian-jessie-console-armhf-2014-08-13.tar.xz
6
 #
20
 #
47
 
61
 
48
 DOMAIN_NAME=$1
62
 DOMAIN_NAME=$1
49
 MY_USERNAME=$2
63
 MY_USERNAME=$2
64
+FREEDNS_SUBDOMAIN_CODE=$3
50
 
65
 
51
 SSH_PORT=2222
66
 SSH_PORT=2222
52
 KERNEL_VERSION="v3.15.10-bone7"
67
 KERNEL_VERSION="v3.15.10-bone7"
77
 	  echo "Please specify your username"
92
 	  echo "Please specify your username"
78
 	  exit
93
 	  exit
79
   fi
94
   fi
95
+  if [ ! $FREEDNS_SUBDOMAIN_CODE ]; then
96
+	  echo "Please specify the freedns subdomain code.  To find it from https://freedns.afraid.org select 'Dynamic DNS', then 'quick cron example' and copy the code located between '?' and '=='."
97
+	  exit
98
+  fi
80
 }
99
 }
81
 
100
 
82
 function change_login_message {
101
 function change_login_message {
662
 }
681
 }
663
 
682
 
664
 function spam_filtering {
683
 function spam_filtering {
684
+  # NOTE: spamassassin installation currently doesn't work, sa-compile fails with a make error 23/09/2014
665
   if grep -Fxq "spam_filtering" $COMPLETION_FILE; then
685
   if grep -Fxq "spam_filtering" $COMPLETION_FILE; then
666
 	  return
686
 	  return
667
   fi
687
   fi
668
-  apt-get -y install spamassassin
688
+  apt-get -y --force-yes install exim4-daemon-heavy
689
+  apt-get -y --force-yes install spamassassin
690
+  sa-update -v
669
   sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin
691
   sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin
670
   sed -i 's/# spamd_address = 127.0.0.1 783/spamd_address = 127.0.0.1 783/g' /etc/exim4/exim4.conf.template
692
   sed -i 's/# spamd_address = 127.0.0.1 783/spamd_address = 127.0.0.1 783/g' /etc/exim4/exim4.conf.template
671
   # This configuration is based on https://wiki.debian.org/DebianSpamAssassin
693
   # This configuration is based on https://wiki.debian.org/DebianSpamAssassin
755
   if grep -Fxq "configure_imap" $COMPLETION_FILE; then
777
   if grep -Fxq "configure_imap" $COMPLETION_FILE; then
756
 	  return
778
 	  return
757
   fi
779
   fi
758
-  apt-get -y install dovecot-common dovecot-imapd
780
+  apt-get -y --force-yes install dovecot-common dovecot-imapd
759
   makecert dovecot
781
   makecert dovecot
760
   chown root:dovecot /etc/ssl/certs/dovecot.crt
782
   chown root:dovecot /etc/ssl/certs/dovecot.crt
761
   chown root:dovecot /etc/ssl/private/dovecot.key
783
   chown root:dovecot /etc/ssl/private/dovecot.key
788
   if grep -Fxq "email_client" $COMPLETION_FILE; then
810
   if grep -Fxq "email_client" $COMPLETION_FILE; then
789
 	  return
811
 	  return
790
   fi
812
   fi
791
-  apt-get -y install mutt-patched lynx abook
813
+  apt-get -y --force-yes install mutt-patched lynx abook
792
   if [ ! -d /home/$MY_USERNAME/.mutt ]; then
814
   if [ ! -d /home/$MY_USERNAME/.mutt ]; then
793
     mkdir /home/$MY_USERNAME/.mutt
815
     mkdir /home/$MY_USERNAME/.mutt
794
   fi
816
   fi
957
   echo 'folders_for_email_addresses' >> $COMPLETION_FILE
979
   echo 'folders_for_email_addresses' >> $COMPLETION_FILE
958
 }
980
 }
959
 
981
 
982
+function dynamic_dns_freedns {
983
+  if grep -Fxq "dynamic_dns_freedns" $COMPLETION_FILE; then
984
+	  return
985
+  fi
986
+
987
+  echo '#!/bin/bash' > /usr/bin/dynamicdns
988
+  echo '# subdomain name 1' >> /usr/bin/dynamicdns
989
+  echo "wget -O - https://freedns.afraid.org/dynamic/update.php?$FREEDNS_SUBDOMAIN_CODE== >> /dev/null 2>&1" >> /usr/bin/dynamicdns
990
+  echo '# add any other subdomains below' >> /usr/bin/dynamicdns
991
+  chmod 600 /usr/bin/dynamicdns
992
+  chmod +x /usr/bin/dynamicdns
993
+
994
+  if ! grep -q "dynamicdns" /etc/crontab; then
995
+    sed -i '/# m h dom mon dow user	command/a\*/5 * * * * root /usr/bin/timeout 240 /usr/bin/dynamicdns' /etc/crontab
996
+  fi
997
+  echo 'dynamic_dns_freedns' >> $COMPLETION_FILE
998
+}
999
+
960
 function install_final {
1000
 function install_final {
961
   if grep -Fxq "install_final" $COMPLETION_FILE; then
1001
   if grep -Fxq "install_final" $COMPLETION_FILE; then
962
 	  return
1002
 	  return
998
 configure_firewall_for_email
1038
 configure_firewall_for_email
999
 folders_for_mailing_lists
1039
 folders_for_mailing_lists
1000
 folders_for_email_addresses
1040
 folders_for_email_addresses
1041
+dynamic_dns_freedns
1001
 install_final
1042
 install_final
1002
 echo 'Freedombone installation is complete'
1043
 echo 'Freedombone installation is complete'