sync_from_old_server.sh: use temporary '/root/.ssh/config file'.
This commit is contained in:
parent
47f6e3d046
commit
52f23db602
@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
ipv4_old="83.223.86.121"
|
# give old IPv4 address here - its mandatory"
|
||||||
|
#
|
||||||
|
ipv4_old=""
|
||||||
old_server_ip=$ipv4_old
|
old_server_ip=$ipv4_old
|
||||||
|
|
||||||
tmp_err_msg=$(mktemp)
|
tmp_err_msg=$(mktemp)
|
||||||
@ -51,9 +53,9 @@ sync_vhost_dirs=""
|
|||||||
|
|
||||||
# - Only needed to replace ip-addresse in virtual host configuration files
|
# - Only needed to replace ip-addresse in virtual host configuration files
|
||||||
# -
|
# -
|
||||||
ipv4_new="83.223.90.20"
|
ipv4_new=""
|
||||||
ipv6_old="2a01:30:0:13:2e0:7bff:fe9a:b18a"
|
ipv6_old=""
|
||||||
ipv6_new="2a01:31:0:2::f851:1"
|
ipv6_new=""
|
||||||
|
|
||||||
|
|
||||||
# - Sync dehydrated cert directory
|
# - Sync dehydrated cert directory
|
||||||
@ -267,6 +269,7 @@ fi
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
echononl " Test ssh connection to $old_server_ip"
|
echononl " Test ssh connection to $old_server_ip"
|
||||||
ssh $old_server_ip "ls" > /dev/null 2> $tmp_err_msg
|
ssh $old_server_ip "ls" > /dev/null 2> $tmp_err_msg
|
||||||
if [[ $? -eq 0 ]];then
|
if [[ $? -eq 0 ]];then
|
||||||
@ -277,6 +280,60 @@ else
|
|||||||
fi
|
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 <<EOF > "/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
|
# - Create log directory
|
||||||
# -
|
# -
|
||||||
@ -959,6 +1016,22 @@ else
|
|||||||
fi
|
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"
|
echo -e "\n\n \033[37m\033[1mRestart Services..\033[m\n"
|
||||||
|
|
||||||
echononl " (Re)start PureFTPd daemon (pure-ftpd)"
|
echononl " (Re)start PureFTPd daemon (pure-ftpd)"
|
||||||
|
Loading…
Reference in New Issue
Block a user