浏览代码

Ensure that there is a security repo

Bob Mottram 10 年前
父节点
当前提交
04e4d301eb
共有 1 个文件被更改,包括 31 次插入18 次删除
  1. 31
    18
      install-freedombone.sh

+ 31
- 18
install-freedombone.sh 查看文件

@@ -52,6 +52,11 @@ SSH_PORT=2222
52 52
 KERNEL_VERSION="v3.15.10-bone7"
53 53
 USE_HWRNG="yes"
54 54
 
55
+# The Debian package repository to use.
56
+DEBIAN_REPO="ftp.de.debian.org"
57
+
58
+DEBIAN_VERSION="jessie"
59
+
55 60
 # Directory where source code is downloaded and compiled
56 61
 INSTALL_DIR=/root/build
57 62
 
@@ -98,21 +103,29 @@ function remove_proprietary_repos {
98 103
   echo 'remove_proprietary_repos' >> $COMPLETION_FILE
99 104
 }
100 105
 
101
-function https_repos {
102
-  # The lack of https repos by default is I think a significant security
103
-  # problem, potentially allowing an adversary to modify package downloads,
104
-  # checksums or gpg public keys in transit and also to know what is installed
105
-  # on your system
106
-  # See http://forums.debian.net/viewtopic.php?f=10&t=74444
107
-  # https://wiki.debian.org/SecureApt
108
-  if grep -Fxq "https_repos" $COMPLETION_FILE; then
106
+function change_debian_repos {
107
+  if grep -Fxq "change_debian_repos" $COMPLETION_FILE; then
109 108
 	  return
110 109
   fi
111
-  apt-get -y update
112
-  # Since at the present time this does not work it's commented out
113
-  #apt-get -y --force-yes install apt-transport-https
114
-  #sed -i 's/http:/https:/g' /etc/apt/sources.list
115
-  echo 'https_repos' >> $COMPLETION_FILE
110
+  rm -rf /var/lib/apt/lists/*
111
+  apt-get clean
112
+  sed -i "s/ftp.us.debian.org/$DEBIAN_REPO/g" /etc/apt/sources.list
113
+
114
+  # ensure that there is a security repo
115
+  if ! grep -q "security" /etc/apt/sources.list; then
116
+      if grep -q "jessie" /etc/apt/sources.list; then
117
+          echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
118
+          echo "#deb-src http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
119
+	  else
120
+          if grep -q "wheezy" /etc/apt/sources.list; then
121
+              echo "deb http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
122
+              echo "#deb-src http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
123
+		  fi
124
+	  fi
125
+  fi
126
+
127
+  apt-get update
128
+  echo 'change_debian_repos' >> $COMPLETION_FILE
116 129
 }
117 130
 
118 131
 function initial_setup {
@@ -137,8 +150,8 @@ function enable_backports {
137 150
   if grep -Fxq "enable_backports" $COMPLETION_FILE; then
138 151
 	  return
139 152
   fi
140
-  if ! grep -Fxq "deb http://ftp.us.debian.org/debian jessie-backports main" /etc/apt/sources.list; then
141
-    echo "deb http://ftp.us.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
153
+  if ! grep -Fxq "deb https://$DEBIAN_REPO/debian jessie-backports main" /etc/apt/sources.list; then
154
+    echo "deb https://$DEBIAN_REPO/debian jessie-backports main" >> /etc/apt/sources.list
142 155
   fi
143 156
   echo 'enable_backports' >> $COMPLETION_FILE
144 157
 }
@@ -573,7 +586,7 @@ function configure_email {
573 586
 	  return
574 587
   fi
575 588
   apt-get -y remove postfix
576
-  apt-get -y install exim4-daemon-heavy sasl2-bin swaks libnet-ssleay-perl procmail
589
+  apt-get -y install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
577 590
   echo 'dc_eximconfig_configtype="internet"' > /etc/exim4/update-exim4.conf.conf
578 591
   echo "dc_other_hostnames='$DOMAIN_NAME'" >> /etc/exim4/update-exim4.conf.conf
579 592
   echo "dc_local_interfaces=''" >> /etc/exim4/update-exim4.conf.conf
@@ -965,12 +978,12 @@ configure_firewall_for_dns
965 978
 configure_firewall_for_ftp
966 979
 configure_firewall_for_web
967 980
 remove_proprietary_repos
968
-https_repos
981
+change_debian_repos
982
+enable_backports
969 983
 configure_dns
970 984
 initial_setup
971 985
 install_editor
972 986
 change_login_message
973
-enable_backports
974 987
 update_the_kernel
975 988
 enable_zram
976 989
 random_number_generator