40 lines
946 B
Plaintext
40 lines
946 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
help()
|
||
|
{
|
||
|
echo "Usage: doinit-rsync [ -h | -help | --help | <COMPUTER> ]"
|
||
|
echo "Init borgmatic configuration for a rsync mirror."
|
||
|
}
|
||
|
|
||
|
#
|
||
|
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"
|
||
|
|
||
|
# TODOOOOOOOOOOOOOOOOOOOOOOOOOO
|
||
|
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/\<HOSTNAME\>/${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
|
||
|
|