Browse Source

gpg key generation

Bob Mottram 10 years ago
parent
commit
245a43c40c
1 changed files with 91 additions and 88 deletions
  1. 91
    88
      install-freedombone.sh

+ 91
- 88
install-freedombone.sh View File

88
 # File which keeps track of what has already been installed
88
 # File which keeps track of what has already been installed
89
 COMPLETION_FILE=/root/freedombone-completed.txt
89
 COMPLETION_FILE=/root/freedombone-completed.txt
90
 if [ ! -f $COMPLETION_FILE ]; then
90
 if [ ! -f $COMPLETION_FILE ]; then
91
-	touch $COMPLETION_FILE
91
+    touch $COMPLETION_FILE
92
 fi
92
 fi
93
 
93
 
94
 function argument_checks {
94
 function argument_checks {
95
   SYNTAX='./install-freedombone.sh [domain] [username] [subdomain code]'
95
   SYNTAX='./install-freedombone.sh [domain] [username] [subdomain code]'
96
   if [ ! -d /home/$MY_USERNAME ]; then
96
   if [ ! -d /home/$MY_USERNAME ]; then
97
-	  echo "There is no user '$MY_USERNAME' on the system. Use 'adduser $MY_USERNAME' to create the user."
98
-	  exit 1
97
+      echo "There is no user '$MY_USERNAME' on the system. Use 'adduser $MY_USERNAME' to create the user."
98
+      exit 1
99
   fi
99
   fi
100
   if [ ! $DOMAIN_NAME ]; then
100
   if [ ! $DOMAIN_NAME ]; then
101
       echo ''
101
       echo ''
102
-	  echo $SYNTAX
103
-	  echo 'Please specify your domain name'
104
-	  exit 2
102
+      echo $SYNTAX
103
+      echo 'Please specify your domain name'
104
+      exit 2
105
   fi
105
   fi
106
   if [ ! $MY_USERNAME ]; then
106
   if [ ! $MY_USERNAME ]; then
107
       echo ''
107
       echo ''
108
-	  echo $SYNTAX
109
-	  echo 'Please specify your username'
110
-	  exit 3
108
+      echo $SYNTAX
109
+      echo 'Please specify your username'
110
+      exit 3
111
   fi
111
   fi
112
   if [ ! $FREEDNS_SUBDOMAIN_CODE ]; then
112
   if [ ! $FREEDNS_SUBDOMAIN_CODE ]; then
113
       echo ''
113
       echo ''
114
-	  echo $SYNTAX
114
+      echo $SYNTAX
115
       echo 'Please specify the freedns subdomain code.  To find it from '
115
       echo 'Please specify the freedns subdomain code.  To find it from '
116
       echo "https://freedns.afraid.org select 'Dynamic DNS', then 'quick "
116
       echo "https://freedns.afraid.org select 'Dynamic DNS', then 'quick "
117
       echo "cron example' and copy the code located between '?' and '=='."
117
       echo "cron example' and copy the code located between '?' and '=='."
118
-	  exit 4
118
+      exit 4
119
   fi
119
   fi
120
 }
120
 }
121
 
121
 
122
 function change_login_message {
122
 function change_login_message {
123
   if grep -Fxq "change_login_message" $COMPLETION_FILE; then
123
   if grep -Fxq "change_login_message" $COMPLETION_FILE; then
124
-	  return
124
+      return
125
   fi
125
   fi
126
   echo '' > /etc/motd
126
   echo '' > /etc/motd
127
   echo ".---.                  .              .                   " >> /etc/motd
127
   echo ".---.                  .              .                   " >> /etc/motd
137
 
137
 
138
 function remove_proprietary_repos {
138
 function remove_proprietary_repos {
139
   if grep -Fxq "remove_proprietary_repos" $COMPLETION_FILE; then
139
   if grep -Fxq "remove_proprietary_repos" $COMPLETION_FILE; then
140
-	  return
140
+      return
141
   fi
141
   fi
142
   sed -i 's/ non-free//g' /etc/apt/sources.list
142
   sed -i 's/ non-free//g' /etc/apt/sources.list
143
   echo 'remove_proprietary_repos' >> $COMPLETION_FILE
143
   echo 'remove_proprietary_repos' >> $COMPLETION_FILE
145
 
145
 
146
 function change_debian_repos {
146
 function change_debian_repos {
147
   if grep -Fxq "change_debian_repos" $COMPLETION_FILE; then
147
   if grep -Fxq "change_debian_repos" $COMPLETION_FILE; then
148
-	  return
148
+      return
149
   fi
149
   fi
150
   rm -rf /var/lib/apt/lists/*
150
   rm -rf /var/lib/apt/lists/*
151
   apt-get clean
151
   apt-get clean
156
       if grep -q "jessie" /etc/apt/sources.list; then
156
       if grep -q "jessie" /etc/apt/sources.list; then
157
           echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
157
           echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
158
           echo "#deb-src http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
158
           echo "#deb-src http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
159
-	  else
159
+      else
160
           if grep -q "wheezy" /etc/apt/sources.list; then
160
           if grep -q "wheezy" /etc/apt/sources.list; then
161
               echo "deb http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
161
               echo "deb http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
162
               echo "#deb-src http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
162
               echo "#deb-src http://security.debian.org/ wheezy/updates main contrib" >> /etc/apt/sources.list
163
-		  fi
164
-	  fi
163
+          fi
164
+      fi
165
   fi
165
   fi
166
 
166
 
167
   apt-get update
167
   apt-get update
171
 
171
 
172
 function initial_setup {
172
 function initial_setup {
173
   if grep -Fxq "initial_setup" $COMPLETION_FILE; then
173
   if grep -Fxq "initial_setup" $COMPLETION_FILE; then
174
-	  return
174
+      return
175
   fi
175
   fi
176
   apt-get -y remove --purge apache*
176
   apt-get -y remove --purge apache*
177
   apt-get -y dist-upgrade
177
   apt-get -y dist-upgrade
181
 
181
 
182
 function install_editor {
182
 function install_editor {
183
   if grep -Fxq "install_editor" $COMPLETION_FILE; then
183
   if grep -Fxq "install_editor" $COMPLETION_FILE; then
184
-	  return
184
+      return
185
   fi
185
   fi
186
   update-alternatives --set editor /usr/bin/emacs24
186
   update-alternatives --set editor /usr/bin/emacs24
187
   echo 'install_editor' >> $COMPLETION_FILE
187
   echo 'install_editor' >> $COMPLETION_FILE
189
 
189
 
190
 function enable_backports {
190
 function enable_backports {
191
   if grep -Fxq "enable_backports" $COMPLETION_FILE; then
191
   if grep -Fxq "enable_backports" $COMPLETION_FILE; then
192
-	  return
192
+      return
193
   fi
193
   fi
194
   if ! grep -Fxq "deb http://$DEBIAN_REPO/debian jessie-backports main" /etc/apt/sources.list; then
194
   if ! grep -Fxq "deb http://$DEBIAN_REPO/debian jessie-backports main" /etc/apt/sources.list; then
195
     echo "deb http://$DEBIAN_REPO/debian jessie-backports main" >> /etc/apt/sources.list
195
     echo "deb http://$DEBIAN_REPO/debian jessie-backports main" >> /etc/apt/sources.list
199
 
199
 
200
 function update_the_kernel {
200
 function update_the_kernel {
201
   if grep -Fxq "update_the_kernel" $COMPLETION_FILE; then
201
   if grep -Fxq "update_the_kernel" $COMPLETION_FILE; then
202
-	  return
202
+      return
203
   fi
203
   fi
204
   cd /opt/scripts/tools
204
   cd /opt/scripts/tools
205
   ./update_kernel.sh --kernel $KERNEL_VERSION
205
   ./update_kernel.sh --kernel $KERNEL_VERSION
208
 
208
 
209
 function enable_zram {
209
 function enable_zram {
210
   if grep -Fxq "enable_zram" $COMPLETION_FILE; then
210
   if grep -Fxq "enable_zram" $COMPLETION_FILE; then
211
-	  return
211
+      return
212
   fi
212
   fi
213
   if ! grep -q "options zram num_devices=1" /etc/modprobe.d/zram.conf; then
213
   if ! grep -q "options zram num_devices=1" /etc/modprobe.d/zram.conf; then
214
       echo 'options zram num_devices=1' >> /etc/modprobe.d/zram.conf
214
       echo 'options zram num_devices=1' >> /etc/modprobe.d/zram.conf
287
 
287
 
288
 function random_number_generator {
288
 function random_number_generator {
289
   if grep -Fxq "random_number_generator" $COMPLETION_FILE; then
289
   if grep -Fxq "random_number_generator" $COMPLETION_FILE; then
290
-	  return
290
+      return
291
   fi
291
   fi
292
   if [ $USE_HWRNG == "yes" ]; then
292
   if [ $USE_HWRNG == "yes" ]; then
293
     apt-get -y --force-yes install rng-tools
293
     apt-get -y --force-yes install rng-tools
294
     sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools
294
     sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools
295
   else
295
   else
296
-	apt-get -y --force-yes install haveged
296
+    apt-get -y --force-yes install haveged
297
   fi
297
   fi
298
   echo 'random_number_generator' >> $COMPLETION_FILE
298
   echo 'random_number_generator' >> $COMPLETION_FILE
299
 }
299
 }
300
 
300
 
301
 function configure_ssh {
301
 function configure_ssh {
302
   if grep -Fxq "configure_ssh" $COMPLETION_FILE; then
302
   if grep -Fxq "configure_ssh" $COMPLETION_FILE; then
303
-	  return
303
+      return
304
   fi
304
   fi
305
   sed -i "s/Port 22/Port $SSH_PORT/g" /etc/ssh/sshd_config
305
   sed -i "s/Port 22/Port $SSH_PORT/g" /etc/ssh/sshd_config
306
   sed -i 's/PermitRootLogin without-password/PermitRootLogin no/g' /etc/ssh/sshd_config
306
   sed -i 's/PermitRootLogin without-password/PermitRootLogin no/g' /etc/ssh/sshd_config
327
 
327
 
328
 function regenerate_ssh_keys {
328
 function regenerate_ssh_keys {
329
   if grep -Fxq "regenerate_ssh_keys" $COMPLETION_FILE; then
329
   if grep -Fxq "regenerate_ssh_keys" $COMPLETION_FILE; then
330
-	  return
330
+      return
331
   fi
331
   fi
332
   rm -f /etc/ssh/ssh_host_*
332
   rm -f /etc/ssh/ssh_host_*
333
   dpkg-reconfigure openssh-server
333
   dpkg-reconfigure openssh-server
337
 
337
 
338
 function configure_dns {
338
 function configure_dns {
339
   if grep -Fxq "configure_dns" $COMPLETION_FILE; then
339
   if grep -Fxq "configure_dns" $COMPLETION_FILE; then
340
-	  return
340
+      return
341
   fi
341
   fi
342
   echo 'domain localdomain' > /etc/resolv.conf
342
   echo 'domain localdomain' > /etc/resolv.conf
343
   echo 'search localdomain' >> /etc/resolv.conf
343
   echo 'search localdomain' >> /etc/resolv.conf
348
 
348
 
349
 function set_your_domain_name {
349
 function set_your_domain_name {
350
   if grep -Fxq "set_your_domain_name" $COMPLETION_FILE; then
350
   if grep -Fxq "set_your_domain_name" $COMPLETION_FILE; then
351
-	  return
351
+      return
352
   fi
352
   fi
353
   echo "$DOMAIN_NAME" > /etc/hostname
353
   echo "$DOMAIN_NAME" > /etc/hostname
354
   hostname $DOMAIN_NAME
354
   hostname $DOMAIN_NAME
359
 
359
 
360
 function time_synchronisation {
360
 function time_synchronisation {
361
   if grep -Fxq "time_synchronisation" $COMPLETION_FILE; then
361
   if grep -Fxq "time_synchronisation" $COMPLETION_FILE; then
362
-	  return
362
+      return
363
   fi
363
   fi
364
   apt-get -y --force-yes install tlsdate
364
   apt-get -y --force-yes install tlsdate
365
   apt-get -y remove ntpdate
365
   apt-get -y remove ntpdate
474
 
474
 
475
 function configure_firewall {
475
 function configure_firewall {
476
   if grep -Fxq "configure_firewall" $COMPLETION_FILE; then
476
   if grep -Fxq "configure_firewall" $COMPLETION_FILE; then
477
-	  return
477
+      return
478
   fi
478
   fi
479
   iptables -P INPUT ACCEPT
479
   iptables -P INPUT ACCEPT
480
   ip6tables -P INPUT ACCEPT
480
   ip6tables -P INPUT ACCEPT
500
 
500
 
501
 function configure_firewall_for_dns {
501
 function configure_firewall_for_dns {
502
   if grep -Fxq "configure_firewall_for_dns" $COMPLETION_FILE; then
502
   if grep -Fxq "configure_firewall_for_dns" $COMPLETION_FILE; then
503
-	  return
503
+      return
504
   fi
504
   fi
505
   iptables -A INPUT -i eth0 -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
505
   iptables -A INPUT -i eth0 -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
506
   save_firewall_settings
506
   save_firewall_settings
509
 
509
 
510
 function configure_firewall_for_ftp {
510
 function configure_firewall_for_ftp {
511
   if grep -Fxq "configure_firewall_for_ftp" $COMPLETION_FILE; then
511
   if grep -Fxq "configure_firewall_for_ftp" $COMPLETION_FILE; then
512
-	  return
512
+      return
513
   fi
513
   fi
514
   iptables -I INPUT -i eth0 -p tcp --dport 1024:65535 --sport 20:21 -j ACCEPT
514
   iptables -I INPUT -i eth0 -p tcp --dport 1024:65535 --sport 20:21 -j ACCEPT
515
   save_firewall_settings
515
   save_firewall_settings
518
 
518
 
519
 function configure_firewall_for_web {
519
 function configure_firewall_for_web {
520
   if grep -Fxq "configure_firewall_for_web" $COMPLETION_FILE; then
520
   if grep -Fxq "configure_firewall_for_web" $COMPLETION_FILE; then
521
-	  return
521
+      return
522
   fi
522
   fi
523
   iptables -A INPUT -i eth0 -p tcp --dport 32768:61000 --sport 80 -j ACCEPT
523
   iptables -A INPUT -i eth0 -p tcp --dport 32768:61000 --sport 80 -j ACCEPT
524
   iptables -A INPUT -i eth0 -p tcp --dport 32768:61000 --sport 443 -j ACCEPT
524
   iptables -A INPUT -i eth0 -p tcp --dport 32768:61000 --sport 443 -j ACCEPT
528
 
528
 
529
 function configure_firewall_for_ssh {
529
 function configure_firewall_for_ssh {
530
   if grep -Fxq "configure_firewall_for_ssh" $COMPLETION_FILE; then
530
   if grep -Fxq "configure_firewall_for_ssh" $COMPLETION_FILE; then
531
-	  return
531
+      return
532
   fi
532
   fi
533
   iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
533
   iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
534
   iptables -A INPUT -i eth0 -p tcp --dport $SSH_PORT -j ACCEPT
534
   iptables -A INPUT -i eth0 -p tcp --dport $SSH_PORT -j ACCEPT
538
 
538
 
539
 function configure_firewall_for_git {
539
 function configure_firewall_for_git {
540
   if grep -Fxq "configure_firewall_for_git" $COMPLETION_FILE; then
540
   if grep -Fxq "configure_firewall_for_git" $COMPLETION_FILE; then
541
-	  return
541
+      return
542
   fi
542
   fi
543
   iptables -A INPUT -i eth0 -p tcp --dport 9418 -j ACCEPT
543
   iptables -A INPUT -i eth0 -p tcp --dport 9418 -j ACCEPT
544
   save_firewall_settings
544
   save_firewall_settings
547
 
547
 
548
 function configure_firewall_for_email {
548
 function configure_firewall_for_email {
549
   if grep -Fxq "configure_firewall_for_email" $COMPLETION_FILE; then
549
   if grep -Fxq "configure_firewall_for_email" $COMPLETION_FILE; then
550
-	  return
550
+      return
551
   fi
551
   fi
552
   iptables -A INPUT -i eth0 -p tcp --dport 25 -j ACCEPT
552
   iptables -A INPUT -i eth0 -p tcp --dport 25 -j ACCEPT
553
   iptables -A INPUT -i eth0 -p tcp --dport 587 -j ACCEPT
553
   iptables -A INPUT -i eth0 -p tcp --dport 587 -j ACCEPT
559
 
559
 
560
 function configure_internet_protocol {
560
 function configure_internet_protocol {
561
   if grep -Fxq "configure_internet_protocol" $COMPLETION_FILE; then
561
   if grep -Fxq "configure_internet_protocol" $COMPLETION_FILE; then
562
-	  return
562
+      return
563
   fi
563
   fi
564
   sed -i "s/#net.ipv4.tcp_syncookies=1/net.ipv4.tcp_syncookies=1/g" /etc/sysctl.conf
564
   sed -i "s/#net.ipv4.tcp_syncookies=1/net.ipv4.tcp_syncookies=1/g" /etc/sysctl.conf
565
   sed -i "s/#net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 0/g" /etc/sysctl.conf
565
   sed -i "s/#net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 0/g" /etc/sysctl.conf
587
 
587
 
588
 function script_to_make_self_signed_certificates {
588
 function script_to_make_self_signed_certificates {
589
   if grep -Fxq "script_to_make_self_signed_certificates" $COMPLETION_FILE; then
589
   if grep -Fxq "script_to_make_self_signed_certificates" $COMPLETION_FILE; then
590
-	  return
590
+      return
591
   fi
591
   fi
592
   echo '#!/bin/bash' > /usr/bin/makecert
592
   echo '#!/bin/bash' > /usr/bin/makecert
593
   echo 'HOSTNAME=$1' >> /usr/bin/makecert
593
   echo 'HOSTNAME=$1' >> /usr/bin/makecert
623
 
623
 
624
 function configure_email {
624
 function configure_email {
625
   if grep -Fxq "configure_email" $COMPLETION_FILE; then
625
   if grep -Fxq "configure_email" $COMPLETION_FILE; then
626
-	  return
626
+      return
627
   fi
627
   fi
628
   apt-get -y remove postfix
628
   apt-get -y remove postfix
629
   apt-get -y --force-yes install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
629
   apt-get -y --force-yes install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
687
     mkdir -m 700 /home/$MY_USERNAME/Maildir/new
687
     mkdir -m 700 /home/$MY_USERNAME/Maildir/new
688
     mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent
688
     mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent
689
     mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/cur
689
     mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/cur
690
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/tmp
691
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/new
692
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam
693
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/cur
694
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/new
695
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/tmp
696
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham
697
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/cur
698
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/new
699
-	mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/tmp
700
-	ln -s /home/$MY_USERNAME/Maildir/.learn-spam /home/$MY_USERNAME/Maildir/spam
701
-	ln -s /home/$MY_USERNAME/Maildir/.learn-ham /home/$MY_USERNAME/Maildir/ham
702
-	chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Maildir
690
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/tmp
691
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/Sent/new
692
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam
693
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/cur
694
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/new
695
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-spam/tmp
696
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham
697
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/cur
698
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/new
699
+    mkdir -m 700 /home/$MY_USERNAME/Maildir/.learn-ham/tmp
700
+    ln -s /home/$MY_USERNAME/Maildir/.learn-spam /home/$MY_USERNAME/Maildir/spam
701
+    ln -s /home/$MY_USERNAME/Maildir/.learn-ham /home/$MY_USERNAME/Maildir/ham
702
+    chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Maildir
703
   fi
703
   fi
704
   echo 'configure_email' >> $COMPLETION_FILE
704
   echo 'configure_email' >> $COMPLETION_FILE
705
 }
705
 }
707
 function spam_filtering {
707
 function spam_filtering {
708
   # NOTE: spamassassin installation currently doesn't work, sa-compile fails with a make error 23/09/2014
708
   # NOTE: spamassassin installation currently doesn't work, sa-compile fails with a make error 23/09/2014
709
   if grep -Fxq "spam_filtering" $COMPLETION_FILE; then
709
   if grep -Fxq "spam_filtering" $COMPLETION_FILE; then
710
-	  return
710
+      return
711
   fi
711
   fi
712
   apt-get -y --force-yes install exim4-daemon-heavy
712
   apt-get -y --force-yes install exim4-daemon-heavy
713
   apt-get -y --force-yes install spamassassin
713
   apt-get -y --force-yes install spamassassin
803
 
803
 
804
 function configure_imap {
804
 function configure_imap {
805
   if grep -Fxq "configure_imap" $COMPLETION_FILE; then
805
   if grep -Fxq "configure_imap" $COMPLETION_FILE; then
806
-	  return
806
+      return
807
   fi
807
   fi
808
   apt-get -y --force-yes install dovecot-common dovecot-imapd
808
   apt-get -y --force-yes install dovecot-common dovecot-imapd
809
   makecert dovecot
809
   makecert dovecot
828
 
828
 
829
 function configure_gpg {
829
 function configure_gpg {
830
   if grep -Fxq "configure_gpg" $COMPLETION_FILE; then
830
   if grep -Fxq "configure_gpg" $COMPLETION_FILE; then
831
-	  return
831
+      return
832
   fi
832
   fi
833
   apt-get -y --force-yes install gnupg
833
   apt-get -y --force-yes install gnupg
834
 
834
 
835
   if [ ! -d /home/$MY_USERNAME/.gnupg ]; then
835
   if [ ! -d /home/$MY_USERNAME/.gnupg ]; then
836
-	  mkdir /home/$MY_USERNAME/.gnupg
837
-	  echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf
838
-	  echo 'keyserver-options auto-key-retrieve' >> /home/$MY_USERNAME/.gnupg/gpg.conf
836
+      mkdir /home/$MY_USERNAME/.gnupg
837
+      echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf
838
+      echo 'keyserver-options auto-key-retrieve' >> /home/$MY_USERNAME/.gnupg/gpg.conf
839
   fi
839
   fi
840
 
840
 
841
   sed -i "s|keyserver hkp://keys.gnupg.net|keyserver $GPG_KEYSERVER|g" /home/$MY_USERNAME/.gnupg/gpg.conf
841
   sed -i "s|keyserver hkp://keys.gnupg.net|keyserver $GPG_KEYSERVER|g" /home/$MY_USERNAME/.gnupg/gpg.conf
851
   chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
851
   chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
852
 
852
 
853
   if [[ $MY_GPG_PUBLIC_KEY && $MY_GPG_PRIVATE_KEY ]]; then
853
   if [[ $MY_GPG_PUBLIC_KEY && $MY_GPG_PRIVATE_KEY ]]; then
854
-	  # use your existing GPG keys which were exported
855
-	  if [ ! -f $MY_GPG_PUBLIC_KEY ]; then
856
-		  echo "GPG public key file $MY_GPG_PUBLIC_KEY was not found"
857
-		  exit 5
858
-	  fi
859
-	  if [ ! -f $MY_GPG_PRIVATE_KEY ]; then
860
-		  echo "GPG private key file $MY_GPG_PRIVATE_KEY was not found"
861
-		  exit 6
862
-	  fi
854
+      # use your existing GPG keys which were exported
855
+      if [ ! -f $MY_GPG_PUBLIC_KEY ]; then
856
+          echo "GPG public key file $MY_GPG_PUBLIC_KEY was not found"
857
+          exit 5
858
+      fi
859
+      if [ ! -f $MY_GPG_PRIVATE_KEY ]; then
860
+          echo "GPG private key file $MY_GPG_PRIVATE_KEY was not found"
861
+          exit 6
862
+      fi
863
       su - $MY_USERNAME gpg --import $MY_GPG_PUBLIC_KEY
863
       su - $MY_USERNAME gpg --import $MY_GPG_PUBLIC_KEY
864
       su - $MY_USERNAME gpg --allow-secret-key-import --import $MY_GPG_PRIVATE_KEY
864
       su - $MY_USERNAME gpg --allow-secret-key-import --import $MY_GPG_PRIVATE_KEY
865
-	  # for security ensure that the private key file doesn't linger around
866
-	  shred -zu $MY_GPG_PRIVATE_KEY
865
+      # for security ensure that the private key file doesn't linger around
866
+      shred -zu $MY_GPG_PRIVATE_KEY
867
   else
867
   else
868
       # Generate a GPG key
868
       # Generate a GPG key
869
-      echo "%echo Generating a GPG key for `hostname --fqdn`" > /home/$MY_USERNAME/gpg-genkey.conf
870
-      echo 'Key-Type: RSA' >> /home/$MY_USERNAME/gpg-genkey.conf
871
-      echo 'Key-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
872
-      echo 'Subkey-Type: ELG-E' >> /home/$MY_USERNAME/gpg-genkey.conf
873
-      echo 'Subkey-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
874
-      echo 'Name-Real:  `hostname --fqdn`' >> /home/$MY_USERNAME/gpg-genkey.conf
875
-      echo "Name-Email: $MY_USERNAME@$DOMAIN_NAME" >> /home/$MY_USERNAME/gpg-genkey.conf
876
-      echo 'Expire-Date: 0' >> /home/$MY_USERNAME/gpg-genkey.conf
877
-      echo '%commit' >> /home/$MY_USERNAME/gpg-genkey.conf
878
-      echo '%echo Done' >> /home/$MY_USERNAME/gpg-genkey.conf
879
-	  chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/gpg-genkey.conf
880
-      su - $MY_USERNAME gpg --batch --gen-key /home/$MY_USERNAME/gpg-genkey.conf
881
-      shred -zu /home/$MY_USERNAME/gpg-genkey.conf
869
+      umask 0277
870
+      cat << EOF > /tmp/$MY_USERNAME-gpg-genkey.conf
871
+      %echo Generating a GPG key
872
+      Key-Type: RSA
873
+      Key-Length: 4096
874
+      Subkey-Type: ELG-E
875
+      Subkey-Length: 4096
876
+      Name-Real:  `hostname --fqdn`
877
+      Name-Email: $MY_USERNAME@`hostname --fqdn`
878
+      Expire-Date: 0
879
+      %commit
880
+      %echo Done
881
+      EOF
882
+      umask 0002
883
+	  su $MY_USERNAME gpg --batch --gen-key /tmp/$MY_USERNAME-gpg-genkey.conf > gpg-keygen.log 2> gpg-keygen_error.log
884
+      shred -zu /tmp/$MY_USERNAME-gpg-genkey.conf
882
   fi
885
   fi
883
 
886
 
884
   echo 'configure_gpg' >> $COMPLETION_FILE
887
   echo 'configure_gpg' >> $COMPLETION_FILE
886
 
889
 
887
 function email_client {
890
 function email_client {
888
   if grep -Fxq "email_client" $COMPLETION_FILE; then
891
   if grep -Fxq "email_client" $COMPLETION_FILE; then
889
-	  return
892
+      return
890
   fi
893
   fi
891
   apt-get -y --force-yes install mutt-patched lynx abook
894
   apt-get -y --force-yes install mutt-patched lynx abook
892
   if [ ! -d /home/$MY_USERNAME/.mutt ]; then
895
   if [ ! -d /home/$MY_USERNAME/.mutt ]; then
987
 
990
 
988
 function folders_for_mailing_lists {
991
 function folders_for_mailing_lists {
989
   if grep -Fxq "folders_for_mailing_lists" $COMPLETION_FILE; then
992
   if grep -Fxq "folders_for_mailing_lists" $COMPLETION_FILE; then
990
-	  return
993
+      return
991
   fi
994
   fi
992
   echo '#!/bin/bash' > /usr/bin/mailinglistrule
995
   echo '#!/bin/bash' > /usr/bin/mailinglistrule
993
   echo 'MYUSERNAME=$1' >> /usr/bin/mailinglistrule
996
   echo 'MYUSERNAME=$1' >> /usr/bin/mailinglistrule
1023
 
1026
 
1024
 function folders_for_email_addresses {
1027
 function folders_for_email_addresses {
1025
   if grep -Fxq "folders_for_email_addresses" $COMPLETION_FILE; then
1028
   if grep -Fxq "folders_for_email_addresses" $COMPLETION_FILE; then
1026
-	  return
1029
+      return
1027
   fi
1030
   fi
1028
   echo '#!/bin/bash' > /usr/bin/emailrule
1031
   echo '#!/bin/bash' > /usr/bin/emailrule
1029
   echo 'MYUSERNAME=$1' >> /usr/bin/emailrule
1032
   echo 'MYUSERNAME=$1' >> /usr/bin/emailrule
1059
 
1062
 
1060
 function dynamic_dns_freedns {
1063
 function dynamic_dns_freedns {
1061
   if grep -Fxq "dynamic_dns_freedns" $COMPLETION_FILE; then
1064
   if grep -Fxq "dynamic_dns_freedns" $COMPLETION_FILE; then
1062
-	  return
1065
+      return
1063
   fi
1066
   fi
1064
 
1067
 
1065
   echo '#!/bin/bash' > /usr/bin/dynamicdns
1068
   echo '#!/bin/bash' > /usr/bin/dynamicdns
1070
   chmod +x /usr/bin/dynamicdns
1073
   chmod +x /usr/bin/dynamicdns
1071
 
1074
 
1072
   if ! grep -q "dynamicdns" /etc/crontab; then
1075
   if ! grep -q "dynamicdns" /etc/crontab; then
1073
-    sed -i '/# m h dom mon dow user	command/a\*/5 * * * * root /usr/bin/timeout 240 /usr/bin/dynamicdns' /etc/crontab
1076
+    sed -i '/# m h dom mon dow user command/a\*/5 * * * * root /usr/bin/timeout 240 /usr/bin/dynamicdns' /etc/crontab
1074
   fi
1077
   fi
1075
   service cron restart
1078
   service cron restart
1076
   echo 'dynamic_dns_freedns' >> $COMPLETION_FILE
1079
   echo 'dynamic_dns_freedns' >> $COMPLETION_FILE
1078
 
1081
 
1079
 function install_final {
1082
 function install_final {
1080
   if grep -Fxq "install_final" $COMPLETION_FILE; then
1083
   if grep -Fxq "install_final" $COMPLETION_FILE; then
1081
-	  return
1084
+      return
1082
   fi
1085
   fi
1083
   echo 'install_final' >> $COMPLETION_FILE
1086
   echo 'install_final' >> $COMPLETION_FILE
1084
   echo ''
1087
   echo ''