Add ability to have custom scripts

pull/142/head
modem7 2024-04-24 21:09:28 +01:00
rodzic face292d3f
commit 37d5e7f819
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 2C37853D96B6D9E9
8 zmienionych plików z 35 dodań i 4 usunięć

Wyświetl plik

@ -41,8 +41,16 @@ It uses cron to run the backups at a time you can configure in `data/borgmatic.d
| CRON_COMMAND | Command cron will run | borgmatic --stats -v 0 2>&1 | borgmatic --stats -v 0 2>&1 |
| EXTRA_CRON | Extra cron lines | 0 5 2 * * command1 | Empty |
## Breaking change
dockercli tag has been removed as there is now a variable to install it at container startup.
## Customising the container
Simply mount a volume located at /custom-cont-init.d and add any scripts you want. These scripts can contain logic for installing packages, copying over custom files to other locations, or installing plugins.
For example:
```yaml
services:
borgmatic:
volumes:
- /home/foo/my-custom-files:/custom-cont-init.d:ro
```
### Usage

Wyświetl plik

@ -2,13 +2,13 @@
# Install DockerCLI if true
if [ "${DOCKERCLI}" == "true" ]; then
echo "Installing Docker CLI and Compose..."
echo "[custom-init] Installing Docker CLI and Compose..."
apk add -U --quiet docker-cli docker-cli-compose
fi
# Install additional packages
if [ -v EXTRA_PKGS ]
then
echo Installing extra packages: "$EXTRA_PKGS"
echo "[custom-init] Installing extra packages: $EXTRA_PKGS"
apk add -U --quiet $EXTRA_PKGS
fi

Wyświetl plik

@ -0,0 +1,21 @@
#!/usr/bin/with-contenv bash
# Directories
SCRIPTS_DIR="/custom-cont-init.d"
# Make sure custom init directory exists and has files in it
if [[ -e "${SCRIPTS_DIR}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]]; then
echo "[custom-init] Files found, executing"
for SCRIPT in "${SCRIPTS_DIR}"/*; do
NAME="$(basename "${SCRIPT}")"
if [[ -f "${SCRIPT}" ]]; then
echo "[custom-init] ${NAME}: executing..."
/bin/bash "${SCRIPT}"
echo "[custom-init] ${NAME}: exited $?"
elif [[ ! -f "${SCRIPT}" ]]; then
echo "[custom-init] ${NAME}: is not a file"
fi
done
else
echo "[custom-init] No custom files found, skipping..."
fi

Wyświetl plik

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-custom-scripts/run