Finished create_source

This commit is contained in:
Nico Schottelius 2007-08-07 08:40:44 +02:00
parent 500bfc55e4
commit 78c3dc1bd7

View file

@ -9,10 +9,12 @@ CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect}
CSOURCES=$CCOLLECT_CONF/sources CSOURCES=$CCOLLECT_CONF/sources
CDEFAULTS=$CCOLLECT_CONF/defaults CDEFAULTS=$CCOLLECT_CONF/defaults
self=$(basename $0)
# functions first # functions first
_echo() _echo()
{ {
echo -n "$(basename $0)> $@" echo -n "${self}> $@"
exit 1 exit 1
} }
@ -24,13 +26,14 @@ _exit_err()
} }
# argv # argv
if [ $# -ne 1 ]; then if [ $# -ne 2 ]; then
_echo "$(basename $0): <name of the server>" _echo "Arguments needed: <name of the server> <where to store backup>"
exit 1 exit 1
fi fi
name="$1" name="$1"
fullname="${CSOURCES}/${name}" fullname="${CSOURCES}/${name}"
destination="$2"
# Tests # Tests
if [ -e "${fullname}" ]; then if [ -e "${fullname}" ]; then
@ -46,12 +49,25 @@ _echo "Creating ${fullname} ..."
mkdir -p "${fullname}" || exit 3 mkdir -p "${fullname}" || exit 3
echo "${name}:/" > "${fullname}/source" echo "${name}:/" > "${fullname}/source"
cat << eof > "${fullname}/exclude" cat << eof > "${fullname}/exclude" || exit 4
/dev/* /dev/*
/proc/* /proc/*
/tmp/* /tmp/*
eof eof
# Destination
if [ -e "${destination}" ]; then
if [ ! -d "${destination}" ]; then
echo "${destination} exists, but is not a directory. Aborting."
exit 5
fi
else
mkdir -p "${destination}" || _exit_err "Failed to create ${destination}."
fi
ln -s "${destination}" "${fullname}/destination" || \
_exit_err "Failed to link \"${destination}\" to \"${fullname}/destination\""
# finish # finish
_echo "Added some default values, please verify ${fullname}." _echo "Added some default values, please verify ${fullname}."
_echo "Finished." _echo "Finished."