diff --git a/sync_from_old_server.sh b/sync_from_old_server.sh index 6627361..636823d 100755 --- a/sync_from_old_server.sh +++ b/sync_from_old_server.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -ipv4_old="83.223.86.121" +# give old IPv4 address here - its mandatory" +# +ipv4_old="" old_server_ip=$ipv4_old tmp_err_msg=$(mktemp) @@ -51,9 +53,9 @@ sync_vhost_dirs="" # - Only needed to replace ip-addresse in virtual host configuration files # - -ipv4_new="83.223.90.20" -ipv6_old="2a01:30:0:13:2e0:7bff:fe9a:b18a" -ipv6_new="2a01:31:0:2::f851:1" +ipv4_new="" +ipv6_old="" +ipv6_new="" # - Sync dehydrated cert directory @@ -267,6 +269,7 @@ fi echo "" + echononl " Test ssh connection to $old_server_ip" ssh $old_server_ip "ls" > /dev/null 2> $tmp_err_msg if [[ $? -eq 0 ]];then @@ -277,6 +280,60 @@ else fi +echononl " Backup file /root/bin/.ssh/config" +if [[ -f "/root/.ssh/config" ]] ; then + mv "/root/.ssh/config " "/root/.ssh/config.${cur_date}" > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]];then + echo_ok + ssh_config_exists=true + else + echo_failed + error "$(cat $tmp_err_msg)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + + fi +else + echo_skipped + ssh_config_exists=false +fi + + +echononl " Create temporary file \033[31m\033[1m/root/.ssh/config\033[m .." + cat < "/root/.ssh/config" +Host * + ControlMaster auto + ControlPath ~/.ssh/%r@%h:%p + ControlPersist 30 + StrictHostKeyChecking no + LogLevel FATAL +EOF +if [[ $? -eq 0 ]];then + echo_ok + ssh_config_exists=true +else + echo_failed + error "$(cat $tmp_err_msg)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + +fi + + # - Create log directory # - @@ -959,6 +1016,22 @@ else fi +echononl " Restore file \033[31m\033[1m/root/.ssh/config\033[m .." +if [[ -f "/root/.ssh/config.${cur_date}" ]] ; then + mv "/root/.ssh/config.${cur_date}" "/root/.ssh/config" > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + fi +else + echo_skipped +fi + + + + echo -e "\n\n \033[37m\033[1mRestart Services..\033[m\n" echononl " (Re)start PureFTPd daemon (pure-ftpd)"