From 500bfc55e45684f3bd1ce065534d58a922773fbc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 08:21:40 +0200 Subject: [PATCH] added exclude --- tools/create_source.sh | 47 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) mode change 100644 => 100755 tools/create_source.sh diff --git a/tools/create_source.sh b/tools/create_source.sh old mode 100644 new mode 100755 index 92f2bc7..7795baa --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -4,19 +4,54 @@ # Written for Netstream (www.netstream.ch) # Creates a source, including exclude -if [ $# -ne 1 ]; then - echo $(basename $0): name - exit 1 -fi - +# standard values CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} CSOURCES=$CCOLLECT_CONF/sources CDEFAULTS=$CCOLLECT_CONF/defaults +# functions first +_echo() +{ + echo -n "$(basename $0)> $@" + exit 1 +} + +_exit_err() +{ + _echo "$@" + rm -f "$TMP" + exit 1 +} + +# argv +if [ $# -ne 1 ]; then + _echo "$(basename $0): " + exit 1 +fi + name="$1" fullname="${CSOURCES}/${name}" +# Tests if [ -e "${fullname}" ]; then - echo "${fullname} already exists. Aborting." + _echo "${fullname} already exists. Aborting." exit 2 fi + +_echo "Trying to reach ${name} ..." +ping -c1 "${name}" || _exit_err "Cannot reach ${name}. Aborting." + +# Create +_echo "Creating ${fullname} ..." +mkdir -p "${fullname}" || exit 3 + +echo "${name}:/" > "${fullname}/source" +cat << eof > "${fullname}/exclude" +/dev/* +/proc/* +/tmp/* +eof + +# finish +_echo "Added some default values, please verify ${fullname}." +_echo "Finished."