diff options
author | Maryam Tahhan <maryam.tahhan@intel.com> | 2016-12-13 14:25:14 +0000 |
---|---|---|
committer | Maryam Tahhan <maryam.tahhan@intel.com> | 2016-12-13 14:33:12 +0000 |
commit | a23869a8d6570035547b3da7b1d7c693ff58f6eb (patch) | |
tree | f51ef50b11bbba2775bb51d6885f78847913c0f0 /src/collectd/include_config.sh | |
parent | 0c1d10389d86c1e6c5cb33552baf58840529406b (diff) |
src: only copy config if it doesn't exist
Only copy sample configuration files if those files don't already exist.
Change-Id: Id72761513cc053906122d638c8c21dee1a77dc76
Signed-off-by: Maryam Tahhan <maryam.tahhan@intel.com>
Diffstat (limited to 'src/collectd/include_config.sh')
-rwxr-xr-x | src/collectd/include_config.sh | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/collectd/include_config.sh b/src/collectd/include_config.sh index 95b052f3..1996e96b 100755 --- a/src/collectd/include_config.sh +++ b/src/collectd/include_config.sh @@ -1,6 +1,9 @@ #!/bin/bash COLLECTD_CONF_FILE=/opt/collectd/etc/collectd.conf +COLLECTD_CONF_DIR=/opt/collectd/etc/collectd.conf.d INCLUDE_CONF="<Include \"/opt/collectd/etc/collectd.conf.d\">" +CURR_DIR=`pwd` +SAMPLE_CONF_DIR=$CURR_DIR/collectd_sample_configs/* function write_include { echo $INCLUDE_CONF | sudo tee -a $COLLECTD_CONF_FILE; @@ -10,3 +13,9 @@ function write_include { grep -qe '<Include "/opt/collectd/etc/collectd.conf.d">' $COLLECTD_CONF_FILE; [ $? -ne 0 ] && write_include +`mkdir -p $COLLECTD_CONF_DIR` + +for F in $SAMPLE_CONF_DIR; do + FILE=$(basename $F) + [ -f $COLLECTD_CONF_DIR/$FILE ] && echo "File $COLLECTD_CONF_DIR/$FILE exists" || cp $F $COLLECTD_CONF_DIR +done |