init.sh: remote path parameter validation
This commit is contained in:
parent
0a9a5f9a71
commit
06cf4d8bde
1 changed files with 9 additions and 7 deletions
14
init.sh
14
init.sh
|
@ -3,7 +3,7 @@
|
|||
SELF="$0"
|
||||
HOST=""
|
||||
PORT="22"
|
||||
REMOTE_PATH="borg"
|
||||
REMOTE_PATH=""
|
||||
NAME=""
|
||||
LOGIN="$(whoami)"
|
||||
|
||||
|
@ -11,6 +11,11 @@ die () {
|
|||
echo -e $1 | sed -e 's-^-! -' >&2
|
||||
exit 1
|
||||
}
|
||||
usage() {
|
||||
echo -e "usage: $SELF PROFILE_NAME --host=server --port=22 --login=backup-user --directory=/backup/path" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
generate_passphrase() {
|
||||
tr -dc A-Za-z0-9 </dev/urandom | head -c 64
|
||||
}
|
||||
|
@ -59,7 +64,7 @@ test_repo_exists() {
|
|||
}
|
||||
invoke_borg() {
|
||||
# do some sandboxinng
|
||||
systemd-run --pipe --collect --unit=temp-borg-init-sandbox.service \
|
||||
systemd-run --quiet --pipe --collect --unit=temp-borg-init-sandbox.service \
|
||||
--working-directory=/tmp \
|
||||
-p "ConfigurationDirectory=borg/$NAME" \
|
||||
-p "CacheDirectory=borg/$NAME" \
|
||||
|
@ -83,10 +88,6 @@ show_repo() {
|
|||
invoke_borg info || die "failed to access borg repo"
|
||||
}
|
||||
|
||||
usage() {
|
||||
die "Usage: $SELF PROFILE_NAME --host=server --port=22 --login=backup-user --directory=/backup/path"
|
||||
}
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
-h*)
|
||||
|
@ -124,6 +125,7 @@ for arg in "$@"; do
|
|||
done
|
||||
|
||||
[ "x$NAME" == "x" ] && usage
|
||||
[ "x$REMOTE_PATH" == "x" ] && usage
|
||||
|
||||
CONFIGDIR="/etc/borg/$NAME"
|
||||
|
||||
|
|
Loading…
Reference in a new issue