home · contact · privacy
Upgrade Firefox version.
[config] / bookworm / setup_scripts / setup_tube.plomlompom.com.sh
1 #!/bin/sh
2 set -e
3 . ./misc.sh
4
5 expect_setup_finished_file setup_web_has_been_run setup_web.sh
6
7 mirror_ip=""
8 mirror_state="not mirroring automatically"
9 domain="tube.plomlompom.com"
10 mail="plom+tube@plomlompom.com"
11 if [ "$#" -gt 0 ]; then
12     domain="$1"
13     if [ "$#" -gt 1 ]; then
14         mail="plom+testing@plomlompom.com"
15         if [ "$#" -gt 2 ]; then
16             mirror_ip="$3"
17             mirror_state="mirroring automatically from ${mirror_ip}"
18         fi
19     fi
20 fi
21 echo "Assuming domain ${domain} and letsencrypt support mail address ${mail} and ${mirror_state}, abort and provide as arguments in this order if other desired! (Otherwise just hit Return.)"
22 read _
23
24 # Install configs, set up firewall.
25 ./install_for_target.sh tube.plomlompom.com
26 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" tube.plomlompom.com
27 nft -f /etc/nftables.conf
28
29 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
30 ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
31 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
32 rm /etc/nginx/sites-enabled/default
33
34 # Prepare NGINX for tube.plomlompom.com.
35 sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/tube.plomlompom.com.nginx
36 ln -s /etc/nginx/sites-available/tube.plomlompom.com.nginx /etc/nginx/sites-enabled/tube.plomlompom.com.nginx
37
38 if [ ! -z "${mirror_ip}" ]; then
39     # Set up connection to old server.
40     cp "${setup_scripts_dir}/misc.sh" /home/plom/
41     cp "${setup_scripts_dir}/prepare_to_meet_server.sh" /home/plom/
42     chown plom:plom /home/plom/prepare_to_meet_server.sh
43     su -lc "./prepare_to_meet_server.sh ${mirror_ip}" plom
44     read -p 'Hit Enter when you are done.' ignore
45     rm /home/plom/prepare_to_meet_server.sh
46
47     # Mirror dirs.
48     cp "${setup_scripts_dir}/mirror_dir.sh" /home/plom/
49     su -lc "./mirror_dir.sh ${mirror_ip} /var/www/tube.plomlompom.com" plom
50     rm /home/plom/mirror_dir.sh
51     rm /home/plom/misc.sh
52 fi
53
54 service nginx restart
55