2 Commits
2 changed files with 46 additions and 21 deletions

No files matched your search

+40 -20
View File
@@ -31,6 +31,9 @@ CONTAINER_EXEC_USER=" $PODMAN exec"
CONTAINER_SVC_UPDATE_USER=" $PODMAN auto-update" CONTAINER_SVC_UPDATE_USER=" $PODMAN auto-update"
CONTAINER_EXEC="podman exec" CONTAINER_EXEC="podman exec"
tagP1=".backup#"
tagP2=".tag"
LOG_RECIPIENT=hb242@pm.me LOG_RECIPIENT=hb242@pm.me
INFO=INFO INFO=INFO
WARN=WARN WARN=WARN
@@ -161,6 +164,8 @@ start_containers() {
if [ -d /var/containers ]; then if [ -d /var/containers ]; then
do_start_stop_containers start do_start_stop_containers start
let rc=rc+$? let rc=rc+$?
# warten bis alle wieder da sind
sleep 2m
fi fi
return $rc return $rc
} }
@@ -205,22 +210,22 @@ do_start_stop_containers() {
update_services() { update_services() {
log $DEBUG "$DBG update_services()" log $DEBUG "$DBG update_services()"
mail_log $INFO "$INF update services" mail_log $INFO "$INF update services"
local old_img=$($PODMAN ps --format "table {{.ImageID}} {{.Names}} {{.Image}}" --sort names) local old_img=$($PODMAN ps --filter "label=io.containers.autoupdate=registry" --format "table {{.ImageID}} {{.Names}} {{.Image}}" --sort names)
echo "$old_img" >>$LOG_FILE 2>&1 echo "$old_img" >>$LOG_FILE 2>&1
local plan=$($CONTAINER_SVC_UPDATE_USER --dry-run --format "{{.Image}} {{.Updated}}" 2>&1 | grep pending | sed 's/^\(.*\) pending/\1/') local plan=$($CONTAINER_SVC_UPDATE_USER --dry-run --format "{{.Image}} {{.Updated}}" 2>&1 | grep pending | sed 's/^\(.*\) pending/\1/')
local upd=$($CONTAINER_SVC_UPDATE_USER --format "table {{.Image}} {{.Updated}}" 2>&1 | tee -a $LOG_FILE | grep true | sed 's/^\(.*\) true/\1/')
check_pipe_rc ${PIPESTATUS[@]}
local rc=$?
# warten bis alle wieder da sind (wg. ps)
sleep 20
local new_img=$($PODMAN ps --format "table {{.ImageID}} {{.Names}} {{.Image}}" --sort names)
echo "$new_img" >>$LOG_FILE 2>&1
for i in $plan; do for i in $plan; do
mail_log $INFO "$INF pending: $i" mail_log $INFO "$INF pending: $i"
done done
local upd=$($CONTAINER_SVC_UPDATE_USER --format "table {{.Image}} {{.Updated}}" 2>&1 | tee -a $LOG_FILE | grep true | sed 's/^\(.*\) true/\1/')
check_pipe_rc ${PIPESTATUS[@]}
local rc=$?
for i in $upd; do for i in $upd; do
mail_log $INFO "$INF updated: $i" mail_log $INFO "$INF updated: $i"
done done
# warten bis alle wieder da sind (wg. ps)
sleep 2m >>$LOG_FILE 2>&1
local new_img=$($PODMAN ps --filter "label=io.containers.autoupdate=registry" --format "table {{.ImageID}} {{.Names}} {{.Image}}" --sort names)
echo "$new_img" >>$LOG_FILE 2>&1
# diff output bring zu wenig # diff output bring zu wenig
#log $DEBUG "$DBG diff before after" #log $DEBUG "$DBG diff before after"
#local diff_img=$(diff <(echo "$old_img") <(echo "$new_img")) #local diff_img=$(diff <(echo "$old_img") <(echo "$new_img"))
@@ -757,8 +762,8 @@ mount_usb_device() {
fi fi
} }
# Check if auto mounted device is exfat and return mount point # Check if auto mounted device is exfat or vfat and return mount point
# (fn for consitence with linux fn) # (fn for consistence with linux fn)
# #
# $1 - device name # $1 - device name
# returns mount point # returns mount point
@@ -768,7 +773,7 @@ mount_usb_device_syno() {
local device=$1 local device=$1
log $DEBUG "$DBG > $SYNO_USB -info $device | grep -i \"file system\" | sed -E \"s/.*:\s*(.*)\s*/\1/\"" log $DEBUG "$DBG > $SYNO_USB -info $device | grep -i \"file system\" | sed -E \"s/.*:\s*(.*)\s*/\1/\""
local fs=$($SYNO_USB -info $device 2>>$LOG_FILE | grep -i "file system" 2>>$LOG_FILE | sed -E "s/.*:\s*(.*)\s*/\1/" 2>>$LOG_FILE) local fs=$($SYNO_USB -info $device 2>>$LOG_FILE | grep -i "file system" 2>>$LOG_FILE | sed -E "s/.*:\s*(.*)\s*/\1/" 2>>$LOG_FILE)
if [ "$fs" != "exfat" ]; then if [ "$fs" != "exfat" && "$fs" != "vfat" ]; then
mail_log $ERROR "$ERR device $device not exfat formatted." mail_log $ERROR "$ERR device $device not exfat formatted."
return 1 return 1
fi fi
@@ -779,6 +784,7 @@ mount_usb_device_syno() {
mail_log $ERROR "$ERR mount point \"$mount_point\" does not exist." mail_log $ERROR "$ERR mount point \"$mount_point\" does not exist."
return 1 return 1
fi fi
mount_point=$(check_syno_mount_point $mount_point)
echo $mount_point echo $mount_point
return 0 return 0
} }
@@ -843,6 +849,28 @@ umount_usb_device_linux() {
return $? return $?
} }
# Mit GUID-Partitontable meldet Synology die falsche Partition (/volumeUSB1/usbshare1-1)
# zusätzlich auf ggf. vorhandener 2. Partition (*1-2) suchen
#
# $1 - mount point
#
check_syno_mount_point() {
log $DEBUG "$DBG check_syno_mount_point( $@ )"
local mount_point=$1
log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | wc -l"
if [ "$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then
log $DEBUG "No tag at mount point \"$mount_point\". Checking next partiton."
mount_point=$(echo $mount_point | sed -E "s/(.*1)-1/\1-2/")
if [ "$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then
mail_log $ERROR "$ERR no tag found on device at $mount_point."
return 1
fi
fi
echo $mount_point
}
# USB-HDD suchen und Backup-Typ ermitteln # USB-HDD suchen und Backup-Typ ermitteln
# #
# Der Typ wird über eine Datei auf der USB-HDD festgelegt: # Der Typ wird über eine Datei auf der USB-HDD festgelegt:
@@ -853,19 +881,11 @@ umount_usb_device_linux() {
check_backup_device() { check_backup_device() {
log $DEBUG "$DBG check_backup_drive( $@ )" log $DEBUG "$DBG check_backup_drive( $@ )"
local mount_point=$1 local mount_point=$1
local tagP1=".backup#"
local tagP2=".tag"
log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | wc -l"
if [ "$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then
mail_log $ERROR "$ERR no tag found on device at $mount_point."
return 1
fi
log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | sed -E \"s/.*$tagP1(.*)$tagP2/\1/\"" log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | sed -E \"s/.*$tagP1(.*)$tagP2/\1/\""
local tag=$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | sed -E "s/.*$tagP1(.*)$tagP2/\1/" 2>>$LOG_FILE) local tag=$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | sed -E "s/.*$tagP1(.*)$tagP2/\1/" 2>>$LOG_FILE)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
mail_log $ERROR "$ERR no tag found on device at $mount_point." mail_log $ERROR "$ERR no valid tag found on device at $mount_point."
return 1 return 1
fi fi
echo $tag echo $tag
+6 -1
View File
@@ -3,6 +3,11 @@
# entrypoint for all actions # entrypoint for all actions
# #
# 2.2.4 30.07.2025 - inc delay (again) for container startup-check (2m)
# 2.2.3 24.06.2025 - Export-Disk kann exfat- oder vfat-formatiert sein,
# Export-Disk mit mehreren Partitonen erkennen
# 2.2.2 19.06.2025 - inc delay for container startup check, fix error in log output
# 2.2.1 16.06.2025 - delay container startup check
# 2.2.0 16.05.2025 - fixes for auto-update, podman migration done # 2.2.0 16.05.2025 - fixes for auto-update, podman migration done
# 2.1.17 11.05.2025 - bugfixes, sort tar archive, split daily/cron daily # 2.1.17 11.05.2025 - bugfixes, sort tar archive, split daily/cron daily
# 2.1.16 10.05.2025 - fix mail.sh, log results of auto-update # 2.1.16 10.05.2025 - fix mail.sh, log results of auto-update
@@ -17,7 +22,7 @@
# 2.1.7 29.04.2025 - 1. Schritt zur Umstellung auf podman # 2.1.7 29.04.2025 - 1. Schritt zur Umstellung auf podman
# 2.1.6 29.04.2025 - weekly backup Sa->SO # 2.1.6 29.04.2025 - weekly backup Sa->SO
VER="2.2.0" VER="2.2.4"
HERE=$(dirname "$0") HERE=$(dirname "$0")
THIS_SCRIPT=$0 THIS_SCRIPT=$0