home · contact · privacy
Differentiate init_state options for *site scripts.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 18 Apr 2020 17:42:07 +0000 (19:42 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 18 Apr 2020 17:42:07 +0000 (19:42 +0200)
buster/setup_scripts/setup_dumpsite.sh
buster/setup_scripts/setup_website.sh

index 4a7200372a9a2a3edc402865ae39073feac65cd5..da4c4415cc82558a0c55f8bd18ffc2f3d5f87eb7 100755 (executable)
@@ -6,8 +6,8 @@ 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'"
+if [ ! "$4" = "copy" ] && [ ! "$4" = "new" ]; then
+    echo "Need init state to be either 'copy' or 'new'"
     false
 fi
 domain="$1"
index ac2d7310398179ea629ff5c2512daef96b390091..17025609b29ce8d208959cc3bf0a60fa559e463f 100755 (executable)
@@ -5,8 +5,8 @@ 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" ] && [ ! "$5" = "new" ]; then
-    echo "Need init state to be either 'old' or 'new'"
+if [ ! "$5" = "copy" ] && [ ! "$5" = "new" ] && [ ! "$5" = "upgrade" ]; then
+    echo "Need init state to be either 'copy' or 'new' or 'upgrade'"
     false
 fi
 domain="$1"
@@ -43,7 +43,11 @@ if [ "${init_state}" = "new" ]; then
 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
+  if ["${init_state}" = "copy" ]; then
+    su -lc "./mirror_dir.sh ${old_server} /var/repos" plom
+  else
+    su -lc "./mirror_dir.sh ${old_server} /var/public_repos" plom
+  fi
   chmod a-w /var
   rm /home/plom/mirror_dir.sh
 fi
@@ -57,11 +61,14 @@ 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}" = "upgrade" ]; then
   # This assumes the old core.plomlompom.com filesystem hierarchy.
   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
+elif [ "${init_state}" = "new" ]; then
+  su -lc "cd /var/repos && git init --bare website" plom
 fi
+# TODO: find out whether this can be part of cloned repo …?
+cp "${config_tree_prefix}/other_files/website_hook_post-receive" /var/repos/website.git/hooks/post-receive
 su -lc 'cd /var/www && git clone /var/repos/website.git .' plom
 
 # Add encryption key.