remote-copy_gateway-config.sh: test if remote directory holds files to download.

This commit is contained in:
Christoph 2018-05-08 01:36:04 +02:00
parent 05fbd45b23
commit 36d2c4d703

View File

@ -12,6 +12,9 @@ backup_date="$(date +%Y-%m-%d-%H%M)"
declare -a files_backuped_arr=()
declare -a dirs_backuped_arr=()
declare -a rm_local_files_arr=()
declare -a rm_local_dirs_arr=()
# ----------
# Base Function(s)
@ -256,6 +259,43 @@ rm_unchanged_backup() {
fi
}
remove_local_files() {
if [[ ${#rm_local_files_arr[@]} -gt 0 ]] ; then
for _file in "${rm_local_files_arr[@]}" ; do
echononl "Remove local file '$(basename "$_file")' .."
if [[ -f "$_file" ]] ; then
rm "$_file" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat "$log_file")"
fi
else
echo_skipped
fi
done
fi
}
remove_local_dir() {
if [[ ${#rm_local_dirs_arr[@]} -gt 0 ]] ; then
for _dir in "${rm_local_dirs_arr[@]}" ; do
echononl "Remove local directory '$(basename "$_dir")' .."
if [[ -d "$_dir" ]] ; then
rm -rf "$_dir" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat "$log_file")"
fi
else
echo_skipped
fi
done
fi
}
manage_files() {
@ -517,6 +557,11 @@ if $terminal ; then
echo ""
fi
declare -i remote_dir_count="$(ssh gw-replacement.wf.netz "ls -A ${_network}-config 2> /dev/null | wc -l")"
if [[ $remote_dir_count -lt 1 ]]; then
fatal "Remote Directory is empty. Run \033[1mcopy_gateway-config.sh ${_network}\033[m on remote host first."
fi
mkdir -p $OFFICE_DIR
cd $OFFICE_DIR