aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlo Landmeter <clandmeter@alpinelinux.org>2018-02-03 21:22:02 +0000
committerCarlo Landmeter <clandmeter@alpinelinux.org>2018-02-03 21:22:02 +0000
commit6e2d2f2d67ae1c94d0294c8fab107cc405563486 (patch)
treedf2253ad02bd0bb4ccaec9b38713df8578e41fb1
parent7bf994d754dece6092ea3991640fd7e0c78e5d76 (diff)
downloadalpine-backup-6e2d2f2d67ae1c94d0294c8fab107cc405563486.tar.bz2
alpine-backup-6e2d2f2d67ae1c94d0294c8fab107cc405563486.tar.xz
check basic command are installed
-rwxr-xr-xalpine-backup18
1 files changed, 13 insertions, 5 deletions
diff --git a/alpine-backup b/alpine-backup
index 9d39ee1..fb6549e 100755
--- a/alpine-backup
+++ b/alpine-backup
@@ -1,19 +1,28 @@
#!/bin/sh
RBU_CONF=/etc/lbu/rbu.conf
+CMD_DEPS="mosquitto_pub openssl rsync ssh"
+
+die() {
+ echo "$@" >&2
+ exit 1
+}
+
+for cmd in $CMD_DEPS; do
+ command -v $cmd >/dev/null 2>&1 || \
+ die "Error: command \"$cmd\" not found."
+done
if [ -f "$RBU_CONF" ]; then
. "$RBU_CONF"
else
- echo "Cannot read $RBU_CONF"
- exit 1
+ die "Cannot read $RBU_CONF"
fi
if [ -n "$BACKUP_LOCATION" ] && [ -n " $BACKUP_CACHE" ]; then
mkdir -p "$BACKUP_LOCATION" "$BACKUP_CACHE"
else
- echo "Error: BACKUP_LOCATION and/or BACKUP_CACHE are not set!"
- exit 1
+ die "Error: BACKUP_LOCATION and/or BACKUP_CACHE are not set."
fi
# set the suffix of backup files when ecryptions is enabled
@@ -38,7 +47,6 @@ SIZE=0
STATUS=failed
if [ $ret = 0 ]; then
- [ -n "$ENCRYPTION" ] && SUFFIX=".$ENCRYPTION"
BACKUP="$BACKUP_LOCATION/$(hostname).apkovl.tar.gz${SUFFIX}"
SIZE=$(stat -c %s $BACKUP)
STATUS=success