home · contact · privacy
Improve web setup.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 29 Aug 2023 22:22:18 +0000 (00:22 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 29 Aug 2023 22:22:18 +0000 (00:22 +0200)
bookworm/setup_scripts/misc.sh
bookworm/setup_scripts/setup_status.plomlompom.com.sh [new file with mode: 0644]
bookworm/setup_scripts/setup_web.sh

index cc93c32b6c53fb9f74d05734efe7c1616571cc87..641d7522b2031da1476f6ad13742ca7108727bae 100644 (file)
@@ -19,6 +19,15 @@ expect_n_args() {
     fi
 }
 
+expect_setup_finished_file() {
+    filename="$1"
+    setup_script="$2"
+    if [ ! -f "${HOME}/${filename}" ]; then
+        echo "First need to run ${setup_script}."
+        false
+    fi
+}
+
 get_system_name_arg() {
     found=0
     for system_name_i in $legal_system_names; do
diff --git a/bookworm/setup_scripts/setup_status.plomlompom.com.sh b/bookworm/setup_scripts/setup_status.plomlompom.com.sh
new file mode 100644 (file)
index 0000000..d5e6d18
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+set -e
+. ./misc.sh
+
+expect_setup_finished_file setup_web_has_been_run setup_web.sh
+
+if [ -z "$1"]; then
+    domain="status.plomlompom.com"
+else
+    domain="$1"
+fi
+# Install configs, set up firewall.
+./install_for_target.sh static_websites
+./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" static_websites
+nft -f /etc/nftables.conf
+
+# Set up letsencrypt certificate. TODO: Is it auto-renewed?
+ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
+certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
+rm /etc/nginx/sites-enabled/default
+
+# Prepare NGINX for status.plomlompom.com.
+sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/status.plomlompom.com.nginx
+ln -s /etc/nginx/sites-available/status.plomlompom.com.nginx /etc/nginx/sites-enabled/status.plomlompom.com.nginx
+
+service nginx restart
+
index 4b1e93f1196628f5329be670aa2823a37953d3cc..a2e672f684899ce51620f7ba1090cb91192a900c 100755 (executable)
@@ -2,26 +2,25 @@
 set -e
 . ./misc.sh
 
+expect_setup_finished_file setup_server_has_been_run setup_server.sh
+
 expect_n_args 1 "(domain name)" "$@"
 domain="$1"
 
-if [ ! -f "$HOME/setup_server_has_been_run" ]; then
-    echo "First need to run setup_server.sh."
-    false
-fi
-
 # Install configs, set up firewall.
-./install_for_target.sh web static_websites
-./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web static_websites
+./install_for_target.sh web
+./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web
 nft -f /etc/nftables.conf
 
-# Set up letsencrypt certificate. TODO: Is it auto-renewed?
-ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
-certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
-rm /etc/nginx/sites-enabled/default
+# Set up letsencrypt certificate. TODO: Is it auto-renewed?
+ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
+certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
+rm /etc/nginx/sites-enabled/default
 
-# Prepare NGINX for status.plomlompom.com.
-sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/status.plomlompom.com.nginx
-ln -s /etc/nginx/sites-available/status.plomlompom.com.nginx /etc/nginx/sites-enabled/status.plomlompom.com.nginx
+# # Prepare NGINX for status.plomlompom.com.
+# sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/status.plomlompom.com.nginx
+# ln -s /etc/nginx/sites-available/status.plomlompom.com.nginx /etc/nginx/sites-enabled/status.plomlompom.com.nginx
+# 
+# service nginx restart
 
-service nginx restart
+touch "$HOME/setup_web_has_been_run"