5 if [ ! -d "$base" -o ! -f "$base/netdata.c" -o ! -d "$base/web" ]
7 echo >&2 "Cannot find my home directory '${base}'."
12 # the detail of the data that will be kept in netdata
13 NETDATA_CONFIG_INTERNAL_UPDATE_EVERY=1
15 # how many entries to keep in memory
16 NETDATA_CONFIG_INTERNAL_HISTORY_LINES=3600
18 # the user to run netdata under
19 NETDATA_CONFIG_USER=nobody
21 # set to 1, to enable debugging
22 NETDATA_CONFIG_DEBUG=0
25 NETDATA_CONFIG_PORT=19999
28 NETDATA_CONFIG_WEB_DIR=web
37 mkdir conf.d || exit 1
45 if [ -f conf.d/netdata.conf ]
47 # 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"`
49 if [ -z "$df" -o "$df" = "0x00000000" -o $((df + 1 - 1)) -eq 0 ]
51 NETDATA_CONFIG_DEBUG=0
53 NETDATA_CONFIG_DEBUG=1
56 # 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"`"
61 echo "Compiling netdata (debug=$NETDATA_CONFIG_DEBUG)"
62 if [ $NETDATA_CONFIG_DEBUG -eq 1 ]
65 make debug=1 || exit 1
66 debug_opts="-df 0xfffffadf"
69 debug_opts="-df 0x00000000"
72 echo "Stopping a (possibly) running netdata..."
73 killall netdata 2>/dev/null
76 if [ "$USER" = "root" -a ! -z "$NETDATA_CONFIG_USER" -a -d "$NETDATA_CONFIG_WEB_DIR" ]
78 echo "Chaning ownership of web files in $NETDATA_CONFIG_WEB_DIR to $NETDATA_CONFIG_USER"
79 chown -R "$NETDATA_CONFIG_USER" "$NETDATA_CONFIG_WEB_DIR" conf.d log || exit 1
80 chmod 0775 "$NETDATA_CONFIG_WEB_DIR" || exit 1
83 if [ ! "$USER" = "root" ]
85 echo >&2 "WARNING: NOT RUNNING AS ROOT - CANNOT SWITCH TO USER $NETDATA_CONFIG_USER"
86 echo >&2 "WARNING: MAKE SURE FILES IN web/ ARE OWNED BY $USER - or it will not work"
89 echo "Starting netdata..."
90 if [ -f conf.d/netdata.conf ]
94 touch conf.d/netdata.conf
96 if [ "$USER" = "root" ]
98 `pwd`/netdata $debug_opts -u $NETDATA_CONFIG_USER -t $NETDATA_CONFIG_INTERNAL_UPDATE_EVERY -l $NETDATA_CONFIG_INTERNAL_HISTORY_LINES -p $NETDATA_CONFIG_PORT || exit 1
100 `pwd`/netdata $debug_opts -t $NETDATA_CONFIG_INTERNAL_UPDATE_EVERY -l $NETDATA_CONFIG_INTERNAL_HISTORY_LINES -p $NETDATA_CONFIG_PORT || exit 1
104 wget 2>/dev/null -O conf.d/netdata.conf.new http://localhost:$NETDATA_CONFIG_PORT/netdata.conf
105 mv conf.d/netdata.conf.new conf.d/netdata.conf
107 echo "Hit http://127.0.0.1:$NETDATA_CONFIG_PORT/ from your browser."
108 echo "You can edit config options in file conf.d/netdata.conf"