Browse code

Merge "Support rsyslog and RELP protocol"

Jenkins authored on 2011/12/10 05:51:47
Showing 1 changed files
... ...
@@ -80,9 +80,6 @@ source ./stackrc
80 80
 # Destination path for installation ``DEST``
81 81
 DEST=${DEST:-/opt/stack}
82 82
 
83
-# Configure services to syslog instead of writing to individual log files
84
-SYSLOG=${SYSLOG:-False}
85
-
86 83
 # apt-get wrapper to just get arguments set correctly
87 84
 function apt_get() {
88 85
     local sudo="sudo"
... ...
@@ -186,6 +183,23 @@ if [ ! -n "$HOST_IP" ]; then
186 186
     fi
187 187
 fi
188 188
 
189
+# Normalize config values to True or False
190
+# VAR=`trueorfalse default-value test-value`
191
+function trueorfalse() {
192
+    local default=$1
193
+    local testval=$2
194
+
195
+    [[ -z "$testval" ]] && { echo "$default"; return; }
196
+    [[ "0 no false" =~ "$testval" ]] && { echo "False"; return; }
197
+    [[ "1 yes true" =~ "$testval" ]] && { echo "True"; return; }
198
+    echo "$default"
199
+}
200
+
201
+# Configure services to syslog instead of writing to individual log files
202
+SYSLOG=`trueorfalse False $SYSLOG`
203
+SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
204
+SYSLOG_PORT=${SYSLOG_PORT:-516}
205
+
189 206
 # Service startup timeout
190 207
 SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
191 208
 
... ...
@@ -559,6 +573,28 @@ fi
559 559
 # it since we are going to run the services in screen for simple
560 560
 cp $FILES/screenrc ~/.screenrc
561 561
 
562
+# Syslog
563
+# ---------
564
+
565
+if [[ $SYSLOG != "False" ]]; then
566
+    apt_get install -y rsyslog-relp
567
+    if [[ "$SYSLOG_HOST" = "$HOST_IP" ]]; then
568
+        # Configure the master host to receive
569
+        cat <<EOF >/tmp/90-stack-m.conf
570
+\$ModLoad imrelp
571
+\$InputRELPServerRun $SYSLOG_PORT
572
+EOF
573
+        sudo mv /tmp/90-stack-m.conf /etc/rsyslog.d
574
+    else
575
+        # Set rsyslog to send to remote host
576
+        cat <<EOF >/tmp/90-stack-s.conf
577
+*.*		:omrelp:$SYSLOG_HOST:$SYSLOG_PORT
578
+EOF
579
+        sudo mv /tmp/90-stack-s.conf /etc/rsyslog.d
580
+    fi
581
+    sudo /usr/sbin/service rsyslog restart
582
+fi
583
+
562 584
 # Rabbit
563 585
 # ---------
564 586
 
... ...
@@ -1045,6 +1081,16 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
1045 1045
     sudo sed -e "s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g" -i $KEYSTONE_DATA
1046 1046
     # initialize keystone with default users/endpoints
1047 1047
     ENABLED_SERVICES=$ENABLED_SERVICES BIN_DIR=$KEYSTONE_DIR/bin bash $KEYSTONE_DATA
1048
+
1049
+    if [ "$SYSLOG" != "False" ]; then
1050
+        sed -i -e '/^handlers=devel$/s/=devel/=production/' \
1051
+            $KEYSTONE_DIR/etc/logging.cnf
1052
+        sed -i -e "
1053
+            /^log_file/s/log_file/\#log_file/; \
1054
+            /^log_config/d;/^\[DEFAULT\]/a\
1055
+            log_config=$KEYSTONE_DIR/etc/logging.cnf" \
1056
+            $KEYSTONE_DIR/etc/keystone.conf
1057
+    fi
1048 1058
 fi
1049 1059
 
1050 1060