From: Christian Heller Date: Wed, 15 Apr 2020 19:57:52 +0000 (+0200) Subject: Improve old/new site handling. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/static/%7B%7Bprefix%7D%7D/index.html?a=commitdiff_plain;h=04991234db9818234aac2c98a0bdcd57ce5c3f05;p=config Improve old/new site handling. --- diff --git a/buster/setup_scripts/setup_website.sh b/buster/setup_scripts/setup_website.sh index 7fae6c3..aefb9a8 100755 --- a/buster/setup_scripts/setup_website.sh +++ b/buster/setup_scripts/setup_website.sh @@ -1,14 +1,19 @@ #!/bin/sh set -e -if [ "$#" -ne 4 ]; then - echo 'Need domain name and mail and old server IP and key ID as argument.' +if [ "$#" -ne 5 ]; then + echo 'Need domain name and mail and old server IP and key ID and init state (old, new?) as argument.' + false +fi +if [ ! "$5" = "old" ] && [ ! "$1" = "new" ]; then + echo "Need init state to be either 'old' or 'new'" false fi domain="$1" mail="$2" old_server="$3" gpg_key="$4" +init_state="$5" # Install configs, set up firewall. config_tree_prefix="${HOME}/config/buster" @@ -29,17 +34,19 @@ read -p'Hit Enter when you are done.' ignore rm /home/plom/prepare_to_meet_server.sh # Set up repos dir. -mkdir /var/repos -chown plom:plom /var/repos # 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. -# Outcomment following lines if setting up new / not migrating. -cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/ -chmod a+w /var -su -lc "./mirror_dir.sh ${old_server} /var/repos" plom -chmod a-w /var -rm /home/plom/mirror_dir.sh +if [ "$init_state" = "new" ]; then + mkdir /var/repos + chown plom:plom /var/repos +else + cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/ + chmod a+w /var + su -lc "./mirror_dir.sh ${old_server} /var/repos" plom + chmod a-w /var + rm /home/plom/mirror_dir.sh +fi # Prepare NGINX and GitWeb config. sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/gitweb.conf @@ -50,9 +57,10 @@ 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 -# Use next two lines if setting up new / not migrating. -#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 +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 su -lc 'cd /var/www && git clone /var/repos/website.git .' plom # Add encryption key. @@ -81,22 +89,25 @@ mkdir -p "${irclogs_dir}" chown -R plom:plom "${irclogs_dir}" mkdir -p "${irclogs_pw_dir}" chown -R plom:plom "${irclogs_pw_dir}" -# Use following lines if setting up new / not migrating. -#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 +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 -# Use upper outcommented instead of lower code if setting up new empty server. -#echo 'bot: plomlombog plomlombog #plomlomtest irc.freenode.net foo bar' >> /home/plom/.plomlombot -#chown plom:plom /home/plom/.plomlombot -cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/ -su -lc "./mirror_dir.sh ${old_server} /home/plom/plomlombot_db" plom -rm /home/plom/mirror_dir.sh -su -lc "scp plom@${old_server}:.plomlombot ~" plom -ssh plom@"${old_server}" "su -lc 'service plomlombot stop'" +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 + cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/ + su -lc "./mirror_dir.sh ${old_server} /home/plom/plomlombot_db" plom + rm /home/plom/mirror_dir.sh + su -lc "scp plom@${old_server}:.plomlombot ~" plom + ssh plom@"${old_server}" "su -lc 'service plomlombot stop'" +fi systemctl enable plomlombot.service service plomlombot start