#!/bin/bash help() { echo "Usage: doinit-remote [ -h | -help | --help | ]" echo "Init borgmatic configuration for a remote computer." } # help=0 if (( $# != 1)); then help=1 else for parameter in $@; do if [ "$parameter" == "-h" ] || [ "$parameter" == "-help" ] || [ "$parameter" == "--help" ]; then help=1 fi done fi if (( $help )); then help else COMPUTER="$1" echo "== Create the borgmatic configuration file." cp /srv/borg/models/model-conf-remote.yaml /etc/borgmatic.d/${COMPUTER}.yaml echo "== Update the repository directory in borgmatic configuration file." sed -i s/\/${COMPUTER}/g /etc/borgmatic.d/${COMPUTER}.yaml echo "== Verify the bogmatic configuration file." validate-borgmatic-config echo "== Create the repository directory." /srv/borg/bin/doinit ${COMPUTER} fi