home · contact · privacy
Fix.
[config] / buster / setup_scripts / setup_dumpsite.sh
index da4c4415cc82558a0c55f8bd18ffc2f3d5f87eb7..0e6cdc60322b1ea8224de38f5cc7a6c7d983d812 100755 (executable)
@@ -1,22 +1,22 @@
 #!/bin/sh
 set -e
-set -x
 
 if [ "$#" -ne 4 ]; then
-    echo 'Need domain name and mail and old server and init state (old, new?).'
+    echo 'Need domain name (choose wisely!) and mail and old server and repos source ("local" or "remote"?).'
     false
 fi
-if [ ! "$4" = "copy" ] && [ ! "$4" = "new" ]; then
-    echo "Need init state to be either 'copy' or 'new'"
+if [ ! "$4" = "local" ] && [ ! "$4" = "remote" ]; then
+    echo "Need legal repo source name."
     false
 fi
 domain="$1"
 mail="$2"
 old_server="$3"
-init_state="$4"
+repos_source="$4"
 
 # Install configs, set up firewall.
 echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
+# TODO: do we really want hostname as mailname?
 echo "postfix postfix/mailname string $(hostname -f)" | debconf-set-selections
 config_tree_prefix="${HOME}/config/buster"
 ./install_for_target.sh web dumpsite
@@ -42,19 +42,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
-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
@@ -72,7 +65,11 @@ su -lc "git clone --mirror ${old_server}:blog.git" plom
 cp "${config_tree_prefix}/other_files/blog_hook_post-receive" /home/plom/blog.git/hooks/post-receive
 su -lc "git clone ~/blog.git" plom
 # TODO: set up like plomlombot repo (with post-recieve hook)?
-su -lc "git clone https://plomlompom.com/repos/clone/redo-blog" plom
+if [ "$repo_source" = "local"]; then
+  su -lc "git clone /var/repos/redo-blog" plom
+else
+  su -lc "git clone https://plomlompom.com/repos/clone/redo-blog" plom
+fi
 su -lc "cd redo-blog && ./add_dir.sh ~/blog" plom
 su -lc "cd blog && redo" plom
 su -lc "ln -s /home/plom/blog/public /var/www-dump/blog" plom
@@ -80,17 +77,19 @@ su -lc "ln -s /home/plom/blog/public /var/www-dump/blog" plom
 
 # Set up url catcher.
 # TODO: set up like plomlombot repo (with post-recieve hook)?
-su -lc "git clone https://plomlompom.com/repos/clone/url-catcher" plom
+if [ "$repo_source" = "local"]; then
+  su -lc "git clone /var/repos/url-catcher" plom
+else
+  su -lc "git clone https://plomlompom.com/repos/clone/url-catcher" plom
+fi
 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
-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