feat(tilo): enable cron job for Nextcloud docker container

This commit is contained in:
Lucien Cartier-Tilet 2025-06-04 19:08:12 +02:00
parent 683796549f
commit a7f280cf30
Signed by: phundrak
SSH Key Fingerprint: SHA256:5IBMlJF+Zue11FtWK5bLZw2WOy2PshX3ATth2H5JMoQ
4 changed files with 38 additions and 1 deletions

View File

@ -71,4 +71,4 @@ This will set up an environment with:
## Contributing
Feel free to fork this repository and make your own changes. If you have any improvements or suggestions, please open an issue or submit a pull request.
Feel free to fork this repository and make your own changes. If you have any improvements or suggestions, please open an issue or submit a pull request.

View File

@ -14,6 +14,7 @@
../../modules/ssh.nix
../../modules/endlessh.nix
../../programs/nano.nix
./services
];
system = {

View File

@ -0,0 +1,3 @@
{
imports = [./nextcloud-cron.nix];
}

View File

@ -0,0 +1,33 @@
{pkgs, ...}: {
systemd = {
timers."nextcloud-cron" = {
wantedBy = ["timers.target"];
timerConfig = {
OnBootSec = "20m";
OnUnitActiveSec = "20m";
Unit = "nextcloud-cron.service";
};
};
services."nextcloud-cron" = {
script = ''
CONTAINER_NAME="nextcloud-nextcloud-1"
is_container_running() {
${pkgs.docker}/bin/docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"
}
while ! is_container_running; do
echo "Waiting for $CONTAINER_NAME to start..."
sleep 10
done
echo "$CONTAINER_NAME is running. Executing CRON job..."
${pkgs.docker}/bin/docker exec -u www-data -it nextcloud-nextcloud-1 php /var/www/html/cron.php
'';
serviceConfig = {
Type = "oneshot";
User = "root";
};
};
};
}