Files
4server/app/sbin/checkCalls
T
2026-09-27 10:39:11 -03:00

49 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
_self="$(realpath "${BASH_SOURCE[0]:-$0}")"; SBIN="$(dirname "$_self")"
source "$SBIN/helpers"
cd /4server/data/
while :
do
# nullglob: if no subdirectories exist the loop body is skipped entirely
shopt -s nullglob
for dir in */; do
dir="${dir%/}"
[ -z "$dir" ] && continue
if [ -d "${dir}/cc" ]; then
if [ -f "${dir}/cc/backup" ]; then
log "BACKUP for: $dir"
"$SBIN/backupContainer" "$dir"
rm "${dir}/cc/backup"
fi
if [ -f "${dir}/cc/restart" ]; then
log "Restart for: $dir"
"$SBIN/startContainer" "$dir"
rm "${dir}/cc/restart"
fi
if [ -f "${dir}/cc/restore" ]; then
FILENAME=$(head -n 1 "${dir}/cc/restore")
log "Restore for: $dir - $FILENAME"
"$SBIN/odoo/restore" "$dir" "$FILENAME"
rm "${dir}/cc/restore"
fi
fi
if [ -d "${dir}/n8n" ]; then
if [ -f "${dir}/n8n/database.sqlite-journal" ]; then
log "Restart N8N (journal) for: $dir"
"$SBIN/startContainer" "$dir"
fi
fi
done
sleep 60
done