-
Notifications
You must be signed in to change notification settings - Fork 22
/
create_sample_config.sh
executable file
·58 lines (48 loc) · 1.46 KB
/
create_sample_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2008, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################
#
# If no configuration file exists, create a sample one.
#
. $ZENHOME/bin/zenfunctions
cd daemons
for daemonctl in * ; do
PRGNAME=`awk -F= '/^PRGNAME=/ { print $2; }' $daemonctl | sed -e 's/\.py//' | tail -1`
#echo "PRGNAME $PRGNAME"
#
# Expand any variables used to define the config file
#
eval CFGFILE=`awk -F= '/^CFGFILE=/ { print $2; }' $daemonctl | tail -1`
#echo "CFGFILE $CFGFILE"
#
# Some sanity checks...
#
if [ -z "$CFGFILE" ] ; then
echo "No configuration file for $PRGNAME found"
continue
elif [ $CFGFILE == '/dev/null' ] ; then
echo "No configuration file for $PRGNAME"
continue
fi
#
# Don't overwrite possibly user-customized files!
#
if [ ! -f $CFGFILE ] ; then
$PRGNAME genconf > /dev/null
if [ "$?" -eq "0" ]; then
echo "Creating configuration file for $PRGNAME..."
`$PRGNAME genconf > $CFGFILE`
chmod 0600 $CFGFILE
fi
fi
done
#
# Don't cause troubles if one of the above steps had issues.
#
exit 0