home · contact · privacy
WIP.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 24 Nov 2018 01:52:39 +0000 (02:52 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 24 Nov 2018 01:52:39 +0000 (02:52 +0100)
all_new_2018/letsencrypt.sh [new file with mode: 0755]
all_new_2018/setup_mail.sh

diff --git a/all_new_2018/letsencrypt.sh b/all_new_2018/letsencrypt.sh
new file mode 100755 (executable)
index 0000000..01f8a81
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+set -e
+
+# Ensure we have a server name as argument.
+if [ ! $# -eq 2 ]; then
+    echo "Need server and action as argument."
+    false
+fi
+server="$1"
+action="$2"
+
+# So we only get asked once for decrypting our key.
+eval $(ssh-agent)
+ssh-add ~/.ssh/id_rsa
+
+if [ "${action}" = "set" ]; then
+    # Install certificate.
+    ssh -t plom@${server} "su -c 'apt -y install certbot && certbot certonly --standalone -d ${server}$'"
+elif [ "${action}" = "get" ]; then
+    # Get /etc/letsencrypt/ as tar file.
+    ssh -t plom@${server} 'su -c "cd /etc/ && tar cf letsencrypt.tar letsencrypt && chown plom:plom letsencrypt.tar && mv letsencrypt.tar /home/plom/"'
+    scp plom@${server}:~/letsencrypt.tar .
+elif [ "${action}" = "put" ]; then
+    # Expand letsencrypt.tar to /etc/letsencrypt/ on server.
+    scp letsencrypt.tar plom@${server}:~/
+    ssh -t plom@${server} 'su -c "rmdir /etc/letsencrypt && mv letsencrypt.tar /etc/ && cd /etc/ && tar xf letsencrypt.tar && rm letsencrypt.tar"'
+else
+    echo "Action must be 'set', 'get', or 'put'."
+    false
+fi
+
index 0415717741b1f73e314f370fee24866a7c86267a..a3045e6b8dcec054b07aaf0a61384ac373d57700 100755 (executable)
@@ -2,7 +2,7 @@
 set -e
 
 echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
-#echo "postfix postfix/mailname string $(hostname -f)" | debconf-set-selections
+echo "postfix postfix/mailname string $(hostname -f)" | debconf-set-selections
 echo "$(hostname -f)" > /etc/mailname
 apt install -y postfix
 mkdir -p /etc/dovecot/conf.d/