2 # Install or copy LetsEncrypt certificates on/from server.
4 # First argument: server
5 # Second argument: "get" or "put"
7 # "get" copies the server's /etc/letsencrypt to a local letsencrypt.tar.
9 # "set" copies a local letsencrypt.tar to the server's /etc/letsencrypt.
12 # Ensure we have a server name as argument.
14 echo "Need server and action as arguments."
20 # So we only get asked once for decrypting our key.
24 if [ "${action}" = "get" ]; then
25 # Get /etc/letsencrypt/ as tar file.
26 ssh -t plom@${server} 'su -c "cd /etc/ && tar cf letsencrypt.tar letsencrypt && chown plom:plom letsencrypt.tar && mv letsencrypt.tar /home/plom/"'
27 scp plom@${server}:~/letsencrypt.tar .
28 elif [ "${action}" = "put" ]; then
29 # Expand letsencrypt.tar to /etc/letsencrypt/ on server.
30 scp letsencrypt.tar plom@${server}:~/
31 ssh -t plom@${server} 'su -c "rmdir /etc/letsencrypt && mv letsencrypt.tar /etc/ && cd /etc/ && tar xf letsencrypt.tar && rm letsencrypt.tar"'
33 echo "Action must be 'get', or 'put'."