X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=buster%2Fsetup_scripts%2Fsetup_dumpsite.sh;h=da4c4415cc82558a0c55f8bd18ffc2f3d5f87eb7;hb=dcebca7ba214a0a7961c84176606f6e4ae696e02;hp=739f145dbff69af4fec8e4359ec10726bdd03c52;hpb=c4c94ddd203e70460c70276f9ed53956c59ac43b;p=config diff --git a/buster/setup_scripts/setup_dumpsite.sh b/buster/setup_scripts/setup_dumpsite.sh index 739f145..da4c441 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" = "copy" ] && [ ! "$4" = "new" ]; then + echo "Need init state to be either 'copy' 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 @@ -23,29 +28,38 @@ 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 connection to old dump 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 + # Set up dump dirs. mkdir /var/www-dump chown plom:plom /var/www-dump dump_dir=dump geheim_dir=geheim -su -lc "mkdir ${dump_dir} ${geheim_dir}" plom 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 -password_geheim=$(pwgen -1) -echo "foo:{PLAIN}${password_geheim}" > /var/www-dump/password_geheim -echo "geheim password is: ${password_geheim}" +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 tar -moxzf redo-sh.tar.gz -C /usr/local -# Set up connection to old dump 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 - # Set up zettel. su -lc "git clone --mirror ${old_server}:zettel.git" plom cp "${config_tree_prefix}/other_files/zettel_hook_post-receive" /home/plom/zettel.git/hooks/post-receive @@ -57,23 +71,29 @@ su -lc "ln -s /home/plom/zettel /var/www-dump/zettel" plom 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 -# FIXME: we should not depend on a GitHub repo; -# instead, set up like plomlombot repo (with post-recieve hook) -su -lc "git clone https://github.com/plomlompom/redo-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 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 # NOTE: Locally, to update content, clone blog.git, not blog. # Set up url catcher. -su -lc "git clone https://github.com/plomlompom/url-catcher.git" plom -# FIXME: we should not depend on a GitHub repo; -# instead, set up like plomlombot repo (with post-recieve hook) +# TODO: set up like plomlombot repo (with post-recieve hook)? +su -lc "git clone https://plomlompom.com/repos/clone/url-catcher" plom 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 -# NOTE: fix metadata/article_tmpl referencing dump.plomlompom.com explicitely +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 # Prepare NGINX. sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/dumpsite.nginx