diff --git a/scripts/add_mail_user.sh b/scripts/add_mail_user.sh new file mode 100644 index 00000000..1e7a58fd --- /dev/null +++ b/scripts/add_mail_user.sh @@ -0,0 +1,15 @@ +EMAIL_ADDR=$1 +if [ -z "$EMAIL_ADDR" ]; then + echo + echo "Set up your first email account..." + read -e -i "user@`hostname`" -p "Email Address: " EMAIL_ADDR +fi + +EMAIL_PW=$2 +if [ -z "$EMAIL_PW" ]; then + read -e -p "Email Password: " EMAIL_PW +fi + +echo "INSERT INTO users (email, password) VALUES ('$EMAIL_ADDR', '`sudo doveadm pw -s SHA512-CRYPT -p $EMAIL_PW`');" \ + | sqlite3 $STORAGE_ROOT/mail/users.sqlite + diff --git a/scripts/index.sh b/scripts/index.sh deleted file mode 100644 index af6abbc1..00000000 --- a/scripts/index.sh +++ /dev/null @@ -1,6 +0,0 @@ -. scripts/system.sh -. scripts/dns.sh -. scripts/mail.sh -. scripts/dkim.sh -. scripts/dns_update.sh - diff --git a/scripts/mail.sh b/scripts/mail.sh index 3cdf6ced..59d2f642 100755 --- a/scripts/mail.sh +++ b/scripts/mail.sh @@ -6,12 +6,12 @@ # Install packages. DEBIAN_FRONTEND=noninteractive apt-get install -q -y \ - postfix postgrey dovecot-core dovecot-imapd dovecot-lmtpd dovecot-sqlite + postfix postgrey dovecot-core dovecot-imapd dovecot-lmtpd dovecot-sqlite sqlite3 # POSTFIX mkdir -p $STORAGE_ROOT/mail - + # TLS configuration sed -i "s/#submission/submission/" /etc/postfix/master.cf # enable submission port (not in Drew Crawford's instructions) tools/editconf.py /etc/postfix/main.cf \ diff --git a/scripts/mail_testuser.sh b/scripts/mail_testuser.sh deleted file mode 100644 index cdc481ed..00000000 --- a/scripts/mail_testuser.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Create a test user: testuser@testdomain.com with password "testpw" -echo "INSERT INTO users (email, password) VALUES ('testuser@testdomain.com', '`sudo doveadm pw -s SHA512-CRYPT -p testpw`');" | sqlite3 storage/mail/users.sqlite - diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 00000000..800e26c2 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,30 @@ +if [ -z "$PUBLIC_HOSTNAME" ]; then + echo + echo "Enter the hostname you want to assign to this machine." + echo "We've guessed a value. Just backspace it if it's wrong." + echo "Josh uses box.occams.info as his hostname. Yours should" + echo "be similar." + read -e -i "`hostname`" -p "Hostname: " PUBLIC_HOSTNAME +fi + +if [ -z "$PUBLIC_IP" ]; then + echo + echo "Enter the public IP address of this machine, as given to" + echo "you by your ISP. We've guessed a value, but just backspace" + echo "it if it's wrong." + read -e -i "`hostname -i`" -p "Public IP: " PUBLIC_IP +fi + +if [ -z "$STORAGE_ROOT" ]; then + if [ ! -d /home/user-data ]; then useradd -m user-data; fi + STORAGE_ROOT=/home/user-data +fi + +. scripts/system.sh +. scripts/dns.sh +. scripts/mail.sh +. scripts/dkim.sh +. scripts/spamassassin.sh +. scripts/dns_update.sh +. scripts/add_mail_user.sh +. scripts/users_update.sh diff --git a/scripts/system.sh b/scripts/system.sh index 1e8cd6d1..efd2be8d 100755 --- a/scripts/system.sh +++ b/scripts/system.sh @@ -3,10 +3,6 @@ apt-get -q update apt-get -q -y upgrade -# Basic packages. - -apt-get -q -y install sqlite3 - # Turn on basic services: # # ntp: keeps the system time correct @@ -19,10 +15,10 @@ apt-get install -q -y ntp fail2ban # Turn on the firewall. First allow incoming SSH, then turn on the firewall. Additional open # ports will be set up in the scripts that set up those services. -ufw allow ssh -#ufw allow http -#ufw allow https -ufw --force enable +if [ -z "$DISABLE_FIREWALL" ]; then + ufw allow ssh; + ufw --force enable; +fi # Mount the storage volume. export STORAGE_ROOT=/home/ubuntu/storage