Check and install rsync if missing

This commit is contained in:
2021-03-28 23:39:46 +02:00
parent 52d03c3730
commit c75ec7ddeb

View File

@@ -1,10 +1,12 @@
#!/bin/bash #!/bin/bash
toolName=backup toolName=backup
toolBin=rsync
# Get script working directory # Get script working directory
# (when called from a different directory) # (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )" WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
APTOPT=
CONFIG=0 CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg" CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
@@ -15,7 +17,12 @@ step_config() {
CONFIG=1 CONFIG=1
else else
echoerr " [E] Check output for errors" echoerr " [E] Check output for errors"
# End if no configuration file exists
[ $DRY -eq 0 ] && return -1
fi fi
[ $QUIET -ne 0 ] && APTOPT="-y"
return 0
} }
step_1_info() { step_1_info() {
@@ -145,15 +152,31 @@ step_3() {
echoerr " [E] Backup target (${buTarget}) is not writable" echoerr " [E] Backup target (${buTarget}) is not writable"
exit 1 exit 1
fi fi
checkInstalled
exep "mv -f ${buTarget}/${buLog}0.log /tmp/${buLog}1.log 2>/dev/null" exep "mv -f ${buTarget}/${buLog}0.log /tmp/${buLog}1.log 2>/dev/null"
exep "rsync -avxHAX --delete --info=stats2 ${buExcludes[*]} ${tmpSource} ${tmpTarget} > /tmp/${buLog}0.log" exep "$toolBin -avxHAX --delete --info=stats2 ${buExcludes[*]} ${tmpSource} ${tmpTarget} > /tmp/${buLog}0.log"
exe mv -f /tmp/${buLog}*.log ${buTarget} exe mv -f /tmp/${buLog}*.log ${buTarget}
exe sync exe sync
exep "mount -o ro,remount '${buTarget}' >>/dev/null 2>&1" exep "mount -o ro,remount '${buTarget}' >>/dev/null 2>&1"
} }
VERSION_SEQREV=10 step_100_info() { echo "Install $toolBin"; }
step_100_alias() { ALIAS="install"; }
step_100() {
exe apt update
exe apt install $toolBin $APTOPT
}
checkInstalled() {
command -v $toolBin >>/dev/null
if [ $? -ne 0 ] ; then
step install
fi
toolBin="$(command -v $toolBin)"
}
VERSION_SEQREV=12
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh