X-Git-Url: https://plomlompom.com/repos/test.html?a=blobdiff_plain;f=buster%2Fsetup_scripts%2Fsetup_dumpsite.sh;h=4a7200372a9a2a3edc402865ae39073feac65cd5;hb=eeb6a9bb67e46e72b02c4cddb342178719c91322;hp=860a3a05e9a52cf947ef51d3399dc5533522c8a7;hpb=439348e7d8dc7945674b30ad78b1e787b6ea315e;p=config
diff --git a/buster/setup_scripts/setup_dumpsite.sh b/buster/setup_scripts/setup_dumpsite.sh
index 860a3a0..4a72003 100755
--- a/buster/setup_scripts/setup_dumpsite.sh
+++ b/buster/setup_scripts/setup_dumpsite.sh
@@ -2,13 +2,18 @@
set -e
set -x
-if [ "$#" -ne 3 ]; then
- echo 'Need domain name and mail and old server.'
+if [ "$#" -ne 4 ]; then
+ echo 'Need domain name and mail and old server and init state (old, new?).'
+ false
+fi
+if [ ! "$4" = "old" ] && [ ! "$4" = "new" ]; then
+ echo "Need init state to be either 'old' or 'new'"
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
@@ -37,16 +42,19 @@ 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
-# Use upper outcommented instead of lower code if setting up new empty server.
-#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}"
-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
-scp plom@${old_server}:/var/www-dump/password_geheim /var/www-dump/password_geheim
-rm /home/plom/{prepare_to_meet_server,mirror_dir}.sh
+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
# Set up redo.
wget http://news.dieweltistgarnichtso.net/bin/archives/redo-sh.tar.gz
@@ -77,10 +85,12 @@ 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}/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/{prepare_to_meet_server,mirror_dir}.sh
+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
# Set up index.html
cp "${config_tree_prefix}/other_files/dumpsite_index.html" /var/www-dump/index.html