Porównaj commity

...

6 Commity

Autor SHA1 Wiadomość Data
modem7 fa9bec5e5e
Optimise and fix s6 2024-04-25 07:45:35 +01:00
modem7 37d5e7f819
Add ability to have custom scripts 2024-04-24 22:59:46 +01:00
modem7 face292d3f
added custom packages in s6 2024-04-24 20:40:31 +01:00
modem7 99ca225aa3
allow ability for additional packages 2024-04-24 16:45:20 +01:00
modem7 20643ba32f
add docker secrets ability 2024-04-24 16:25:12 +01:00
modem7 8416343d33
Add docker compose to docker install 2024-04-24 16:16:08 +01:00
13 zmienionych plików z 109 dodań i 20 usunięć

Wyświetl plik

@ -35,13 +35,22 @@ It uses cron to run the backups at a time you can configure in `data/borgmatic.d
# Environment Variables
| Variable | Description | Possible Values | Default |
| :----: | --- | --- | --- |
| DOCKERCLI | Install DockerCLI | true | Empty |
| CRON | Cron times | cron time, disabled | 0 1 * * * |
| DOCKERCLI | Install DockerCLI and ComposeCLI | true | Empty |
| EXTRA_PKGS | Install additional packages | rclone coreutils jq other_packages | Empty |
| CRON | Cron times | cron time, false | 0 1 * * * |
| 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

@ -74,7 +74,7 @@ RUN --mount=type=cache,id=pip,target=/root/.cache,sharing=locked \
borgmatic --bash-completion > "$(pkg-config --variable=completionsdir bash-completion)"/borgmatic
EOF
COPY --link root/ /
COPY --chmod=744 --link root/ /
VOLUME /root/.borgmatic
VOLUME /root/.config/borg

Wyświetl plik

@ -0,0 +1 @@
# This file doesn't do anything, it's just the end of the downstream image init process

Wyświetl plik

@ -0,0 +1,17 @@
#!/command/with-contenv bash
# Install DockerCLI if true
if [ "${DOCKERCLI}" == "true" ]; then
echo "[custom-init] Installing Docker CLI and Docker Compose..."
apk add -U --quiet docker-cli docker-cli-compose
else
echo "[custom-init] Docker CLI variable not set, skipping..."
fi
# Install additional packages
if [ -v EXTRA_PKGS ]; then
echo "[custom-init] Installing extra packages: $EXTRA_PKGS"
apk add -U --quiet $EXTRA_PKGS
else
echo "[custom-init] No custom packages found, skipping..."
fi

Wyświetl plik

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

Wyświetl plik

@ -1,4 +1,4 @@
#!/bin/bash
#!/command/with-contenv bash
if test "$1" -eq 256 ; then
e=$((128 + $2))
@ -7,4 +7,4 @@ else
fi
echo "Received exit code $e."
echo "$e" > /run/s6-linux-init-container-results/exitcode
echo "$e" > /run/s6-linux-init-container-results/exitcode

Wyświetl plik

@ -1,13 +1,4 @@
#!/usr/bin/with-contenv bash
# Install DockerCLI if true
if [ "${DOCKERCLI:-}" == "true" ]; then
echo "Installing Docker CLI..."
apk add -U --quiet docker-cli
dockerver=$(docker --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
else
dockerver="not installed"
fi
#!/command/with-contenv bash
# Version variables
borgver=$(borg --version)
@ -15,21 +6,89 @@ borgmaticver=$(borgmatic --version)
apprisever=$(apprise --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
pythonver=$(python3 --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
if [ "${DOCKERCLI}" == "true" ]; then
dockerver=$(docker --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
composever=$(docker compose version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
else
dockerver="not installed"
composever="not installed"
fi
# Software versions
echo "-----------------------------------"
echo "Software Versions:
-----------------------------------
apprise $apprisever
$borgver
borgmatic $borgmaticver
dockercli $dockerver
composecli $composever
python $pythonver
-----------------------------------
Time Zone: $TZ
-----------------------------------
"
-----------------------------------"
if [ -v EXTRA_PKGS ]
then
echo "Additional packages installed:"
echo "-----------------------------------"
echo $EXTRA_PKGS | tr -s " " "\n"
echo "-----------------------------------"
fi
# Enable initial debug logging based on the DEBUG_SECRETS environment variable.
# Logs the initial values of BORG_PASSPHRASE and BORG_PASSPHRASE_FILE.
if [ "${DEBUG_SECRETS}" = "true" ] || [ "${DEBUG_SECRETS}" = "1" ]; then
echo "Before: BORG_PASSPHRASE: ${BORG_PASSPHRASE}"
echo "Before: BORG_PASSPHRASE_FILE: ${BORG_PASSPHRASE_FILE}"
echo "Before: YOUR_PASSPHRASE: ${YOUR_PASSPHRASE}"
echo "Before: YOUR_PASSPHRASE_FILE: ${YOUR_PASSPHRASE_FILE}"
fi
# Loop through all environment variables that start with 'BORG'.
for var_name in $(set | grep -E '^BORG|^YOUR' | awk -F= '{print $1}'); do
# Retrieve the current value of each environment variable.
var_value=$(eval echo \$$var_name)
# Check if the variable's name ends with '_FILE'.
if [[ "$var_name" =~ _FILE$ ]]; then
# Strip the '_FILE' suffix to obtain the corresponding variable name.
original_var_name=${var_name%_FILE}
# Retrieve the value of the original environment variable, if it exists.
original_var_value=$(eval echo \$$original_var_name)
# Ensure the *_FILE variable is valid, and the referenced file exists and is not empty.
if [ -n "$var_value" ] && [ -s "$var_value" ]; then
# Notify user if original variable is being overwritten.
if [ -n "$original_var_value" ]; then
echo "Note: $original_var_name was already set but is being overwritten by $var_name"
fi
# Update the original variable with the content of the file.
export "$original_var_name"=$(cat "$var_value")
echo "Setting $original_var_name from the content of $var_value"
# Unset the *_FILE environment variable.
unset "$var_name"
echo "Unsetting $var_name"
else
# Issue an error if the *_FILE variable is not properly set, or the file does not exist or is empty.
echo "Error: File $var_value does not exist or is empty."
fi
fi
done
# Enable final debug logging based on the DEBUG_SECRETS environment variable.
# Logs the final values of BORG_PASSPHRASE and BORG_PASSPHRASE_FILE.
if [ "${DEBUG_SECRETS}" = "true" ] || [ "${DEBUG_SECRETS}" = "1" ]; then
echo "Before: BORG_PASSPHRASE: ${BORG_PASSPHRASE}"
echo "Before: BORG_PASSPHRASE_FILE: ${BORG_PASSPHRASE_FILE}"
echo "Before: YOUR_PASSPHRASE: ${YOUR_PASSPHRASE}"
echo "Before: YOUR_PASSPHRASE_FILE: ${YOUR_PASSPHRASE_FILE}"
fi
# Disable cron if it's set to disabled.
if [[ "$CRON" =~ ^(false|disabled|off)$ ]]; then
if [[ "$CRON" = "false" ]]; then
echo "Disabling cron, removing configuration"
# crontab -r # quite destructive
# echo -n > /etc/crontabs/root # Empty config, doesn't look as nice with "crontab -l"