install-freedombone.sh 48KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. #!/bin/bash
  2. # Freedombone install script intended for use with Debian Jessie
  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_checks and the call to dynamic_dns_freedns.
  14. #
  15. # Prerequisites
  16. # =============
  17. #
  18. # cd ~/
  19. # wget http://freedombone.uk.to/debian-jessie-console-armhf-2014-08-13.tar.xz
  20. #
  21. # Verify it.
  22. #
  23. # sha256sum debian-jessie-console-armhf-2014-08-13.tar.xz
  24. # fc225cfb3c2dfad92cccafa97e92c3cd3db9d94f4771af8da364ef59609f43de
  25. #
  26. # Uncompress it.
  27. #
  28. # tar xJf debian-jessie-console-armhf-2014-08-13.tar.xz
  29. # cd debian-jessie-console-armhf-2014-08-13
  30. #
  31. # sudo apt-get install u-boot-tools dosfstools git-core kpartx wget parted
  32. # sudo ./setup_sdcard.sh --mmc /dev/sdX --dtb beaglebone
  33. #
  34. # When finished eject the micrtoSD then reinsert it
  35. #
  36. # sudo cp /media/$USER/BOOT/bbb-uEnv.txt /media/$USER/BOOT/uEnv.txt
  37. # sync
  38. #
  39. # Eject microSD, insert into BBB, attach USB cable between BBB and laptop.
  40. # On Ubuntu wait until you see the "connected" message.
  41. #
  42. # ssh-keygen -f "/home/$USER/.ssh/known_hosts" -R 192.168.7.2
  43. # ssh debian@192.168.7.2 (password "temppwd")
  44. # su (password "root")
  45. # passwd
  46. # adduser $MY_USERNAME
  47. # sed -i '/iface eth0 inet dhcp/a\iface eth0 inet static' /etc/network/interfaces
  48. # sed -i '/iface eth0 inet static/a\ dns-nameservers 213.73.91.35 85.214.20.141' /etc/network/interfaces
  49. # sed -i "/iface eth0 inet static/a\ gateway $MY_ROUTER_IP" /etc/network/interfaces
  50. # sed -i '/iface eth0 inet static/a\ netmask 255.255.255.0' /etc/network/interfaces
  51. # sed -i "/iface eth0 inet static/a\ address $MY_BBB_STATIC_IP" /etc/network/interfaces
  52. # sed -i '/iface usb0 inet static/,/ gateway 192.168.7.1/ s/^/#/' /etc/network/interfaces
  53. # shutdown now
  54. #
  55. # Connect BBB to router
  56. #
  57. # scp install-freedombone.sh $MY_USERNAME@$MY_BBB_STATIC_IP:/home/$MY_USERNAME
  58. # ssh $MY_USERNAME@$MY_BBB_STATIC_IP
  59. # su
  60. # ./install-freedombone.sh [DOMAIN_NAME] [MY_USERNAME]
  61. DOMAIN_NAME=$1
  62. MY_USERNAME=$2
  63. FREEDNS_SUBDOMAIN_CODE=$3
  64. SSH_PORT=2222
  65. KERNEL_VERSION="v3.15.10-bone7"
  66. USE_HWRNG="yes"
  67. GPG_KEYSERVER="hkp://keys.gnupg.net"
  68. # The Debian package repository to use.
  69. DEBIAN_REPO="ftp.de.debian.org"
  70. DEBIAN_VERSION="jessie"
  71. # Directory where source code is downloaded and compiled
  72. INSTALL_DIR=/root/build
  73. export DEBIAN_FRONTEND=noninteractive
  74. # File which keeps track of what has already been installed
  75. COMPLETION_FILE=/root/freedombone-completed.txt
  76. if [ ! -f $COMPLETION_FILE ]; then
  77. touch $COMPLETION_FILE
  78. fi
  79. function argument_checks {
  80. echo './install-freedombone.sh [domain] [username] [subdomain code]'
  81. echo ''
  82. if [ ! $DOMAIN_NAME ]; then
  83. echo 'Please specify your domain name'
  84. exit
  85. fi
  86. if [ ! $MY_USERNAME ]; then
  87. echo 'Please specify your username'
  88. exit
  89. fi
  90. if [ ! $FREEDNS_SUBDOMAIN_CODE ]; then
  91. echo 'Please specify the freedns subdomain code. To find it from '
  92. echo "https://freedns.afraid.org select 'Dynamic DNS', then 'quick "
  93. echo "cron example' and copy the code located between '?' and '=='."
  94. exit
  95. fi
  96. }
  97. function change_login_message {
  98. if grep -Fxq "change_login_message" $COMPLETION_FILE; then
  99. return
  100. fi
  101. echo '' > /etc/motd
  102. echo ".---. . . " >> /etc/motd
  103. echo "| | | " >> /etc/motd
  104. echo "|--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. " >> /etc/motd
  105. echo "| | (.-' (.-' ( | ( )| | | | )( )| | (.-' " >> /etc/motd
  106. echo "' ' --' --' -' - -' ' ' -' -' -' ' - --'" >> /etc/motd
  107. echo '' >> /etc/motd
  108. echo ' Freedom in the Cloud' >> /etc/motd
  109. echo '' >> /etc/motd
  110. echo 'change_login_message' >> $COMPLETION_FILE
  111. }
  112. function remove_proprietary_repos {
  113. if grep -Fxq "remove_proprietary_repos" $COMPLETION_FILE; then
  114. return
  115. fi
  116. sed -i 's/ non-free//g' /etc/apt/sources.list
  117. echo 'remove_proprietary_repos' >> $COMPLETION_FILE
  118. }
  119. function change_debian_repos {
  120. if grep -Fxq "change_debian_repos" $COMPLETION_FILE; then
  121. return
  122. fi
  123. rm -rf /var/lib/apt/lists/*
  124. apt-get clean
  125. sed -i "s/ftp.us.debian.org/$DEBIAN_REPO/g" /etc/apt/sources.list
  126. # ensure that there is a security repo
  127. if ! grep -q "security" /etc/apt/sources.list; then
  128. if grep -q "jessie" /etc/apt/sources.list; then
  129. echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
  130. echo "#deb-src http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
  131. else
  132. if grep -q "wheezy" /etc/apt/sources.list; then
  133. echo "deb http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
  134. echo "#deb-src http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
  135. fi
  136. fi
  137. fi
  138. apt-get update
  139. apt-get -y --force-yes install apt-transport-https
  140. echo 'change_debian_repos' >> $COMPLETION_FILE
  141. }
  142. function initial_setup {
  143. if grep -Fxq "initial_setup" $COMPLETION_FILE; then
  144. return
  145. fi
  146. apt-get -y remove --purge apache*
  147. apt-get -y dist-upgrade
  148. apt-get -y install ca-certificates emacs24
  149. echo 'initial_setup' >> $COMPLETION_FILE
  150. }
  151. function install_editor {
  152. if grep -Fxq "install_editor" $COMPLETION_FILE; then
  153. return
  154. fi
  155. update-alternatives --set editor /usr/bin/emacs24
  156. echo 'install_editor' >> $COMPLETION_FILE
  157. }
  158. function enable_backports {
  159. if grep -Fxq "enable_backports" $COMPLETION_FILE; then
  160. return
  161. fi
  162. if ! grep -Fxq "deb http://$DEBIAN_REPO/debian jessie-backports main" /etc/apt/sources.list; then
  163. echo "deb http://$DEBIAN_REPO/debian jessie-backports main" >> /etc/apt/sources.list
  164. fi
  165. echo 'enable_backports' >> $COMPLETION_FILE
  166. }
  167. function update_the_kernel {
  168. if grep -Fxq "update_the_kernel" $COMPLETION_FILE; then
  169. return
  170. fi
  171. cd /opt/scripts/tools
  172. ./update_kernel.sh --kernel $KERNEL_VERSION
  173. echo 'update_the_kernel' >> $COMPLETION_FILE
  174. }
  175. function enable_zram {
  176. if grep -Fxq "enable_zram" $COMPLETION_FILE; then
  177. return
  178. fi
  179. if ! grep -q "options zram num_devices=1" /etc/modprobe.d/zram.conf; then
  180. echo 'options zram num_devices=1' >> /etc/modprobe.d/zram.conf
  181. fi
  182. echo '#!/bin/bash' > /etc/init.d/zram
  183. echo '### BEGIN INIT INFO' >> /etc/init.d/zram
  184. echo '# Provides: zram' >> /etc/init.d/zram
  185. echo '# Required-Start:' >> /etc/init.d/zram
  186. echo '# Required-Stop:' >> /etc/init.d/zram
  187. echo '# Default-Start: 2 3 4 5' >> /etc/init.d/zram
  188. echo '# Default-Stop: 0 1 6' >> /etc/init.d/zram
  189. echo '# Short-Description: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM)' >> /etc/init.d/zram
  190. echo '# Description: Adapted from systemd scripts at https://github.com/mystilleef/FedoraZram' >> /etc/init.d/zram
  191. echo '### END INIT INFO' >> /etc/init.d/zram
  192. echo 'start() {' >> /etc/init.d/zram
  193. echo ' # get the number of CPUs' >> /etc/init.d/zram
  194. echo ' num_cpus=$(grep -c processor /proc/cpuinfo)' >> /etc/init.d/zram
  195. echo ' # if something goes wrong, assume we have 1' >> /etc/init.d/zram
  196. echo ' [ "$num_cpus" != 0 ] || num_cpus=1' >> /etc/init.d/zram
  197. echo ' # set decremented number of CPUs' >> /etc/init.d/zram
  198. echo ' decr_num_cpus=$((num_cpus - 1))' >> /etc/init.d/zram
  199. echo ' # get the amount of memory in the machine' >> /etc/init.d/zram
  200. echo ' mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching "[[:digit:]]+")' >> /etc/init.d/zram
  201. echo ' mem_total=$((mem_total_kb * 1024))' >> /etc/init.d/zram
  202. echo ' # load dependency modules' >> /etc/init.d/zram
  203. echo ' modprobe zram num_devices=$num_cpus' >> /etc/init.d/zram
  204. echo ' # initialize the devices' >> /etc/init.d/zram
  205. echo ' for i in $(seq 0 $decr_num_cpus); do' >> /etc/init.d/zram
  206. echo ' echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize' >> /etc/init.d/zram
  207. echo ' done' >> /etc/init.d/zram
  208. echo ' # Creating swap filesystems' >> /etc/init.d/zram
  209. echo ' for i in $(seq 0 $decr_num_cpus); do' >> /etc/init.d/zram
  210. echo ' mkswap /dev/zram$i' >> /etc/init.d/zram
  211. echo ' done' >> /etc/init.d/zram
  212. echo ' # Switch the swaps on' >> /etc/init.d/zram
  213. echo ' for i in $(seq 0 $decr_num_cpus); do' >> /etc/init.d/zram
  214. echo ' swapon -p 100 /dev/zram$i' >> /etc/init.d/zram
  215. echo ' done' >> /etc/init.d/zram
  216. echo '}' >> /etc/init.d/zram
  217. echo 'stop() {' >> /etc/init.d/zram
  218. echo ' # get the number of CPUs' >> /etc/init.d/zram
  219. echo ' num_cpus=$(grep -c processor /proc/cpuinfo)' >> /etc/init.d/zram
  220. echo ' # set decremented number of CPUs' >> /etc/init.d/zram
  221. echo ' decr_num_cpus=$((num_cpus - 1))' >> /etc/init.d/zram
  222. echo ' # Switching off swap' >> /etc/init.d/zram
  223. echo ' for i in $(seq 0 $decr_num_cpus); do' >> /etc/init.d/zram
  224. echo ' if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then' >> /etc/init.d/zram
  225. echo ' swapoff /dev/zram$i' >> /etc/init.d/zram
  226. echo ' sleep 1' >> /etc/init.d/zram
  227. echo ' fi' >> /etc/init.d/zram
  228. echo ' done' >> /etc/init.d/zram
  229. echo ' sleep 1' >> /etc/init.d/zram
  230. echo ' rmmod zram' >> /etc/init.d/zram
  231. echo '}' >> /etc/init.d/zram
  232. echo 'case "$1" in' >> /etc/init.d/zram
  233. echo ' start)' >> /etc/init.d/zram
  234. echo ' start' >> /etc/init.d/zram
  235. echo ' ;;' >> /etc/init.d/zram
  236. echo ' stop)' >> /etc/init.d/zram
  237. echo ' stop' >> /etc/init.d/zram
  238. echo ' ;;' >> /etc/init.d/zram
  239. echo ' restart)' >> /etc/init.d/zram
  240. echo ' stop' >> /etc/init.d/zram
  241. echo ' sleep 3' >> /etc/init.d/zram
  242. echo ' start' >> /etc/init.d/zram
  243. echo ' ;;' >> /etc/init.d/zram
  244. echo ' *)' >> /etc/init.d/zram
  245. echo ' echo "Usage: $0 {start|stop|restart}"' >> /etc/init.d/zram
  246. echo ' RETVAL=1' >> /etc/init.d/zram
  247. echo 'esac' >> /etc/init.d/zram
  248. echo 'exit $RETVAL' >> /etc/init.d/zram
  249. chmod +x /etc/init.d/zram
  250. update-rc.d zram defaults
  251. echo 'enable_zram' >> $COMPLETION_FILE
  252. }
  253. function random_number_generator {
  254. if grep -Fxq "random_number_generator" $COMPLETION_FILE; then
  255. return
  256. fi
  257. if [ $USE_HWRNG == "yes" ]; then
  258. apt-get -y --force-yes install rng-tools
  259. sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools
  260. else
  261. apt-get -y --force-yes install haveged
  262. fi
  263. echo 'random_number_generator' >> $COMPLETION_FILE
  264. }
  265. function configure_ssh {
  266. if grep -Fxq "configure_ssh" $COMPLETION_FILE; then
  267. return
  268. fi
  269. sed -i "s/Port 22/Port $SSH_PORT/g" /etc/ssh/sshd_config
  270. sed -i 's/PermitRootLogin without-password/PermitRootLogin no/g' /etc/ssh/sshd_config
  271. sed -i 's/X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config
  272. sed -i 's/ServerKeyBits 1024/ServerKeyBits 4096/g' /etc/ssh/sshd_config
  273. sed -i 's/TCPKeepAlive yes/TCPKeepAlive no/g' /etc/ssh/sshd_config
  274. sed -i 's|HostKey /etc/ssh/ssh_host_dsa_key|#HostKey /etc/ssh/ssh_host_dsa_key|g' /etc/ssh/sshd_config
  275. sed -i 's|HostKey /etc/ssh/ssh_host_ecdsa_key|#HostKey /etc/ssh/ssh_host_ecdsa_key|g' /etc/ssh/sshd_config
  276. echo 'ClientAliveInterval 60' >> /etc/ssh/sshd_config
  277. echo 'ClientAliveCountMax 3' >> /etc/ssh/sshd_config
  278. echo 'Ciphers aes256-ctr,aes128-ctr' >> /etc/ssh/sshd_config
  279. echo 'MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
  280. KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1' >> /etc/ssh/sshd_config
  281. apt-get -y install fail2ban
  282. echo 'configure_ssh' >> $COMPLETION_FILE
  283. echo ''
  284. echo ''
  285. echo ' *** Rebooting to initialise ssh settings and random number generator ***'
  286. echo ''
  287. echo " *** Reconnect via ssh on port $SSH_PORT, then run this script again ***"
  288. echo ''
  289. reboot
  290. }
  291. function regenerate_ssh_keys {
  292. if grep -Fxq "regenerate_ssh_keys" $COMPLETION_FILE; then
  293. return
  294. fi
  295. rm -f /etc/ssh/ssh_host_*
  296. dpkg-reconfigure openssh-server
  297. service ssh restart
  298. echo 'regenerate_ssh_keys' >> $COMPLETION_FILE
  299. }
  300. function configure_dns {
  301. if grep -Fxq "configure_dns" $COMPLETION_FILE; then
  302. return
  303. fi
  304. echo 'domain localdomain' > /etc/resolv.conf
  305. echo 'search localdomain' >> /etc/resolv.conf
  306. echo 'nameserver 213.73.91.35' >> /etc/resolv.conf
  307. echo 'nameserver 85.214.20.141' >> /etc/resolv.conf
  308. echo 'configure_dns' >> $COMPLETION_FILE
  309. }
  310. function set_your_domain_name {
  311. if grep -Fxq "set_your_domain_name" $COMPLETION_FILE; then
  312. return
  313. fi
  314. echo "$DOMAIN_NAME" > /etc/hostname
  315. hostname $DOMAIN_NAME
  316. sed -i "s/127.0.1.1 arm/127.0.1.1 $DOMAIN_NAME/g" /etc/hosts
  317. echo "127.0.1.1 $DOMAIN_NAME" >> /etc/hosts
  318. echo 'set_your_domain_name' >> $COMPLETION_FILE
  319. }
  320. function time_synchronisation {
  321. if grep -Fxq "time_synchronisation" $COMPLETION_FILE; then
  322. return
  323. fi
  324. apt-get -y install tlsdate
  325. apt-get -y remove ntpdate
  326. echo '#!/bin/bash' > /usr/bin/updatedate
  327. echo 'TIMESOURCE=google.com' >> /usr/bin/updatedate
  328. echo 'TIMESOURCE2=www.ptb.de' >> /usr/bin/updatedate
  329. echo 'LOGFILE=/var/log/tlsdate.log' >> /usr/bin/updatedate
  330. echo 'TIMEOUT=5' >> /usr/bin/updatedate
  331. echo "EMAIL=$MY_USERNAME@$DOMAIN_NAME" >> /usr/bin/updatedate
  332. echo '# File which contains the previous date as a number' >> /usr/bin/updatedate
  333. echo 'BEFORE_DATE_FILE=/var/log/tlsdateprevious.txt' >> /usr/bin/updatedate
  334. echo '# File which contains the previous date as a string' >> /usr/bin/updatedate
  335. echo 'BEFORE_FULLDATE_FILE=/var/log/tlsdate.txt' >> /usr/bin/updatedate
  336. echo 'DATE_BEFORE=$(date)' >> /usr/bin/updatedate
  337. echo 'BEFORE=$(date -d "$Y-$M-$D" "+%s")' >> /usr/bin/updatedate
  338. echo 'BACKWARDS_BETWEEN=0' >> /usr/bin/updatedate
  339. echo '# If the date was previously set' >> /usr/bin/updatedate
  340. echo 'if [[ -f "$BEFORE_DATE_FILE" ]]; then' >> /usr/bin/updatedate
  341. echo ' BEFORE_FILE=$(cat $BEFORE_DATE_FILE)' >> /usr/bin/updatedate
  342. echo ' BEFORE_FULLDATE=$(cat $BEFORE_FULLDATE_FILE)' >> /usr/bin/updatedate
  343. echo ' # is the date going backwards?' >> /usr/bin/updatedate
  344. echo ' if (( BEFORE_FILE > BEFORE )); then' >> /usr/bin/updatedate
  345. echo ' echo -n "Date went backwards between tlsdate updates. " >> $LOGFILE' >> /usr/bin/updatedate
  346. echo ' echo -n "$BEFORE_FILE > $BEFORE, " >> $LOGFILE' >> /usr/bin/updatedate
  347. echo ' echo "$BEFORE_FULLDATE > $DATE_BEFORE" >> $LOGFILE' >> /usr/bin/updatedate
  348. echo ' # Send a warning email' > /usr/bin/updatedate
  349. echo ' echo $(tail $LOGFILE -n 2) | mail -s "tlsdate anomaly" $EMAIL' >> /usr/bin/updatedate
  350. echo ' # Try another time source' >> /usr/bin/updatedate
  351. echo ' TIMESOURCE=$TIMESOURCE2' >> /usr/bin/updatedate
  352. echo ' # try running without any parameters' >> /usr/bin/updatedate
  353. echo ' tlsdate >> $LOGFILE' >> /usr/bin/updatedate
  354. echo ' BACKWARDS_BETWEEN=1' >> /usr/bin/updatedate
  355. echo ' fi' >> /usr/bin/updatedate
  356. echo 'fi' >> /usr/bin/updatedate
  357. echo '# Set the date' >> /usr/bin/updatedate
  358. echo '/usr/bin/timeout $TIMEOUT tlsdate -l -t -H $TIMESOURCE -p 443 >> $LOGFILE' >> /usr/bin/updatedate
  359. echo 'DATE_AFTER=$(date)' >> /usr/bin/updatedate
  360. echo 'AFTER=$(date -d "$Y-$M-$D" '+%s')' >> /usr/bin/updatedate
  361. echo '# After setting the date did it go backwards?' >> /usr/bin/updatedate
  362. echo 'if (( AFTER < BEFORE )); then' >> /usr/bin/updatedate
  363. echo ' echo "Incorrect date: $DATE_BEFORE -> $DATE_AFTER" >> $LOGFILE' >> /usr/bin/updatedate
  364. echo ' # Send a warning email' >> /usr/bin/updatedate
  365. echo ' echo $(tail $LOGFILE -n 2) | mail -s "tlsdate anomaly" $EMAIL' >> /usr/bin/updatedate
  366. echo ' # Try resetting the date from another time source' >> /usr/bin/updatedate
  367. echo ' /usr/bin/timeout $TIMEOUT tlsdate -l -t -H $TIMESOURCE2 -p 443 >> $LOGFILE' >> /usr/bin/updatedate
  368. echo ' DATE_AFTER=$(date)' >> /usr/bin/updatedate
  369. echo ' AFTER=$(date -d "$Y-$M-$D" "+%s")' >> /usr/bin/updatedate
  370. echo 'else' >> /usr/bin/updatedate
  371. echo ' echo -n $TIMESOURCE >> $LOGFILE' >> /usr/bin/updatedate
  372. echo ' if [[ -f "$BEFORE_DATE_FILE" ]]; then' >> /usr/bin/updatedate
  373. echo ' echo -n " " >> $LOGFILE' >> /usr/bin/updatedate
  374. echo ' echo -n $BEFORE_FILE >> $LOGFILE' >> /usr/bin/updatedate
  375. echo ' fi' >> /usr/bin/updatedate
  376. echo ' echo -n " " >> $LOGFILE' >> /usr/bin/updatedate
  377. echo ' echo -n $BEFORE >> $LOGFILE' >> /usr/bin/updatedate
  378. echo ' echo -n " " >> $LOGFILE' >> /usr/bin/updatedate
  379. echo ' echo -n $AFTER >> $LOGFILE' >> /usr/bin/updatedate
  380. echo ' echo -n " " >> $LOGFILE' >> /usr/bin/updatedate
  381. echo ' echo $DATE_AFTER >> $LOGFILE' >> /usr/bin/updatedate
  382. echo 'fi' >> /usr/bin/updatedate
  383. echo '# Log the last date' >> /usr/bin/updatedate
  384. echo 'if [ BACKWARDS_BETWEEN == 0 ]; then' >> /usr/bin/updatedate
  385. echo ' echo "$AFTER" > $BEFORE_DATE_FILE' >> /usr/bin/updatedate
  386. echo ' echo "$DATE_AFTER" > $BEFORE_FULLDATE_FILE' >> /usr/bin/updatedate
  387. echo ' exit 0' >> /usr/bin/updatedate
  388. echo 'else' >> /usr/bin/updatedate
  389. echo ' exit 1' >> /usr/bin/updatedate
  390. echo 'fi' >> /usr/bin/updatedate
  391. chmod +x /usr/bin/updatedate
  392. echo '*/15 * * * * root /usr/bin/updatedate' >> /etc/crontab
  393. service cron restart
  394. echo '#!/bin/bash' > /etc/init.d/tlsdate
  395. echo '# /etc/init.d/tlsdate' >> /etc/init.d/tlsdate
  396. echo '### BEGIN INIT INFO' >> /etc/init.d/tlsdate
  397. echo '# Provides: tlsdate' >> /etc/init.d/tlsdate
  398. echo '# Required-Start: $remote_fs $syslog' >> /etc/init.d/tlsdate
  399. echo '# Required-Stop: $remote_fs $syslog' >> /etc/init.d/tlsdate
  400. echo '# Default-Start: 2 3 4 5' >> /etc/init.d/tlsdate
  401. echo '# Default-Stop: 0 1 6' >> /etc/init.d/tlsdate
  402. echo '# Short-Description: Initially calls tlsdate with the timewarp option' >> /etc/init.d/tlsdate
  403. echo '# Description: Initially calls tlsdate with the timewarp option' >> /etc/init.d/tlsdate
  404. echo '### END INIT INFO' >> /etc/init.d/tlsdate
  405. echo '# Author: Bob Mottram <bob@robotics.uk.to>' >> /etc/init.d/tlsdate
  406. echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin"' >> /etc/init.d/tlsdate
  407. echo 'LOGFILE="/var/log/tlsdate.log"' >> /etc/init.d/tlsdate
  408. echo 'TLSDATECOMMAND="tlsdate --timewarp -l -H www.ptb.de -p 443 >> $LOGFILE"' >> /etc/init.d/tlsdate
  409. echo '#Start-Stop here' >> /etc/init.d/tlsdate
  410. echo 'case "$1" in' >> /etc/init.d/tlsdate
  411. echo ' start)' >> /etc/init.d/tlsdate
  412. echo ' echo "tlsdate started"' >> /etc/init.d/tlsdate
  413. echo ' $TLSDATECOMMAND' >> /etc/init.d/tlsdate
  414. echo ' ;;' >> /etc/init.d/tlsdate
  415. echo ' stop)' >> /etc/init.d/tlsdate
  416. echo ' echo "tlsdate stopped"' >> /etc/init.d/tlsdate
  417. echo ' ;;' >> /etc/init.d/tlsdate
  418. echo ' restart)' >> /etc/init.d/tlsdate
  419. echo ' echo "tlsdate restarted"' >> /etc/init.d/tlsdate
  420. echo ' $TLSDATECOMMAND' >> /etc/init.d/tlsdate
  421. echo ' ;;' >> /etc/init.d/tlsdate
  422. echo ' *)' >> /etc/init.d/tlsdate
  423. echo ' echo "Usage: $0 {start|stop|restart}"' >> /etc/init.d/tlsdate
  424. echo ' exit 1' >> /etc/init.d/tlsdate
  425. echo ' ;;' >> /etc/init.d/tlsdate
  426. echo 'esac' >> /etc/init.d/tlsdate
  427. echo 'exit 0' >> /etc/init.d/tlsdate
  428. chmod +x /etc/init.d/tlsdate
  429. update-rc.d tlsdate defaults
  430. echo 'time_synchronisation' >> $COMPLETION_FILE
  431. }
  432. function configure_firewall {
  433. if grep -Fxq "configure_firewall" $COMPLETION_FILE; then
  434. return
  435. fi
  436. iptables -P INPUT ACCEPT
  437. ip6tables -P INPUT ACCEPT
  438. iptables -F
  439. ip6tables -F
  440. iptables -X
  441. ip6tables -X
  442. iptables -P INPUT DROP
  443. ip6tables -P INPUT DROP
  444. iptables -A INPUT -i lo -j ACCEPT
  445. iptables -A INPUT -i eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  446. echo 'configure_firewall' >> $COMPLETION_FILE
  447. }
  448. function save_firewall_settings {
  449. iptables-save > /etc/firewall.conf
  450. ip6tables-save > /etc/firewall6.conf
  451. printf '#!/bin/sh\n' > /etc/network/if-up.d/iptables
  452. printf 'iptables-restore < /etc/firewall.conf\n' >> /etc/network/if-up.d/iptables
  453. printf 'ip6tables-restore < /etc/firewall6.conf\n' >> /etc/network/if-up.d/iptables
  454. chmod +x /etc/network/if-up.d/iptables
  455. }
  456. function configure_firewall_for_dns {
  457. if grep -Fxq "configure_firewall_for_dns" $COMPLETION_FILE; then
  458. return
  459. fi
  460. iptables -A INPUT -i eth0 -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
  461. save_firewall_settings
  462. echo 'configure_firewall_for_dns' >> $COMPLETION_FILE
  463. }
  464. function configure_firewall_for_ftp {
  465. if grep -Fxq "configure_firewall_for_ftp" $COMPLETION_FILE; then
  466. return
  467. fi
  468. iptables -I INPUT -i eth0 -p tcp --dport 1024:65535 --sport 20:21 -j ACCEPT
  469. save_firewall_settings
  470. echo 'configure_firewall_for_ftp' >> $COMPLETION_FILE
  471. }
  472. function configure_firewall_for_web {
  473. if grep -Fxq "configure_firewall_for_web" $COMPLETION_FILE; then
  474. return
  475. fi
  476. iptables -A INPUT -i eth0 -p tcp --dport 32768:61000 --sport 80 -j ACCEPT
  477. iptables -A INPUT -i eth0 -p tcp --dport 32768:61000 --sport 443 -j ACCEPT
  478. save_firewall_settings
  479. echo 'configure_firewall_for_web' >> $COMPLETION_FILE
  480. }
  481. function configure_firewall_for_ssh {
  482. if grep -Fxq "configure_firewall_for_ssh" $COMPLETION_FILE; then
  483. return
  484. fi
  485. iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
  486. iptables -A INPUT -i eth0 -p tcp --dport $SSH_PORT -j ACCEPT
  487. save_firewall_settings
  488. echo 'configure_firewall_for_ssh' >> $COMPLETION_FILE
  489. }
  490. function configure_firewall_for_git {
  491. if grep -Fxq "configure_firewall_for_git" $COMPLETION_FILE; then
  492. return
  493. fi
  494. iptables -A INPUT -i eth0 -p tcp --dport 9418 -j ACCEPT
  495. save_firewall_settings
  496. echo 'configure_firewall_for_git' >> $COMPLETION_FILE
  497. }
  498. function configure_firewall_for_email {
  499. if grep -Fxq "configure_firewall_for_email" $COMPLETION_FILE; then
  500. return
  501. fi
  502. iptables -A INPUT -i eth0 -p tcp --dport 25 -j ACCEPT
  503. iptables -A INPUT -i eth0 -p tcp --dport 587 -j ACCEPT
  504. iptables -A INPUT -i eth0 -p tcp --dport 465 -j ACCEPT
  505. iptables -A INPUT -i eth0 -p tcp --dport 993 -j ACCEPT
  506. save_firewall_settings
  507. echo 'configure_firewall_for_email' >> $COMPLETION_FILE
  508. }
  509. function configure_internet_protocol {
  510. if grep -Fxq "configure_internet_protocol" $COMPLETION_FILE; then
  511. return
  512. fi
  513. sed -i "s/#net.ipv4.tcp_syncookies=1/net.ipv4.tcp_syncookies=1/g" /etc/sysctl.conf
  514. sed -i "s/#net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 0/g" /etc/sysctl.conf
  515. sed -i "s/#net.ipv6.conf.all.accept_redirects = 0/net.ipv6.conf.all.accept_redirects = 0/g" /etc/sysctl.conf
  516. sed -i "s/#net.ipv4.conf.all.send_redirects = 0/net.ipv4.conf.all.send_redirects = 0/g" /etc/sysctl.conf
  517. sed -i "s/#net.ipv4.conf.all.accept_source_route = 0/net.ipv4.conf.all.accept_source_route = 0/g" /etc/sysctl.conf
  518. sed -i "s/#net.ipv6.conf.all.accept_source_route = 0/net.ipv6.conf.all.accept_source_route = 0/g" /etc/sysctl.conf
  519. sed -i "s/#net.ipv4.conf.default.rp_filter=1/net.ipv4.conf.default.rp_filter=1/g" /etc/sysctl.conf
  520. sed -i "s/#net.ipv4.conf.all.rp_filter=1/net.ipv4.conf.all.rp_filter=1/g" /etc/sysctl.conf
  521. sed -i "s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=0/g" /etc/sysctl.conf
  522. sed -i "s/#net.ipv6.conf.all.forwarding=1/net.ipv6.conf.all.forwarding=0/g" /etc/sysctl.conf
  523. echo '# ignore pings' >> /etc/sysctl.conf
  524. echo 'net.ipv4.icmp_echo_ignore_all = 1' >> /etc/sysctl.conf
  525. echo 'net.ipv6.icmp_echo_ignore_all = 1' >> /etc/sysctl.conf
  526. echo '# disable ipv6' >> /etc/sysctl.conf
  527. echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf
  528. echo 'net.ipv4.tcp_synack_retries = 2' >> /etc/sysctl.conf
  529. echo 'net.ipv4.tcp_syn_retries = 1' >> /etc/sysctl.conf
  530. echo '# keepalive' >> /etc/sysctl.conf
  531. echo 'net.ipv4.tcp_keepalive_probes = 9' >> /etc/sysctl.conf
  532. echo 'net.ipv4.tcp_keepalive_intvl = 75' >> /etc/sysctl.conf
  533. echo 'net.ipv4.tcp_keepalive_time = 7200' >> /etc/sysctl.conf
  534. echo 'configure_internet_protocol' >> $COMPLETION_FILE
  535. }
  536. function script_to_make_self_signed_certificates {
  537. if grep -Fxq "script_to_make_self_signed_certificates" $COMPLETION_FILE; then
  538. return
  539. fi
  540. echo '#!/bin/bash' > /usr/bin/makecert
  541. echo 'HOSTNAME=$1' >> /usr/bin/makecert
  542. echo 'COUNTRY_CODE="US"' >> /usr/bin/makecert
  543. echo 'AREA="Free Speech Zone"' >> /usr/bin/makecert
  544. echo 'LOCATION="Freedomville"' >> /usr/bin/makecert
  545. echo 'ORGANISATION="Freedombone"' >> /usr/bin/makecert
  546. echo 'UNIT="Freedombone Unit"' >> /usr/bin/makecert
  547. echo 'if ! which openssl > /dev/null ;then' >> /usr/bin/makecert
  548. echo ' echo "$0: openssl is not installed, exiting" 1>&2' >> /usr/bin/makecert
  549. echo ' exit 1' >> /usr/bin/makecert
  550. echo 'fi' >> /usr/bin/makecert
  551. echo 'openssl req -x509 -nodes -days 3650 -sha256 -subj "/O=$ORGANISATION/OU=$UNIT/C=$COUNTRY_CODE/ST=$AREA/L=$LOCATION/CN=$HOSTNAME" -newkey rsa:4096 -keyout /etc/ssl/private/$HOSTNAME.key -out /etc/ssl/certs/$HOSTNAME.crt' >> /usr/bin/makecert
  552. echo 'openssl dhparam -check -text -5 1024 -out /etc/ssl/certs/$HOSTNAME.dhparam' >> /usr/bin/makecert
  553. echo 'chmod 400 /etc/ssl/private/$HOSTNAME.key' >> /usr/bin/makecert
  554. echo 'chmod 640 /etc/ssl/certs/$HOSTNAME.crt' >> /usr/bin/makecert
  555. echo 'chmod 640 /etc/ssl/certs/$HOSTNAME.dhparam' >> /usr/bin/makecert
  556. echo 'if [ -f /etc/init.d/nginx ]; then' >> /usr/bin/makecert
  557. echo ' /etc/init.d/nginx reload' >> /usr/bin/makecert
  558. echo 'fi' >> /usr/bin/makecert
  559. echo '# add the public certificate to a separate directory' >> /usr/bin/makecert
  560. echo '# so that we can redistribute it easily' >> /usr/bin/makecert
  561. echo 'if [ ! -d /etc/ssl/mycerts ]; then' >> /usr/bin/makecert
  562. echo ' mkdir /etc/ssl/mycerts' >> /usr/bin/makecert
  563. echo 'fi' >> /usr/bin/makecert
  564. echo 'cp /etc/ssl/certs/$HOSTNAME.crt /etc/ssl/mycerts' >> /usr/bin/makecert
  565. echo '# Create a bundle of your certificates' >> /usr/bin/makecert
  566. echo 'cat /etc/ssl/mycerts/*.crt > /etc/ssl/freedombone-bundle.crt' >> /usr/bin/makecert
  567. echo 'tar -czvf /etc/ssl/freedombone-certs.tar.gz /etc/ssl/mycerts/*.crt' >> /usr/bin/makecert
  568. chmod +x /usr/bin/makecert
  569. echo 'script_to_make_self_signed_certificates' >> $COMPLETION_FILE
  570. }
  571. function configure_email {
  572. if grep -Fxq "configure_email" $COMPLETION_FILE; then
  573. return
  574. fi
  575. apt-get -y remove postfix
  576. apt-get -y --force-yes install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
  577. echo 'dc_eximconfig_configtype="internet"' > /etc/exim4/update-exim4.conf.conf
  578. echo "dc_other_hostnames='$DOMAIN_NAME'" >> /etc/exim4/update-exim4.conf.conf
  579. echo "dc_local_interfaces=''" >> /etc/exim4/update-exim4.conf.conf
  580. echo "dc_readhost=''" >> /etc/exim4/update-exim4.conf.conf
  581. echo "dc_relay_domains=''" >> /etc/exim4/update-exim4.conf.conf
  582. echo "dc_minimaldns='false'" >> /etc/exim4/update-exim4.conf.conf
  583. echo "dc_relay_nets='192.168.1.0/24'" >> /etc/exim4/update-exim4.conf.conf
  584. echo "dc_smarthost=''" >> /etc/exim4/update-exim4.conf.conf
  585. echo "CFILEMODE='644'" >> /etc/exim4/update-exim4.conf.conf
  586. echo "dc_use_split_config='false'" >> /etc/exim4/update-exim4.conf.conf
  587. echo "dc_hide_mailname=''" >> /etc/exim4/update-exim4.conf.conf
  588. echo "dc_mailname_in_oh='true'" >> /etc/exim4/update-exim4.conf.conf
  589. echo "dc_localdelivery='maildir_home'" >> /etc/exim4/update-exim4.conf.conf
  590. update-exim4.conf
  591. sed -i "s/START=no/START=yes/g" /etc/default/saslauthd
  592. /etc/init.d/saslauthd start
  593. # make a tls certificate for email
  594. makecert exim
  595. mv /etc/ssl/private/exim.key /etc/exim4
  596. mv /etc/ssl/certs/exim.crt /etc/exim4
  597. mv /etc/ssl/certs/exim.dhparam /etc/exim4
  598. chown root:Debian-exim /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
  599. chmod 640 /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
  600. sed -i '/login_saslauthd_server/,/.endif/ s/# *//' /etc/exim4/exim4.conf.template
  601. sed -i "/.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME/i\MAIN_HARDCODE_PRIMARY_HOSTNAME = $DOMAIN_NAME\nMAIN_TLS_ENABLE = true" /etc/exim4/exim4.conf.template
  602. sed -i "s|SMTPLISTENEROPTIONS=''|SMTPLISTENEROPTIONS='-oX 465:25:587 -oP /var/run/exim4/exim.pid'|g" /etc/default/exim4
  603. if ! grep -q "tls_on_connect_ports=465" /etc/exim4/exim4.conf.template; then
  604. sed -i '/SSL configuration for exim/i\tls_on_connect_ports=465' /etc/exim4/exim4.conf.template
  605. fi
  606. adduser $MY_USERNAME sasl
  607. addgroup Debian-exim sasl
  608. /etc/init.d/exim4 restart
  609. if [ ! -d /etc/skel/Maildir ]; then
  610. mkdir -m 700 /etc/skel/Maildir
  611. mkdir -m 700 /etc/skel/Maildir/Sent
  612. mkdir -m 700 /etc/skel/Maildir/Sent/tmp
  613. mkdir -m 700 /etc/skel/Maildir/Sent/cur
  614. mkdir -m 700 /etc/skel/Maildir/Sent/new
  615. mkdir -m 700 /etc/skel/Maildir/.learn-spam
  616. mkdir -m 700 /etc/skel/Maildir/.learn-spam/cur
  617. mkdir -m 700 /etc/skel/Maildir/.learn-spam/new
  618. mkdir -m 700 /etc/skel/Maildir/.learn-spam/tmp
  619. mkdir -m 700 /etc/skel/Maildir/.learn-ham
  620. mkdir -m 700 /etc/skel/Maildir/.learn-ham/cur
  621. mkdir -m 700 /etc/skel/Maildir/.learn-ham/new
  622. mkdir -m 700 /etc/skel/Maildir/.learn-ham/tmp
  623. ln -s /etc/skel/Maildir/.learn-spam /etc/skel/Maildir/spam
  624. ln -s /etc/skel/Maildir/.learn-ham /etc/skel/Maildir/ham
  625. fi
  626. if [ ! -d /home/$MY_USERNAME/Maildir ]; then
  627. mkdir -m 700 /home/$MY_USERNAME/Maildir
  628. mkdir -m 700 /home/$MY_USERNAME/Maildir/cur
  629. mkdir -m 700 /home/$MY_USERNAME/Maildir/tmp
  630. mkdir -m 700 /home/$MY_USERNAME/Maildir/new
  631. mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent
  632. mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/cur
  633. mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/tmp
  634. mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/new
  635. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam
  636. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/cur
  637. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/new
  638. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/tmp
  639. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham
  640. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/cur
  641. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/new
  642. mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/tmp
  643. ln -s /home/$MY_USERNAME/Maildir/.learn-spam /home/$MY_USERNAME/Maildir/spam
  644. ln -s /home/$MY_USERNAME/Maildir/.learn-ham /home/$MY_USERNAME/Maildir/ham
  645. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Maildir
  646. fi
  647. echo 'configure_email' >> $COMPLETION_FILE
  648. }
  649. function spam_filtering {
  650. # NOTE: spamassassin installation currently doesn't work, sa-compile fails with a make error 23/09/2014
  651. if grep -Fxq "spam_filtering" $COMPLETION_FILE; then
  652. return
  653. fi
  654. apt-get -y --force-yes install exim4-daemon-heavy
  655. apt-get -y --force-yes install spamassassin
  656. sa-update -v
  657. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin
  658. sed -i 's/# spamd_address = 127.0.0.1 783/spamd_address = 127.0.0.1 783/g' /etc/exim4/exim4.conf.template
  659. # This configuration is based on https://wiki.debian.org/DebianSpamAssassin
  660. sed -i 's/local_parts = postmaster/local_parts = postmaster:abuse/g' /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
  661. sed -i '/domains = +local_domains : +relay_to_domains/a\ set acl_m0 = rfcnames' /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
  662. sed -i 's/accept/accept condition = ${if eq{$acl_m0}{rfcnames} {1}{0}}/g' /etc/exim4/conf.d/acl/40_exim4-config_check_data
  663. echo 'warn message = X-Spam-Score: $spam_score ($spam_bar)' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  664. echo ' spam = nobody:true' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  665. echo 'warn message = X-Spam-Flag: YES' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  666. echo ' spam = nobody' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  667. echo 'warn message = X-Spam-Report: $spam_report' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  668. echo ' spam = nobody' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  669. echo '# reject spam at high scores (> 12)' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  670. echo 'deny message = This message scored $spam_score spam points.' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  671. echo ' spam = nobody:true' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  672. echo ' condition = ${if >{$spam_score_int}{120}{1}{0}}' >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
  673. # procmail configuration
  674. echo 'MAILDIR=$HOME/Maildir' > /home/$MY_USERNAME/.procmailrc
  675. echo 'DEFAULT=$MAILDIR/' >> /home/$MY_USERNAME/.procmailrc
  676. echo 'LOGFILE=$HOME/log/procmail.log' >> /home/$MY_USERNAME/.procmailrc
  677. echo 'LOGABSTRACT=all' >> /home/$MY_USERNAME/.procmailrc
  678. echo '# get spamassassin to check emails' >> /home/$MY_USERNAME/.procmailrc
  679. echo ':0fw: .spamassassin.lock' >> /home/$MY_USERNAME/.procmailrc
  680. echo ' * < 256000' >> /home/$MY_USERNAME/.procmailrc
  681. echo '| spamc' >> /home/$MY_USERNAME/.procmailrc
  682. echo '# strong spam are discarded' >> /home/$MY_USERNAME/.procmailrc
  683. echo ':0' >> /home/$MY_USERNAME/.procmailrc
  684. echo ' * ^X-Spam-Level: \*\*\*\*\*\*' >> /home/$MY_USERNAME/.procmailrc
  685. echo '/dev/null' >> /home/$MY_USERNAME/.procmailrc
  686. echo '# weak spam are kept just in case - clear this out every now and then' >> /home/$MY_USERNAME/.procmailrc
  687. echo ':0' >> /home/$MY_USERNAME/.procmailrc
  688. echo ' * ^X-Spam-Level: \*\*\*\*\*' >> /home/$MY_USERNAME/.procmailrc
  689. echo '.0-spam/' >> /home/$MY_USERNAME/.procmailrc
  690. echo '# otherwise, marginal spam goes here for revision' >> /home/$MY_USERNAME/.procmailrc
  691. echo ':0' >> /home/$MY_USERNAME/.procmailrc
  692. echo ' * ^X-Spam-Level: \*\*' >> /home/$MY_USERNAME/.procmailrc
  693. echo '.spam/' >> /home/$MY_USERNAME/.procmailrc
  694. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.procmailrc
  695. # filtering scripts
  696. echo '#!/bin/bash' > /usr/bin/filterspam
  697. echo 'USERNAME=$1' >> /usr/bin/filterspam
  698. echo 'MAILDIR=/home/$USERNAME/Maildir/.learn-spam' >> /usr/bin/filterspam
  699. echo 'if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterspam
  700. echo ' exit' >> /usr/bin/filterspam
  701. echo 'fi' >> /usr/bin/filterspam
  702. echo 'for f in `ls $MAILDIR/cur`' >> /usr/bin/filterspam
  703. echo 'do' >> /usr/bin/filterspam
  704. echo ' spamc -L spam < "$MAILDIR/cur/$f" > /dev/null' >> /usr/bin/filterspam
  705. echo ' rm "$MAILDIR/cur/$f"' >> /usr/bin/filterspam
  706. echo 'done' >> /usr/bin/filterspam
  707. echo 'for f in `ls $MAILDIR/new`' >> /usr/bin/filterspam
  708. echo 'do' >> /usr/bin/filterspam
  709. echo ' spamc -L spam < "$MAILDIR/new/$f" > /dev/null' >> /usr/bin/filterspam
  710. echo ' rm "$MAILDIR/new/$f"' >> /usr/bin/filterspam
  711. echo 'done' >> /usr/bin/filterspam
  712. echo '#!/bin/bash' > /usr/bin/filterham
  713. echo 'USERNAME=$1' >> /usr/bin/filterham
  714. echo 'MAILDIR=/home/$USERNAME/Maildir/.learn-ham' >> /usr/bin/filterham
  715. echo 'if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterham
  716. echo ' exit' >> /usr/bin/filterham
  717. echo 'fi' >> /usr/bin/filterham
  718. echo 'for f in `ls $MAILDIR/cur`' >> /usr/bin/filterham
  719. echo 'do' >> /usr/bin/filterham
  720. echo ' spamc -L ham < "$MAILDIR/cur/$f" > /dev/null' >> /usr/bin/filterham
  721. echo ' rm "$MAILDIR/cur/$f"' >> /usr/bin/filterham
  722. echo 'done' >> /usr/bin/filterham
  723. echo 'for f in `ls $MAILDIR/new`' >> /usr/bin/filterham
  724. echo 'do' >> /usr/bin/filterham
  725. echo ' spamc -L ham < "$MAILDIR/new/$f" > /dev/null' >> /usr/bin/filterham
  726. echo ' rm "$MAILDIR/new/$f"' >> /usr/bin/filterham
  727. echo 'done' >> /usr/bin/filterham
  728. if ! grep -q "filterspam" /etc/crontab; then
  729. echo "*/3 * * * * root /usr/bin/timeout 120 /usr/bin/filterspam $MY_USERNAME" >> /etc/crontab
  730. fi
  731. if ! grep -q "filterham" /etc/crontab; then
  732. echo "*/3 * * * * root /usr/bin/timeout 120 /usr/bin/filterham $MY_USERNAME" >> /etc/crontab
  733. fi
  734. chmod 655 /usr/bin/filterspam /usr/bin/filterham
  735. sed -i 's/# use_bayes 1/use_bayes 1/g' /etc/mail/spamassassin/local.cf
  736. sed -i 's/# bayes_auto_learn 1/bayes_auto_learn 1/g' /etc/mail/spamassassin/local.cf
  737. service spamassassin restart
  738. service exim4 restart
  739. service cron restart
  740. echo 'spam_filtering' >> $COMPLETION_FILE
  741. }
  742. function configure_imap {
  743. if grep -Fxq "configure_imap" $COMPLETION_FILE; then
  744. return
  745. fi
  746. apt-get -y --force-yes install dovecot-common dovecot-imapd
  747. makecert dovecot
  748. chown root:dovecot /etc/ssl/certs/dovecot.crt
  749. chown root:dovecot /etc/ssl/private/dovecot.key
  750. chown root:dovecot /etc/ssl/private/dovecot.dhparams
  751. sed -i 's|#ssl = yes|ssl = yes|g' /etc/dovecot/conf.d/10-ssl.conf
  752. sed -i 's|ssl_cert = </etc/dovecot/dovecot.pem|ssl_cert = </etc/ssl/certs/dovecot.crt|g' /etc/dovecot/conf.d/10-ssl.conf
  753. sed -i 's|ssl_key = </etc/dovecot/private/dovecot.pem|/etc/ssl/private/dovecot.key|g' /etc/dovecot/conf.d/10-ssl.conf
  754. sed -i 's|#ssl_dh_parameters_length = 1024|ssl_dh_parameters_length = 1024|g' /etc/dovecot/conf.d/10-ssl.conf
  755. sed -i 's/#ssl_prefer_server_ciphers = no/ssl_prefer_server_ciphers = yes/g' /etc/dovecot/conf.d/10-ssl.conf
  756. echo "ssl_cipher_list = 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'" >> /etc/dovecot/conf.d/10-ssl.conf
  757. sed -i 's/#listen = *, ::/listen = */g' /etc/dovecot/dovecot.conf
  758. sed -i 's/#disable_plaintext_auth = yes/disable_plaintext_auth = no/g' /etc/dovecot/conf.d/10-auth.conf
  759. sed -i 's/auth_mechanisms = plain/auth_mechanisms = plain login/g' /etc/dovecot/conf.d/10-auth.conf
  760. sed -i 's|# mail_location = maildir:~/Maildir| mail_location = maildir:~/Maildir:LAYOUT=fs|g' /etc/dovecot/conf.d/10-mail.conf
  761. echo 'configure_imap' >> $COMPLETION_FILE
  762. }
  763. function configure_gpg {
  764. if grep -Fxq "configure_gpg" $COMPLETION_FILE; then
  765. return
  766. fi
  767. apt-get -y install gnupg
  768. if [ ! -d /home/$MY_USERNAME/.gnupg ]; then
  769. mkdir /home/$MY_USERNAME/.gnupg
  770. echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf
  771. echo 'keyserver-options auto-key-retrieve' >> /home/$MY_USERNAME/.gnupg/gpg.conf
  772. fi
  773. sed -i "s|keyserver hkp://keys.gnupg.net|keyserver $GPG_KEYSERVER|g" /home/$MY_USERNAME/.gnupg/gpg.conf
  774. if grep -q "# default preferences" /home/$MY_USERNAME/.gnupg/gpg.conf; then
  775. echo '' >> /home/$MY_USERNAME/.gnupg/gpg.conf
  776. echo '# default preferences' >> /home/$MY_USERNAME/.gnupg/gpg.conf
  777. echo 'personal-digest-preferences SHA256' >> /home/$MY_USERNAME/.gnupg/gpg.conf
  778. echo 'cert-digest-algo SHA256' >> /home/$MY_USERNAME/.gnupg/gpg.conf
  779. echo 'default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed' >> /home/$MY_USERNAME/.gnupg/gpg.conf
  780. fi
  781. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
  782. echo 'configure_gpg' >> $COMPLETION_FILE
  783. }
  784. function email_client {
  785. if grep -Fxq "email_client" $COMPLETION_FILE; then
  786. return
  787. fi
  788. apt-get -y --force-yes install mutt-patched lynx abook
  789. if [ ! -d /home/$MY_USERNAME/.mutt ]; then
  790. mkdir /home/$MY_USERNAME/.mutt
  791. fi
  792. echo "text/html; lynx -dump -width=78 -nolist %s | sed ‘s/^ //’; copiousoutput; needsterminal; nametemplate=%s.html" > /home/$MY_USERNAME/.mutt/mailcap
  793. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.mutt
  794. echo 'set mbox_type=Maildir' >> /etc/Muttrc
  795. echo 'set folder="~/Maildir"' >> /etc/Muttrc
  796. echo 'set mask="!^\\.[^.]"' >> /etc/Muttrc
  797. echo 'set mbox="~/Maildir"' >> /etc/Muttrc
  798. echo 'set record="+Sent"' >> /etc/Muttrc
  799. echo 'set postponed="+Drafts"' >> /etc/Muttrc
  800. echo 'set trash="+Trash"' >> /etc/Muttrc
  801. echo 'set spoolfile="~/Maildir"' >> /etc/Muttrc
  802. echo 'auto_view text/x-vcard text/html text/enriched' >> /etc/Muttrc
  803. echo 'set editor="emacs"' >> /etc/Muttrc
  804. echo 'set header_cache="+.cache"' >> /etc/Muttrc
  805. echo '' >> /etc/Muttrc
  806. echo 'macro index S "<tag-prefix><save-message>=.learn-spam<enter>" "move to learn-spam"' >> /etc/Muttrc
  807. echo 'macro pager S "<save-message>=.learn-spam<enter>" "move to learn-spam"' >> /etc/Muttrc
  808. echo 'macro index H "<tag-prefix><copy-message>=.learn-ham<enter>" "copy to learn-ham"' >> /etc/Muttrc
  809. echo 'macro pager H "<copy-message>=.learn-ham<enter>" "copy to learn-ham"' >> /etc/Muttrc
  810. echo '' >> /etc/Muttrc
  811. echo '# set up the sidebar' >> /etc/Muttrc
  812. echo 'set sidebar_width=12' >> /etc/Muttrc
  813. echo 'set sidebar_visible=yes' >> /etc/Muttrc
  814. echo "set sidebar_delim='|'" >> /etc/Muttrc
  815. echo 'set sidebar_sort=yes' >> /etc/Muttrc
  816. echo '' >> /etc/Muttrc
  817. echo 'set rfc2047_parameters' >> /etc/Muttrc
  818. echo '' >> /etc/Muttrc
  819. echo '# Show inbox and sent items' >> /etc/Muttrc
  820. echo 'mailboxes = =Sent' >> /etc/Muttrc
  821. echo '' >> /etc/Muttrc
  822. echo '# Alter these colours as needed for maximum bling' >> /etc/Muttrc
  823. echo 'color sidebar_new yellow default' >> /etc/Muttrc
  824. echo 'color normal white default' >> /etc/Muttrc
  825. echo 'color hdrdefault brightcyan default' >> /etc/Muttrc
  826. echo 'color signature green default' >> /etc/Muttrc
  827. echo 'color attachment brightyellow default' >> /etc/Muttrc
  828. echo 'color quoted green default' >> /etc/Muttrc
  829. echo 'color quoted1 white default' >> /etc/Muttrc
  830. echo 'color tilde blue default' >> /etc/Muttrc
  831. echo '' >> /etc/Muttrc
  832. echo '# ctrl-n, ctrl-p to select next, prev folder' >> /etc/Muttrc
  833. echo '# ctrl-o to open selected folder' >> /etc/Muttrc
  834. echo 'bind index \Cp sidebar-prev' >> /etc/Muttrc
  835. echo 'bind index \Cn sidebar-next' >> /etc/Muttrc
  836. echo 'bind index \Co sidebar-open' >> /etc/Muttrc
  837. echo 'bind pager \Cp sidebar-prev' >> /etc/Muttrc
  838. echo 'bind pager \Cn sidebar-next' >> /etc/Muttrc
  839. echo 'bind pager \Co sidebar-open' >> /etc/Muttrc
  840. echo '' >> /etc/Muttrc
  841. echo '# ctrl-b toggles sidebar visibility' >> /etc/Muttrc
  842. echo "macro index,pager \Cb '<enter-command>toggle sidebar_visible<enter><redraw-screen>' 'toggle sidebar'" >> /etc/Muttrc
  843. echo '' >> /etc/Muttrc
  844. echo '# esc-m Mark new messages as read' >> /etc/Muttrc
  845. echo 'macro index <esc>m "T~N<enter>;WNT~O<enter>;WO\CT~T<enter>" "mark all messages read"' >> /etc/Muttrc
  846. echo '' >> /etc/Muttrc
  847. echo '# Collapsing threads' >> /etc/Muttrc
  848. echo 'macro index [ "<collapse-thread>" "collapse/uncollapse thread"' >> /etc/Muttrc
  849. echo 'macro index ] "<collapse-all>" "collapse/uncollapse all threads"' >> /etc/Muttrc
  850. echo '' >> /etc/Muttrc
  851. echo '# threads containing new messages' >> /etc/Muttrc
  852. echo 'uncolor index "~(~N)"' >> /etc/Muttrc
  853. echo 'color index brightblue default "~(~N)"' >> /etc/Muttrc
  854. echo '' >> /etc/Muttrc
  855. echo '# new messages themselves' >> /etc/Muttrc
  856. echo 'uncolor index "~N"' >> /etc/Muttrc
  857. echo 'color index brightyellow default "~N"' >> /etc/Muttrc
  858. echo '' >> /etc/Muttrc
  859. echo '# GPG/PGP integration' >> /etc/Muttrc
  860. echo '# this set the number of seconds to keep in memory the passphrase used to encrypt/sign' >> /etc/Muttrc
  861. echo 'set pgp_timeout=60' >> /etc/Muttrc
  862. echo '' >> /etc/Muttrc
  863. echo '# automatically sign and encrypt with PGP/MIME' >> /etc/Muttrc
  864. echo 'set pgp_autosign # autosign all outgoing mails' >> /etc/Muttrc
  865. echo 'set pgp_replyencrypt # autocrypt replies to crypted' >> /etc/Muttrc
  866. echo 'set pgp_replysign # autosign replies to signed' >> /etc/Muttrc
  867. echo 'set pgp_auto_decode=yes # decode attachments' >> /etc/Muttrc
  868. echo 'unset smime_is_default' >> /etc/Muttrc
  869. echo '' >> /etc/Muttrc
  870. echo 'set alias_file=~/.mutt-alias' >> /etc/Muttrc
  871. echo 'source ~/.mutt-alias' >> /etc/Muttrc
  872. echo 'set query_command= "abook --mutt-query \"%s\""' >> /etc/Muttrc
  873. echo 'macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"' >> /etc/Muttrc
  874. cp -f /etc/Muttrc /home/$MY_USERNAME/.muttrc
  875. touch /home/$MY_USERNAME/.mutt-alias
  876. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.muttrc
  877. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.mutt-alias
  878. echo 'email_client' >> $COMPLETION_FILE
  879. }
  880. function folders_for_mailing_lists {
  881. if grep -Fxq "folders_for_mailing_lists" $COMPLETION_FILE; then
  882. return
  883. fi
  884. echo '#!/bin/bash' > /usr/bin/mailinglistrule
  885. echo 'MYUSERNAME=$1' >> /usr/bin/mailinglistrule
  886. echo 'MAILINGLIST=$2' >> /usr/bin/mailinglistrule
  887. echo 'SUBJECTTAG=$3' >> /usr/bin/mailinglistrule
  888. echo 'MUTTRC=/home/$MYUSERNAME/.muttrc' >> /usr/bin/mailinglistrule
  889. echo 'PM=/home/$MYUSERNAME/.procmailrc' >> /usr/bin/mailinglistrule
  890. echo 'LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST' >> /usr/bin/mailinglistrule
  891. echo 'if [ ! -d "$LISTDIR" ]; then' >> /usr/bin/mailinglistrule
  892. echo ' mkdir -m 700 $LISTDIR' >> /usr/bin/mailinglistrule
  893. echo ' mkdir -m 700 $LISTDIR/tmp' >> /usr/bin/mailinglistrule
  894. echo ' mkdir -m 700 $LISTDIR/new' >> /usr/bin/mailinglistrule
  895. echo ' mkdir -m 700 $LISTDIR/cur' >> /usr/bin/mailinglistrule
  896. echo 'fi' >> /usr/bin/mailinglistrule
  897. echo 'chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR' >> /usr/bin/mailinglistrule
  898. echo 'echo "" >> $PM' >> /usr/bin/mailinglistrule
  899. echo 'echo ":0" >> $PM' >> /usr/bin/mailinglistrule
  900. echo 'echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM' >> /usr/bin/mailinglistrule
  901. echo 'echo "$LISTDIR/new" >> $PM' >> /usr/bin/mailinglistrule
  902. echo 'chown $MYUSERNAME:$MYUSERNAME $PM' >> /usr/bin/mailinglistrule
  903. echo 'if [ ! -f "$MUTTRC" ]; then' >> /usr/bin/mailinglistrule
  904. echo ' cp /etc/Muttrc $MUTTRC' >> /usr/bin/mailinglistrule
  905. echo ' chown $MYUSERNAME:$MYUSERNAME $MUTTRC' >> /usr/bin/mailinglistrule
  906. echo 'fi' >> /usr/bin/mailinglistrule
  907. echo 'PROCMAILLOG=/home/$MYUSERNAME/log' >> /usr/bin/mailinglistrule
  908. echo 'if [ ! -d $PROCMAILLOG ]; then' >> /usr/bin/mailinglistrule
  909. echo ' mkdir $PROCMAILLOG' >> /usr/bin/mailinglistrule
  910. echo ' chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG' >> /usr/bin/mailinglistrule
  911. echo 'fi' >> /usr/bin/mailinglistrule
  912. chmod +x /usr/bin/mailinglistrule
  913. echo 'folders_for_mailing_lists' >> $COMPLETION_FILE
  914. }
  915. function folders_for_email_addresses {
  916. if grep -Fxq "folders_for_email_addresses" $COMPLETION_FILE; then
  917. return
  918. fi
  919. echo '#!/bin/bash' > /usr/bin/emailrule
  920. echo 'MYUSERNAME=$1' >> /usr/bin/emailrule
  921. echo 'EMAILADDRESS=$2' >> /usr/bin/emailrule
  922. echo 'MAILINGLIST=$3' >> /usr/bin/emailrule
  923. echo 'MUTTRC=/home/$MYUSERNAME/.muttrc' >> /usr/bin/emailrule
  924. echo 'PM=/home/$MYUSERNAME/.procmailrc' >> /usr/bin/emailrule
  925. echo 'LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST' >> /usr/bin/emailrule
  926. echo 'if [ ! -d "$LISTDIR" ]; then' >> /usr/bin/emailrule
  927. echo ' mkdir -m 700 $LISTDIR' >> /usr/bin/emailrule
  928. echo ' mkdir -m 700 $LISTDIR/tmp' >> /usr/bin/emailrule
  929. echo ' mkdir -m 700 $LISTDIR/new' >> /usr/bin/emailrule
  930. echo ' mkdir -m 700 $LISTDIR/cur' >> /usr/bin/emailrule
  931. echo 'fi' >> /usr/bin/emailrule
  932. echo 'chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR' >> /usr/bin/emailrule
  933. echo 'echo "" >> $PM' >> /usr/bin/emailrule
  934. echo 'echo ":0" >> $PM' >> /usr/bin/emailrule
  935. echo 'echo " * ^From: $EMAILADDRESS" >> $PM' >> /usr/bin/emailrule
  936. echo 'echo "$LISTDIR/new" >> $PM' >> /usr/bin/emailrule
  937. echo 'chown $MYUSERNAME:$MYUSERNAME $PM' >> /usr/bin/emailrule
  938. echo 'if [ ! -f "$MUTTRC" ]; then' >> /usr/bin/emailrule
  939. echo ' cp /etc/Muttrc $MUTTRC' >> /usr/bin/emailrule
  940. echo ' chown $MYUSERNAME:$MYUSERNAME $MUTTRC' >> /usr/bin/emailrule
  941. echo 'fi' >> /usr/bin/emailrule
  942. echo 'PROCMAILLOG=/home/$MYUSERNAME/log' >> /usr/bin/emailrule
  943. echo 'if [ ! -d $PROCMAILLOG ]; then' >> /usr/bin/emailrule
  944. echo ' mkdir $PROCMAILLOG' >> /usr/bin/emailrule
  945. echo ' chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG' >> /usr/bin/emailrule
  946. echo 'fi' >> /usr/bin/emailrule
  947. chmod +x /usr/bin/emailrule
  948. echo 'folders_for_email_addresses' >> $COMPLETION_FILE
  949. }
  950. function dynamic_dns_freedns {
  951. if grep -Fxq "dynamic_dns_freedns" $COMPLETION_FILE; then
  952. return
  953. fi
  954. echo '#!/bin/bash' > /usr/bin/dynamicdns
  955. echo '# subdomain name 1' >> /usr/bin/dynamicdns
  956. echo "wget -O - https://freedns.afraid.org/dynamic/update.php?$FREEDNS_SUBDOMAIN_CODE== >> /dev/null 2>&1" >> /usr/bin/dynamicdns
  957. echo '# add any other subdomains below' >> /usr/bin/dynamicdns
  958. chmod 600 /usr/bin/dynamicdns
  959. chmod +x /usr/bin/dynamicdns
  960. if ! grep -q "dynamicdns" /etc/crontab; then
  961. sed -i '/# m h dom mon dow user command/a\*/5 * * * * root /usr/bin/timeout 240 /usr/bin/dynamicdns' /etc/crontab
  962. fi
  963. service cron restart
  964. echo 'dynamic_dns_freedns' >> $COMPLETION_FILE
  965. }
  966. function install_final {
  967. if grep -Fxq "install_final" $COMPLETION_FILE; then
  968. return
  969. fi
  970. echo 'install_final' >> $COMPLETION_FILE
  971. echo ''
  972. echo ' *** Freedombone installation is complete. Rebooting... ***'
  973. echo ''
  974. reboot
  975. }
  976. argument_checks
  977. configure_firewall
  978. configure_firewall_for_ssh
  979. configure_firewall_for_dns
  980. configure_firewall_for_ftp
  981. configure_firewall_for_web
  982. remove_proprietary_repos
  983. change_debian_repos
  984. enable_backports
  985. configure_dns
  986. initial_setup
  987. install_editor
  988. change_login_message
  989. update_the_kernel
  990. enable_zram
  991. random_number_generator
  992. set_your_domain_name
  993. time_synchronisation
  994. configure_internet_protocol
  995. configure_ssh
  996. regenerate_ssh_keys
  997. script_to_make_self_signed_certificates
  998. configure_email
  999. spam_filtering
  1000. configure_imap
  1001. configure_gpg
  1002. email_client
  1003. configure_firewall_for_email
  1004. folders_for_mailing_lists
  1005. folders_for_email_addresses
  1006. dynamic_dns_freedns
  1007. install_final
  1008. echo 'Freedombone installation is complete'