From: Christian Heller Date: Wed, 15 Apr 2020 20:09:35 +0000 (+0200) Subject: Improve handling of old/new dumpsite init. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bprefix%7D%7D/coming?a=commitdiff_plain;h=e030933cc9421a5e5bce9c8462a8c4e8f4a1de5e;p=config Improve handling of old/new dumpsite init. --- diff --git a/buster/setup_scripts/setup_dumpsite.sh b/buster/setup_scripts/setup_dumpsite.sh index 71cc6f5..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,17 +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 -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 +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 @@ -78,11 +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 -# Outcomment if setting up new / not migrating. -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 +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 diff --git a/buster/setup_scripts/setup_website.sh b/buster/setup_scripts/setup_website.sh index 0873903..38b49a2 100755 --- a/buster/setup_scripts/setup_website.sh +++ b/buster/setup_scripts/setup_website.sh @@ -37,7 +37,7 @@ rm /home/plom/prepare_to_meet_server.sh # To use this dir, "git clone --mirror" repo source paths into it as user plom. # As user plom, touch git-daemon-export-ok files into it to make the repo # publically available. -if [ "$init_state" = "new" ]; then +if [ "${init_state}" = "new" ]; then mkdir /var/repos chown plom:plom /var/repos else @@ -57,7 +57,7 @@ ln -s /etc/nginx/sites-available/website.nginx /etc/nginx/sites-enabled/website. rm -rf /var/www mkdir /var/www chown plom:plom /var/www -if [ "$init_state" = "new" ]; then +if [ "${init_state}" = "new" ]; then su -lc "cd /var/repos && git clone --mirror ${old_server}:repos/website" plom cp "${config_tree_prefix}/other_files/website_hook_post-receive" /var/repos/website.git/hooks/post-receive fi @@ -89,16 +89,15 @@ mkdir -p "${irclogs_dir}" chown -R plom:plom "${irclogs_dir}" mkdir -p "${irclogs_pw_dir}" chown -R plom:plom "${irclogs_pw_dir}" -if [ "$init_state" = "new" ]; then +if [ "${init_state}" = "new" ]; then su -lc "cd /var/repos && git clone --mirror https://plomlompom.com/repos/clone/plomlombot-irc" plom su -lc "touch /var/repos/plomlombot-irc.git/git-daemon-export-ok" plom cp "${config_tree_prefix}/other_files/plomlombot_hook_post-receive" /var/repos/plomlombot-irc.git/hooks/post-receive fi - su -lc "git clone /var/repos/plomlombot-irc.git" plom cp "${config_tree_prefix}/other_files/plomlombot_daemon.sh" /home/plom/ chown plom:plom /home/plom/plomlombot_daemon.sh -if [ "$init_state" = "new" ]; then +if [ "${init_state}" = "new" ]; then echo 'bot: plomlombog plomlombog #plomlomtest irc.freenode.net foo bar' >> /home/plom/.plomlombot chown plom:plom /home/plom/.plomlombot else