home · contact · privacy
Fix.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 18 Apr 2020 17:52:30 +0000 (19:52 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 18 Apr 2020 17:52:30 +0000 (19:52 +0200)
buster/setup_scripts/setup_dumpsite.sh
buster/setup_scripts/setup_website.sh

index da4c4415cc82558a0c55f8bd18ffc2f3d5f87eb7..2b8c732cf1b0b0b296b726e82fb0444ade12168b 100755 (executable)
@@ -3,17 +3,12 @@ set -e
 set -x
 
 if [ "$#" -ne 4 ]; then
 set -x
 
 if [ "$#" -ne 4 ]; then
-    echo 'Need domain name and mail and old server and init state (old, new?).'
-    false
-fi
-if [ ! "$4" = "copy" ] && [ ! "$4" = "new" ]; then
-    echo "Need init state to be either 'copy' or 'new'"
+    echo 'Need domain name and mail and old server.'
     false
 fi
 domain="$1"
 mail="$2"
 old_server="$3"
     false
 fi
 domain="$1"
 mail="$2"
 old_server="$3"
-init_state="$4"
 
 # Install configs, set up firewall.
 echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
 
 # Install configs, set up firewall.
 echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
@@ -42,19 +37,12 @@ dump_dir=dump
 geheim_dir=geheim
 su -lc "ln -s /home/plom/${dump_dir} /var/www-dump/${dump_dir}" plom
 su -lc "ln -s /home/plom/${geheim_dir} /var/www-dump/${geheim_dir}" plom
 geheim_dir=geheim
 su -lc "ln -s /home/plom/${dump_dir} /var/www-dump/${dump_dir}" plom
 su -lc "ln -s /home/plom/${geheim_dir} /var/www-dump/${geheim_dir}" plom
-if [ "${init_state}" = "new" ]; then
-  su -lc "mkdir ${dump_dir} ${geheim_dir}" plom
-  password_geheim=$(pwgen -1)
-  echo "foo:{PLAIN}${password_geheim}" > /var/www-dump/password_geheim
-  echo "geheim password is: ${password_geheim}"
-else
-  cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/
-  su -lc "./mirror_dir.sh ${old_server} /home/plom/${dump_dir}" plom
-  su -lc "./mirror_dir.sh ${old_server} /home/plom/${geheim_dir}" plom
-  su -lc "scp plom@${old_server}:/var/www-dump/password_geheim ~" plom
-  mv /home/plom/password_geheim /var/www-dump/password_geheim
-  rm /home/plom/mirror_dir.sh
-fi
+cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/
+su -lc "./mirror_dir.sh ${old_server} /home/plom/${dump_dir}" plom
+su -lc "./mirror_dir.sh ${old_server} /home/plom/${geheim_dir}" plom
+su -lc "scp plom@${old_server}:/var/www-dump/password_geheim ~" plom
+mv /home/plom/password_geheim /var/www-dump/password_geheim
+rm /home/plom/mirror_dir.sh
 
 # Set up redo.
 wget http://news.dieweltistgarnichtso.net/bin/archives/redo-sh.tar.gz
 
 # Set up redo.
 wget http://news.dieweltistgarnichtso.net/bin/archives/redo-sh.tar.gz
@@ -85,12 +73,10 @@ su -lc "cd url-catcher && ln -s ../blog/captchas/linkable/ captchas" plom
 cp "${config_tree_prefix}/other_files/url-catcher_customizations.json" /home/plom/url-catcher/customizations.json
 systemctl enable url_catcher.service
 service url_catcher start
 cp "${config_tree_prefix}/other_files/url-catcher_customizations.json" /home/plom/url-catcher/customizations.json
 systemctl enable url_catcher.service
 service url_catcher start
-if [ ! "${init_state}" = "new" ]; then
-  cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/
-  su -lc "./mirror_dir.sh ${old_server} /home/plom/url-catcher/ips" plom
-  su -lc "./mirror_dir.sh ${old_server} /home/plom/url-catcher/lists" plom
-  rm /home/plom/mirror_dir.sh
-fi
+cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/
+su -lc "./mirror_dir.sh ${old_server} /home/plom/url-catcher/ips" plom
+su -lc "./mirror_dir.sh ${old_server} /home/plom/url-catcher/lists" plom
+rm /home/plom/mirror_dir.sh
 
 # Set up index.html
 cp "${config_tree_prefix}/other_files/dumpsite_index.html" /var/www-dump/index.html
 
 # Set up index.html
 cp "${config_tree_prefix}/other_files/dumpsite_index.html" /var/www-dump/index.html
index 17025609b29ce8d208959cc3bf0a60fa559e463f..f781905cc6ce4ea10770c7bde7cf55a66d26ea91 100755 (executable)
@@ -1,19 +1,23 @@
 #!/bin/sh
 set -e
 
 #!/bin/sh
 set -e
 
-if [ "$#" -ne 5 ]; then
-    echo 'Need domain name and mail and old server IP and key ID and init state (old, new?) as argument.'
+if [ "$#" -ne 4 ] && [ "$#" -ne 5 ]; then
+    echo 'Need domain name and mail and key ID and init state and possibly old server IP as argument.'
     false
 fi
     false
 fi
-if [ ! "$5" = "copy" ] && [ ! "$5" = "new" ] && [ ! "$5" = "upgrade" ]; then
+if [ ! "$4" = "copy" ] && [ ! "$4" = "new" ] && [ ! "$4" = "upgrade" ]; then
     echo "Need init state to be either 'copy' or 'new' or 'upgrade'"
     false
 fi
     echo "Need init state to be either 'copy' or 'new' or 'upgrade'"
     false
 fi
+if [ ! "$4" = "new" ] and [ "$#" -ne 5 ]; then
+    echo "With init state != 'new' need fifth argument old server IP."
+    false
+fi
 domain="$1"
 mail="$2"
 domain="$1"
 mail="$2"
-old_server="$3"
-gpg_key="$4"
-init_state="$5"
+gpg_key="$3"
+init_state="$4"
+old_server="$5"
 
 # Install configs, set up firewall.
 config_tree_prefix="${HOME}/config/buster"
 
 # Install configs, set up firewall.
 config_tree_prefix="${HOME}/config/buster"
@@ -27,11 +31,13 @@ certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}
 rm /etc/nginx/sites-enabled/default
 
 # Set up connection to old server.
 rm /etc/nginx/sites-enabled/default
 
 # Set up connection to old server.
-cp "${config_tree_prefix}/setup_scripts/prepare_to_meet_server.sh" /home/plom/
-chown plom:plom /home/plom/prepare_to_meet_server.sh
-su -lc "./prepare_to_meet_server.sh ${old_server}" plom
-read -p'Hit Enter when you are done.' ignore
-rm /home/plom/prepare_to_meet_server.sh
+if [ ! "${init_state}" = "new" ]; then
+  cp "${config_tree_prefix}/setup_scripts/prepare_to_meet_server.sh" /home/plom/
+  chown plom:plom /home/plom/prepare_to_meet_server.sh
+  su -lc "./prepare_to_meet_server.sh ${old_server}" plom
+  read -p'Hit Enter when you are done.' ignore
+  rm /home/plom/prepare_to_meet_server.sh
+fi
 
 # Set up repos dir.
 # To use this dir, "git clone --mirror" repo source paths into it as user plom.
 
 # Set up repos dir.
 # To use this dir, "git clone --mirror" repo source paths into it as user plom.