From 78c3dc1bd7a67851a8d43ca6f8e07eba7e7113e1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 08:40:44 +0200 Subject: [PATCH] Finished create_source --- tools/create_source.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/create_source.sh b/tools/create_source.sh index 7795baa..f05a237 100755 --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -9,10 +9,12 @@ CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} CSOURCES=$CCOLLECT_CONF/sources CDEFAULTS=$CCOLLECT_CONF/defaults +self=$(basename $0) + # functions first _echo() { - echo -n "$(basename $0)> $@" + echo -n "${self}> $@" exit 1 } @@ -24,13 +26,14 @@ _exit_err() } # argv -if [ $# -ne 1 ]; then - _echo "$(basename $0): " +if [ $# -ne 2 ]; then + _echo "Arguments needed: " exit 1 fi name="$1" fullname="${CSOURCES}/${name}" +destination="$2" # Tests if [ -e "${fullname}" ]; then @@ -46,12 +49,25 @@ _echo "Creating ${fullname} ..." mkdir -p "${fullname}" || exit 3 echo "${name}:/" > "${fullname}/source" -cat << eof > "${fullname}/exclude" +cat << eof > "${fullname}/exclude" || exit 4 /dev/* /proc/* /tmp/* 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 _echo "Added some default values, please verify ${fullname}." _echo "Finished."