hosts/scripts/main_part.include: only kill pd if prozess is present.

This commit is contained in:
2026-03-01 11:39:07 +01:00
parent c1e4fbc75c
commit fe73b6728b

View File

@@ -18,7 +18,7 @@ backup_mirror_dir=$script_backup_dir/mirror
script_dir=$hosts_base_dir/scripts script_dir=$hosts_base_dir/scripts
## - All backuped directories will be written to that file, to ## - All backuped directories will be written to that file, to
## - avoid multiple execution. ## - avoid multiple execution.
## - ## -
dirs_backup_done="$script_backup_dir/backup_dirs.lst" dirs_backup_done="$script_backup_dir/backup_dirs.lst"
@@ -30,13 +30,13 @@ export destHost script_backup_dir backup_archiv_dir backup_mirror_dir script_dir
## - Works even if "ssh_hopping" is not set ## - Works even if "ssh_hopping" is not set
## - ## -
if [ "X$ssh_hopping" = "X" ] ; then if [ "X$ssh_hopping" = "X" ] ; then
ssh_hopping=false ssh_hopping=false
fi fi
## - Works even if "ssh_tunnel" is not set ## - Works even if "ssh_tunnel" is not set
## - ## -
if [ "X$ssh_tunnel" = "X" ] ; then if [ "X$ssh_tunnel" = "X" ] ; then
ssh_tunnel=false ssh_tunnel=false
fi fi
if ! $ssh_hopping && ! $ssh_tunnel ; then if ! $ssh_hopping && ! $ssh_tunnel ; then
@@ -69,7 +69,7 @@ else
## - delete existing ssh tunnels ## - delete existing ssh tunnels
## - ## -
tunnel_pid_old=`ps x | grep -e "$local_port:[^:]*:$target_port" | grep -v grep | awk '{print$1}'` tunnel_pid_old=`ps x | grep -e "$local_port:[^:]*:$target_port" | grep -v grep | awk '{print$1}'`
if [ -n "$tunnel_pid_old" ]; then if [ -n "$tunnel_pid_old" ]; then
kill $tunnel_pid_old kill $tunnel_pid_old
fi fi
@@ -93,7 +93,7 @@ else
## - delete existing ssh tunnels ## - delete existing ssh tunnels
## - ## -
tunnel_pid_old=`ps x | grep -e "$ssh_tunnel_local_port:$target_host:$ssh_tunnel_target_port" | grep -v grep | awk '{print$1}'` tunnel_pid_old=`ps x | grep -e "$ssh_tunnel_local_port:$target_host:$ssh_tunnel_target_port" | grep -v grep | awk '{print$1}'`
if [ -n "$tunnel_pid_old" ]; then if [ -n "$tunnel_pid_old" ]; then
kill $tunnel_pid_old kill $tunnel_pid_old
fi fi
@@ -133,7 +133,7 @@ if [ "$found" = "true" -o "$pgsql_backup" = "true" -o "$mysql_backup" = "true"
begin_m=`date +%M` begin_m=`date +%M`
backup_date=`date +"%d.%m.%Y"` backup_date=`date +"%d.%m.%Y"`
backup_begin_timestamp=`date +"%s"` backup_begin_timestamp=`date +"%s"`
if $_via_ssh_tunnel ; then if $_via_ssh_tunnel ; then
echolog "\nBegin saving host \"$target_host\" : $backup_date ( ${begin_h}:${begin_m} h )\n" echolog "\nBegin saving host \"$target_host\" : $backup_date ( ${begin_h}:${begin_m} h )\n"
else else
@@ -318,9 +318,9 @@ if [ "$found" = "true" -o "$pgsql_backup" = "true" -o "$mysql_backup" = "true"
else else
echolog "\nGoing to backup mysql databases.. ( `$date +%H`:`$date +%M` h )" echolog "\nGoing to backup mysql databases.. ( `$date +%H`:`$date +%M` h )"
export mysql_user mysql_password mysql_credential_args mysql_gzip export mysql_user mysql_password mysql_credential_args mysql_gzip
$script_dir/mysql_backup.sh $script_dir/mysql_backup.sh
fi fi
## - !! ## - !!
if $restart_apache ;then if $restart_apache ;then
$ssh ${ssh_user}@$srcHost "sudo /etc/init.d/apache2 restart" $ssh ${ssh_user}@$srcHost "sudo /etc/init.d/apache2 restart"
fi fi
@@ -349,7 +349,7 @@ if [ "$found" = "true" -o "$pgsql_backup" = "true" -o "$mysql_backup" = "true"
echolog "\nGoing to backup network directories.. ( `$date +%H`:`$date +%M` h )" echolog "\nGoing to backup network directories.. ( `$date +%H`:`$date +%M` h )"
for dir in $net_mounted_dir_backup ; do for dir in $net_mounted_dir_backup ; do
#echolog "\n\tBackup network directory $dir" #echolog "\n\tBackup network directory $dir"
export mount_netdir export mount_netdir
backup_dir=$dir $script_dir/net_mounted_dir_backup.sh backup_dir=$dir $script_dir/net_mounted_dir_backup.sh
done done
fi fi
@@ -379,10 +379,10 @@ if [ "$found" = "true" -o "$pgsql_backup" = "true" -o "$mysql_backup" = "true"
declare -a nextcloud_account_arr declare -a nextcloud_account_arr
# - Splitt on newlines # - Splitt on newlines
# - # -
# - Use: IFS=$'\n' # - Use: IFS=$'\n'
# - # -
IFS=$'\n' ; for _account in $nextcloud_accounts ; do IFS=$'\n' ; for _account in $nextcloud_accounts ; do
nextcloud_account_arr+=("$(trim $_account)"); nextcloud_account_arr+=("$(trim $_account)");
done done
@@ -487,6 +487,8 @@ fi
if $_via_ssh_tunnel ; then if $_via_ssh_tunnel ; then
if [[ -n "$tunnel_pid" ]]; then if [[ -n "$tunnel_pid" ]]; then
kill "$tunnel_pid" if ps --pd ${tunnel_pid} > /dev/null 2>&^; then
kill "$tunnel_pid"
fi
fi fi
fi fi