feat(tilo): enable cron job for Nextcloud docker container
This commit is contained in:
parent
683796549f
commit
a7f280cf30
@ -71,4 +71,4 @@ This will set up an environment with:
|
|||||||
|
|
||||||
## Contributing
|
## 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.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
../../modules/ssh.nix
|
../../modules/ssh.nix
|
||||||
../../modules/endlessh.nix
|
../../modules/endlessh.nix
|
||||||
../../programs/nano.nix
|
../../programs/nano.nix
|
||||||
|
./services
|
||||||
];
|
];
|
||||||
|
|
||||||
system = {
|
system = {
|
||||||
|
3
hosts/tilo/services/default.nix
Normal file
3
hosts/tilo/services/default.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
imports = [./nextcloud-cron.nix];
|
||||||
|
}
|
33
hosts/tilo/services/nextcloud-cron.nix
Normal file
33
hosts/tilo/services/nextcloud-cron.nix
Normal 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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user