2022-04-05 01:12:07 +08:00
|
|
|
#!/bin/bash
|
2021-11-30 18:20:42 +08:00
|
|
|
|
|
|
|
while true; do
|
2022-04-05 01:12:07 +08:00
|
|
|
if [ -f "/mnt/docker-aio-config/data/daily_backup_time" ]; then
|
|
|
|
set -x
|
2022-07-11 03:47:25 +08:00
|
|
|
BACKUP_TIME="$(head -1 "/mnt/docker-aio-config/data/daily_backup_time")"
|
|
|
|
export BACKUP_TIME
|
|
|
|
export DAILY_BACKUP=1
|
|
|
|
if [ "$(sed -n '2p' "/mnt/docker-aio-config/data/daily_backup_time")" != 'automaticUpdatesAreNotEnabled' ]; then
|
|
|
|
export AUTOMATIC_UPDATES=1
|
|
|
|
else
|
|
|
|
export AUTOMATIC_UPDATES=0
|
|
|
|
export START_CONTAINERS=1
|
|
|
|
fi
|
2023-10-09 23:18:40 +08:00
|
|
|
if [ "$(sed -n '3p' "/mnt/docker-aio-config/data/daily_backup_time")" != 'successNotificationsAreNotEnabled' ]; then
|
|
|
|
export SEND_SUCCESS_NOTIFICATIONS=1
|
|
|
|
else
|
|
|
|
export SEND_SUCCESS_NOTIFICATIONS=0
|
|
|
|
fi
|
2022-04-05 01:12:07 +08:00
|
|
|
set +x
|
2022-11-20 08:36:55 +08:00
|
|
|
if [ -f "/mnt/docker-aio-config/data/daily_backup_running" ]; then
|
|
|
|
export LOCK_FILE_PRESENT=1
|
|
|
|
else
|
|
|
|
export LOCK_FILE_PRESENT=0
|
|
|
|
fi
|
2022-04-05 01:12:07 +08:00
|
|
|
else
|
2022-07-11 03:47:25 +08:00
|
|
|
export BACKUP_TIME="04:00"
|
|
|
|
export DAILY_BACKUP=0
|
|
|
|
export LOCK_FILE_PRESENT=0
|
2022-04-05 01:12:07 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Allow to continue directly if e.g. the mastercontainer was updated. Otherwise wait for the next execution
|
|
|
|
if [ "$LOCK_FILE_PRESENT" = 0 ]; then
|
|
|
|
while [ "$(date +%H:%M)" != "$BACKUP_TIME" ]; do
|
2022-05-29 22:30:45 +08:00
|
|
|
sleep 30
|
2022-04-05 01:12:07 +08:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$DAILY_BACKUP" = 1 ]; then
|
2022-07-11 03:47:25 +08:00
|
|
|
bash /daily-backup.sh
|
2022-04-05 01:12:07 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure to delete the lock file always
|
|
|
|
rm -f "/mnt/docker-aio-config/data/daily_backup_running"
|
|
|
|
|
2023-03-07 16:29:04 +08:00
|
|
|
# Check for updates and send notification if yes on saturdays
|
|
|
|
if [ "$(date +%u)" = 6 ]; then
|
|
|
|
sudo -u www-data php /var/www/docker-aio/php/src/Cron/UpdateNotification.php
|
|
|
|
fi
|
2022-04-05 01:12:07 +08:00
|
|
|
|
2022-11-17 20:38:09 +08:00
|
|
|
# Check if AIO is outdated
|
|
|
|
sudo -u www-data php /var/www/docker-aio/php/src/Cron/OutdatedNotification.php
|
|
|
|
|
2022-03-08 22:16:16 +08:00
|
|
|
# Remove sessions older than 24h
|
|
|
|
find "/mnt/docker-aio-config/session/" -mindepth 1 -mmin +1440 -delete
|
2022-04-05 01:12:07 +08:00
|
|
|
|
2023-02-23 01:03:48 +08:00
|
|
|
# Remove nextcloud-aio-domaincheck container
|
2023-02-24 01:19:51 +08:00
|
|
|
if sudo -u www-data docker ps --format "{{.Names}}" --filter "status=exited" | grep -q "^nextcloud-aio-domaincheck$"; then
|
2023-02-24 01:05:34 +08:00
|
|
|
sudo -u www-data docker container remove nextcloud-aio-domaincheck
|
|
|
|
fi
|
2023-02-23 01:03:48 +08:00
|
|
|
|
2022-04-05 01:12:07 +08:00
|
|
|
# Remove dangling images
|
2023-02-23 01:03:48 +08:00
|
|
|
sudo -u www-data docker image prune --force
|
2022-05-29 22:30:45 +08:00
|
|
|
|
2023-06-25 07:27:44 +08:00
|
|
|
# Check for available free space
|
|
|
|
sudo -u www-data php /var/www/docker-aio/php/src/Cron/CheckFreeDiskSpace.php
|
|
|
|
|
2023-06-04 00:05:29 +08:00
|
|
|
# Remove mastercontainer from default bridge network
|
|
|
|
if sudo -u www-data docker inspect nextcloud-aio-mastercontainer --format "{{.NetworkSettings.Networks}}" | grep -q "bridge"; then
|
|
|
|
sudo -u www-data docker network disconnect bridge nextcloud-aio-mastercontainer
|
|
|
|
fi
|
|
|
|
|
2022-05-29 22:30:45 +08:00
|
|
|
# Wait 60s so that the whole loop will not be executed again
|
|
|
|
sleep 60
|
2021-11-30 18:20:42 +08:00
|
|
|
done
|