#!/bin/sh
set -e
-if [ "$#" -ne 5 ]; then
- echo 'Need domain name and mail and old server IP and key ID and init state (old, new?) as argument.'
+if [ "$#" -ne 4 ] && [ "$#" -ne 5 ]; then
+ echo 'Need domain name and mail and key ID and init state and possibly old server IP as argument.'
false
fi
-if [ ! "$5" = "copy" ] && [ ! "$5" = "new" ] && [ ! "$5" = "upgrade" ]; then
+if [ ! "$4" = "copy" ] && [ ! "$4" = "new" ] && [ ! "$4" = "upgrade" ]; then
echo "Need init state to be either 'copy' or 'new' or 'upgrade'"
false
fi
+if [ ! "$4" = "new" ] and [ "$#" -ne 5 ]; then
+ echo "With init state != 'new' need fifth argument old server IP."
+ false
+fi
domain="$1"
mail="$2"
-old_server="$3"
-gpg_key="$4"
-init_state="$5"
+gpg_key="$3"
+init_state="$4"
+old_server="$5"
# Install configs, set up firewall.
config_tree_prefix="${HOME}/config/buster"
rm /etc/nginx/sites-enabled/default
# Set up connection to old 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
+if [ ! "${init_state}" = "new" ]; then
+ 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
+fi
# Set up repos dir.
# To use this dir, "git clone --mirror" repo source paths into it as user plom.