2023-01-23 20:29:20 -08:00
{{- if (eq .host.distro.family "linux") -}}
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
2023-01-23 20:44:59 -08:00
### Docker push-rm
2023-01-29 20:44:55 -08:00
if [ ! -f " ${ XDG_CONFIG_HOME : - $ HOME / . config } /docker/cli-plugins/docker-pushrm" ]; then
2023-01-23 20:44:59 -08:00
logg info 'Acquiring release information for Docker push-rm'
RELEASE_TAG="$(curl -sSL https://api.github.com/repos/christian-korneck/docker-pushrm/releases/latest | jq -r '.tag_name')"
2023-01-29 19:09:02 -08:00
mkdir -p " ${ XDG_CONFIG_HOME : - $ HOME / . config } /docker/cli-plugins"
2023-01-23 20:44:59 -08:00
logg info 'Downloading Docker push-rm'
2023-01-29 19:09:02 -08:00
curl https://github.com/christian-korneck/docker-pushrm/releases/download/ $ RELEASE_TAG /docker-pushrm_darwin_amd64 -o " ${ XDG_CONFIG_HOME : - $ HOME / . config } /docker/cli-plugins/docker-pushrm"
chmod +x " ${ XDG_CONFIG_HOME : - $ HOME / . config } /docker/cli-plugins/docker-pushrm"
2023-01-23 20:44:59 -08:00
logg success 'Added Docker push-rm'
else
logg info 'Docker push-rm already added'
fi
2023-01-29 20:44:55 -08:00
### Docker Rclone plugin
# Source: https://rclone.org/docker/
2023-02-04 00:19:52 -08:00
# First, ensure Docker Rclone configuration exists (which only happens when the Chezmoi Age decryption key is present as well as keys for Rclone)
if [ -f " ${ XDG_CONFIG_HOME : - $ HOME / . config } /rclone/docker-rclone.conf" ]; then
### Ensure Docker Rclone plugin system folders exist
logg info 'Ensure Docker Rclone plugin system folders exist'
if [ ! -d /var/lib/docker-plugins/rclone/config ]; then
logg info 'Creating directory /var/lib/docker-plugins/rclone/config'
sudo mkdir -p /var/lib/docker-plugins/rclone/config
fi
if [ ! -d /var/lib/docker-plugins/rclone/cache ]; then
logg info 'Creating directory /var/lib/docker-plugins/rclone/cache'
sudo mkdir -p /var/lib/docker-plugins/rclone/cache
fi
### Copy Rclone configuration
logg info "Copy the Rclone configuration from ${ XDG_CONFIG_HOME : - $ HOME / . config } /rclone/docker-rclone.conf to /var/lib/docker-plugins/rclone/config/rclone.conf"
sudo cp -f " ${ XDG_CONFIG_HOME : - $ HOME / . config } /rclone/docker-rclone.conf" /var/lib/docker-plugins/rclone/config/rclone.conf
### Install the Rclone Docker plugin (if not already installed)
if ! sudo su -c 'docker plugin ls' - " $ USER " | grep 'rclone:latest' > /dev/null; then
sudo su -c 'docker plugin install rclone/docker-volume-rclone:amd64 args="-v" --alias rclone --grant-all-permissions' - " $ USER "
fi
2023-01-29 20:44:55 -08:00
fi
2023-01-29 19:09:02 -08:00
2023-01-23 20:44:59 -08:00
{{ end -}}