fixes
Costa Tsaousis (ktsaou) committed
May 20, 2014 at 03:49 UTC
5542759c669cf112279b44fd83f678ab420bbf82
1 file changed
+28
-30
netdata.start
+28
-30
@@ -24,28 +24,15 @@ NETDATA_CONFIG_DEBUG=0
24
# our port
25
NETDATA_CONFIG_PORT=19999
26
27
-# our web files
28
-NETDATA_CONFIG_WEB_DIR=web
27
+NETDATA_CONFIG_CONF_DIR="conf.d"
28
+NETDATA_CONFIG_WEB_DIR="web"
29
+NETDATA_CONFIG_CACHE_DIR="cache"
30
+NETDATA_CONFIG_LOG_DIR="log"
31
30
-if [ ! -d log ]
31
-then
32
- mkdir log || exit 1
33
-fi
34
-
35
-if [ ! -d conf.d ]
36
-then
37
- mkdir conf.d || exit 1
38
-fi
39
-
40
-if [ ! -d cache ]
41
-then
42
- mkdir cache || exit 1
43
-fi
44
-
45
-if [ -f conf.d/netdata.conf ]
32
+if [ -f $NETDATA_CONFIG_CONF_DIR/netdata.conf ]
33
then
34
# find if debug is enabled in the config
48
- df=`grep "debug flags = " conf.d/netdata.conf | tail -n 1 | cut -d '=' -f 2 | sed s"/ //g"`
35
+ df=`grep "debug flags = " $NETDATA_CONFIG_CONF_DIR/netdata.conf | tail -n 1 | cut -d '=' -f 2 | sed s"/ //g"`
36
if [ -z "$df" -o "$df" = "0x00000000" -o $((df + 1 - 1)) -eq 0 ]
37
then
38
NETDATA_CONFIG_DEBUG=0
@@ -54,10 +41,18 @@ then
41
fi
42
43
# find the user to run as
57
- NETDATA_CONFIG_USER="`grep 'run as user = ' conf.d/netdata.conf | head -n 1 | cut -d '=' -f 2 | sed s"/ //g"`"
58
- NETDATA_CONFIG_WEB_DIR="`grep 'web files directory = ' conf.d/netdata.conf | head -n 1 | cut -d '=' -f 2 | sed -e s"/^ \+//g" -e s"/ \+$//g"`"
44
+ NETDATA_CONFIG_USER="`grep 'run as user = ' $NETDATA_CONFIG_CONF_DIR/netdata.conf | head -n 1 | cut -d '=' -f 2 | sed s"/ //g"`"
45
+ NETDATA_CONFIG_WEB_DIR="`grep 'web files directory = ' $NETDATA_CONFIG_CONF_DIR/netdata.conf | head -n 1 | cut -d '=' -f 2 | sed -e s"/^ \+//g" -e s"/ \+$//g"`"
46
fi
47
48
+for x in "$NETDATA_CONFIG_WEB_DIR" "$NETDATA_CONFIG_CONF_DIR" "$NETDATA_CONFIG_CACHE_DIR" "$NETDATA_CONFIG_LOG_DIR"
49
+do
50
+ if [ ! -d $x ]
51
+ then
52
+ mkdir $x || exit 1
53
+ fi
54
+done
55
+
56
echo "Compiling netdata (debug=$NETDATA_CONFIG_DEBUG)"
57
if [ $NETDATA_CONFIG_DEBUG -eq 1 ]
58
then
@@ -85,11 +80,14 @@ do
80
test $ret -eq 0 && sleep 1
81
done
82
88
-if [ "$USER" = "root" -a ! -z "$NETDATA_CONFIG_USER" -a -d "$NETDATA_CONFIG_WEB_DIR" ]
83
+if [ "$USER" = "root" -a ! -z "$NETDATA_CONFIG_USER" ]
84
then
90
- echo "Chaning ownership of web files in $NETDATA_CONFIG_WEB_DIR to $NETDATA_CONFIG_USER"
91
- chown -R "$NETDATA_CONFIG_USER" "$NETDATA_CONFIG_WEB_DIR" conf.d log cache || exit 1
92
- chmod 0775 "$NETDATA_CONFIG_WEB_DIR" conf.d log cache || exit 1
85
+ for x in "$NETDATA_CONFIG_WEB_DIR" "$NETDATA_CONFIG_CONF_DIR" "$NETDATA_CONFIG_CACHE_DIR" "$NETDATA_CONFIG_LOG_DIR"
86
+ do
87
+ echo "Chaning ownership of web files in $x to $NETDATA_CONFIG_USER"
88
+ chown -R "$NETDATA_CONFIG_USER" "$x" || exit 1
89
+ chmod 0775 "$x" $NETDATA_CONFIG_CONF_DIR log cache || exit 1
90
+ done
91
fi
92
93
if [ ! "$USER" = "root" ]
@@ -99,11 +97,11 @@ then
97
fi
98
99
echo "Starting netdata..."
102
-if [ -f conf.d/netdata.conf ]
100
+if [ -f $NETDATA_CONFIG_CONF_DIR/netdata.conf ]
101
then
102
`pwd`/netdata
103
else
106
- touch conf.d/netdata.conf
104
+ touch $NETDATA_CONFIG_CONF_DIR/netdata.conf
105
106
if [ "$USER" = "root" ]
107
then
@@ -113,11 +111,11 @@ else
111
fi
112
113
sleep 2
116
- wget 2>/dev/null -O conf.d/netdata.conf.new http://localhost:$NETDATA_CONFIG_PORT/netdata.conf
117
- mv conf.d/netdata.conf.new conf.d/netdata.conf
114
+ wget 2>/dev/null -O $NETDATA_CONFIG_CONF_DIR/netdata.conf.new http://localhost:$NETDATA_CONFIG_PORT/netdata.conf
115
+ mv $NETDATA_CONFIG_CONF_DIR/netdata.conf.new $NETDATA_CONFIG_CONF_DIR/netdata.conf
116
117
echo "Hit http://127.0.0.1:$NETDATA_CONFIG_PORT/ from your browser."
120
- echo "You can edit config options in file conf.d/netdata.conf"
118
+ echo "You can edit config options in file $NETDATA_CONFIG_CONF_DIR/netdata.conf"
119
fi
120
121
echo