5 if [ "$#" -ne 3 ] && [ "$#" -ne 4 ]; then
6 echo 'Need domain name and mail and init state and possibly old server IP as argument.'
9 if [ ! "$3" = "copy" ] && [ ! "$3" = "new" ]; then
10 echo "Need init state to be either 'copy' or 'new'."
13 if [ ! "$3" = "new" ] && [ "$#" -ne 4 ]; then
14 echo "With init state != 'new' need fifth argument old server IP."
22 # Install configs, set up firewall.
23 config_tree_prefix="${HOME}/config/bullseye"
24 ./install_for_target.sh web
25 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web microblogpub
26 nft -f /etc/nftables.conf
28 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
29 ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
30 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
31 rm /etc/nginx/sites-enabled/default
33 # Install Python 3.10 from source (Bullseye only has 3.9).
36 python_dirname="Python-3.1.11.1"
37 su -lc "wget https://www.python.org/ftp/python/3.11.1/${python_dirname}.tgz" plom
38 su -lc "tar -xvf ${python_dirname}.tgz" plom
39 su -lc "cd ${python_dirname} && ./configure && make && make test"
40 cd /home/plom/${python_dirname}/
44 # Prepare and start NGINX config.
45 sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/microblogpub.nginx
46 ln -s /etc/nginx/sites-available/microblogpub.nginx /etc/nginx/sites-enabled/microblogpub.nginx