use our tool finder
This commit is contained in:
parent
9584e5d415
commit
669500bbcb
57
remote-backup
Normal file → Executable file
57
remote-backup
Normal file → Executable file
@ -6,20 +6,59 @@
|
|||||||
# rotating backup-snapshots of /home whenever called
|
# rotating backup-snapshots of /home whenever called
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
unset PATH # suggestion from H. Milz: avoid accidental use of $PATH
|
#unset PATH # suggestion from H. Milz: avoid accidental use of $PATH
|
||||||
|
|
||||||
# ------------- system commands used by this script --------------------
|
# ------------- system commands used by this script --------------------
|
||||||
ID=/usr/bin/id;
|
|
||||||
ECHO=/bin/echo;
|
|
||||||
|
|
||||||
MOUNT=/bin/mount;
|
###BEGIN: generic tool checker
|
||||||
RM=/bin/rm;
|
# FIXME: To reuse this function, be sure to edit this line (space separated
|
||||||
MV=/bin/mv;
|
# list).
|
||||||
CP=/bin/cp;
|
needed_tools="id echo mount rm mv cp touch rsync"
|
||||||
TOUCH=/bin/touch;
|
#
|
||||||
|
# One shall not need edit anything below this line
|
||||||
|
###
|
||||||
|
checktools() {
|
||||||
|
# This functions attempts to be generic enough to be reused in any program
|
||||||
|
# that needs to check that specific tools are present on the system
|
||||||
|
# and can be found in the PATH
|
||||||
|
var=$(echo $1 | tr '[:lower:]' '[:upper:]')
|
||||||
|
echo -n "# Looking for $1... "
|
||||||
|
local_var="$(which $1)"
|
||||||
|
eval $var="$local_var"
|
||||||
|
if [ -z "$local_var" ]
|
||||||
|
then
|
||||||
|
echo 'NOT FOUND!'
|
||||||
|
NOTFOUND="$NOTFOUND$1 "
|
||||||
|
DIE=1
|
||||||
|
else
|
||||||
|
echo "$local_var"
|
||||||
|
FOUND="$FOUND$1 "
|
||||||
|
fi
|
||||||
|
unset local_var
|
||||||
|
}
|
||||||
|
|
||||||
RSYNC=/usr/bin/rsync;
|
for tool in $needed_tools
|
||||||
|
do
|
||||||
|
checktools "$tool"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "# Found $FOUND"
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ -n "$DIE" ]
|
||||||
|
then
|
||||||
|
echo "Some tools were not found, please check your installation" >&2
|
||||||
|
echo "Needed tools: $needed_tools" >&2
|
||||||
|
echo -n "Not found:" >&2
|
||||||
|
for tool in $NOTFOUND
|
||||||
|
do
|
||||||
|
echo -n " $tool" >&2
|
||||||
|
done
|
||||||
|
echo '!' >&2
|
||||||
|
exit 127
|
||||||
|
fi
|
||||||
|
###END: generic tool checker
|
||||||
|
|
||||||
# ------------- file locations -----------------------------------------
|
# ------------- file locations -----------------------------------------
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user