Bryan Kearney
2009-Jan-15 19:55 UTC
[Ovirt-devel] [PATCH node] BZ479378: Provide the user an option to mount the logging partition during the initial configuration of the logging configurations
This is built off of Alan's patch stream, and replaces the earlier logging
patch which was sent.
---
scripts/ovirt-config-logging | 196 +++++++++++++++++++++++-------------------
scripts/ovirt-functions | 31 +++++++
2 files changed, 139 insertions(+), 88 deletions(-)
diff --git a/scripts/ovirt-config-logging b/scripts/ovirt-config-logging
index f1daf29..97551b0 100755
--- a/scripts/ovirt-config-logging
+++ b/scripts/ovirt-config-logging
@@ -7,6 +7,25 @@
RSYSLOG_FILE="/etc/rsyslog.conf"
+function enable_local_logging {
+ if grep -q "/dev/mapper/HostVG-Logging " /proc/mounts; then
+ return 0
+ else
+ while true; do
+ printf "\n"
+ read -p "Would you like to enable logging to the local disk?
(Y/N)? "
+ r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]')
+ if [ "$r" == "Y" ]; then
+ mount_logging
+ return
+ elif [ "$r" == "N" ]; then
+ printf "\nNot mounting the local disk. All logs will be
lost\n"
+ return
+ fi
+ done
+ fi
+}
+
# Creates the rsyslog file based on the following inputs
# $1 ipaddress of remote syslog server
# $2 port of remote syslog server
@@ -71,96 +90,96 @@ function is_numeric {
function prompt_user {
while true ; do
- max_log_size="10"
- syslog_server_ip=""
- syslog_server_port=""
-
- while true; do
- printf "\n"
- read -p "What is the max size, in kilobytes, for local log files
(def. ${max_log_size}k)? "
-
- if [ -n "$REPLY" ]; then
- r=$REPLY
- if [[ $r =~ ^[0-9]+$ ]] && [[ $r -gt 0 ]]; then
- max_log_size=$r
- printf "\nMaximum logging size will be ${max_log_size}k.\n"
- break
- else
- printf "\nInvalid input.\n"
- fi
- else
- printf "\nLeaving log size as ${max_log_size}k.\n"
- break
- fi
- done
-
- printf "\n"
- read -p "What is the IP address for the syslog server, hit Enter to skip?
"
- if [ -n "$REPLY" ]; then
- syslog_server_ip=$REPLY
- while true; do
- read -p "Please enter the remote logging port used: "
- r=$REPLY
- if [ -n "$r" ]; then
- if [[ $r =~ ^[0-9]+$ ]] && [[ $r -gt 0 ]]; then
- syslog_server_port=$REPLY
- break
- else
- printf "Invalid port.\n"
- fi
- fi
- done
-
- printf "\n"
- while true; do
- read -p "Remote logging uses [t]cp or [u]dp? "
- r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]')
- if [ "$r" == "T" ]; then
syslog_server_protocol="tcp"; break; fi
- if [ "$r" == "U" ]; then
syslog_server_protocol="udp"; break; fi
- # else
- printf "Invalid input.\n"
- done
- else
- printf "\nDisabling remote logging.\n"
- fi
-
- printf "\n"
- printf "\nLogging will be configured as follows:"
- printf "\n======================================"
- printf "\n Max Logfile Size: $max_log_size"
- if [ -n "$syslog_server_ip" ]; then
- printf "\n Remote Server: $syslog_server_ip"
- printf "\n Remote Port: $syslog_server_port"
- printf "\n Logging Protocol: $syslog_server_protocol"
- fi
- printf "\n"
- printf "\n"
- while true; do
- read -p "Is this correct (Y/N/A)? "
- r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]')
- if [ "$r" == "Y" ]; then
- printf "\nSaving configuration.\n"
- if [[ -n "$syslog_server_ip" ]] &&
- [[ -n "$syslog_server_port" ]] &&
- [[ -n "$syslog_server_protocol" ]]; then
- ovirt_rsyslog $syslog_server_ip \
- $syslog_server_port \
- $syslog_server_protocol
- fi
- sed -i -e "s/^size=.*/size=${max_log_size}k/" \
- /etc/logrotate.d/ovirt-logrotate.conf
- return
- elif [ "$r" == "N" ]; then
- printf "\nRestarting logging configuration.\n"
- break
- elif [ "$r" == "A" ]; then
- printf "\nAborting logging configuration.\n"
- return
- fi
- done
+ max_log_size="10"
+ syslog_server_ip=""
+ syslog_server_port=""
+
+ while true; do
+ printf "\n"
+ read -p "What is the max size, in kilobytes, for local log
files (def. ${max_log_size}k)? "
+
+ if [ -n "$REPLY" ]; then
+ r=$REPLY
+ if [[ $r =~ ^[0-9]+$ ]] && [[ $r -gt 0 ]]; then
+ max_log_size=$r
+ printf "\nMaximum logging size will be
${max_log_size}k.\n"
+ break
+ else
+ printf "\nInvalid input.\n"
+ fi
+ else
+ printf "\nLeaving log size as ${max_log_size}k.\n"
+ break
+ fi
+ done
+
+ printf "\n"
+ read -p "What is the IP address for the syslog server, hit Enter
to skip? "
+ if [ -n "$REPLY" ]; then
+ syslog_server_ip=$REPLY
+ while true; do
+ read -p "Please enter the remote logging port used: "
+ r=$REPLY
+ if [ -n "$r" ]; then
+ if [[ $r =~ ^[0-9]+$ ]] && [[ $r -gt 0 ]]; then
+ syslog_server_port=$REPLY
+ break
+ else
+ printf "Invalid port.\n"
+ fi
+ fi
+ done
+
+ printf "\n"
+ while true; do
+ read -p "Remote logging uses [t]cp or [u]dp? "
+ r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]')
+ if [ "$r" == "T" ]; then
syslog_server_protocol="tcp"; break; fi
+ if [ "$r" == "U" ]; then
syslog_server_protocol="udp"; break; fi
+ # else
+ printf "Invalid input.\n"
+ done
+ else
+ printf "\nDisabling remote logging.\n"
+ fi
+
+ printf "\n"
+ printf "\nLogging will be configured as follows:"
+ printf "\n======================================"
+ printf "\n Max Logfile Size: $max_log_size"
+ if [ -n "$syslog_server_ip" ]; then
+ printf "\n Remote Server: $syslog_server_ip"
+ printf "\n Remote Port: $syslog_server_port"
+ printf "\n Logging Protocol: $syslog_server_protocol"
+ fi
+ printf "\n"
+ printf "\n"
+ while true; do
+ read -p "Is this correct (Y/N/A)? "
+ r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]')
+ if [ "$r" == "Y" ]; then
+ printf "\nSaving configuration.\n"
+ if [[ -n "$syslog_server_ip" ]] &&
+ [[ -n "$syslog_server_port" ]] &&
+ [[ -n "$syslog_server_protocol" ]]; then
+ ovirt_rsyslog $syslog_server_ip \
+ $syslog_server_port \
+ $syslog_server_protocol
+ fi
+ sed -i -e "s/^size=.*/size=${max_log_size}k/" \
+ /etc/logrotate.d/ovirt-logrotate.conf
+ return
+ elif [ "$r" == "N" ]; then
+ printf "\nRestarting logging configuration.\n"
+ break
+ elif [ "$r" == "A" ]; then
+ printf "\nAborting logging configuration.\n"
+ return
+ fi
+ done
done
}
-
+
# AUTO for auto-install
if [ "$1" = "AUTO" ]; then
if [ -z "$OVIRT_SYSLOG_SERVER" -o -z
"$OVIRT_SYSLOG_PORT" ]; then
@@ -178,6 +197,7 @@ if [ "$1" = "AUTO" ]; then
fi
else
prompt_user
+ enable_local_logging
fi
exit 0
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index 26dc556..ec4cf89 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -193,6 +193,37 @@ mount_config() {
fi
}
+# mount logging partition
+mount_logging() {
+ if grep -q "/dev/mapper/HostVG-Logging " /proc/mounts; then
+ return 0
+ fi
+
+ if [ -e /dev/HostVG/Logging ] ; then
+
+ # backup the logs
+ if [ -e /var/logs-backup ]; then
+ rm -rf /var/logs-backup
+ fi
+ cp -R /var/log /var/logs-backup
+
+ mount /dev/HostVG/Logging /var/log
+ if [ -e /var/log/initialboot ]; then
+ rm -rf /var/log/initialboot
+ fi
+
+ mkdir /var/log/initialboot
+ cp -R /var/logs-backup/* /var/log/initialboot
+ rm -rf /var/logs-backup
+ return 0
+ else
+ # /var/log is not available
+ printf "\nThe logging partion has not been created. Please create
it at the main menu.\n"
+ return 1
+ fi
+}
+
+
# augtool wrapper
# workaround for bind-mounted files
# see https://fedorahosted.org/augeas/ticket/32
--
1.6.0.6