我在 ubuntu 机器上安装 Mysql 服务器时遇到了一些麻烦。经过一番搜索,我发现 Mysql 的初始化脚本 (/etc/init.d/mysql) 尝试调用“/etc/lsb-base-logging.sh”shell 脚本,该脚本中有 4 行检查变量“INITOUTPUT”的值,但该变量未定义。
我只是注释了这 4 行,一切正常。我检查了使用 Fedora 10 的笔记本电脑,发现根本没有“lsb-base-logging.sh”脚本。有人知道这个脚本在系统中执行什么具体任务吗?为什么它使用未定义的变量?该变量实际上有什么用处?
更新 我在这里附加脚本。文件:/etc/lsb-base-logging.sh
# Default init script logging functions suitable for Ubuntu.
# See /lib/lsb/init-functions for usage help.
# edited by Farzad Ghanei lines 84, 114, 136, 156 are commented to fix mysql server start
. /etc/default/rcS
log_use_usplash () {
if [ "${loop:-n}" = y ]; then
return 1
fi
type usplash_write >/dev/null 2>&1
}
log_to_console () {
[ "${loop:-n}" != y ] || return 0
[ "${QUIET:-no}" != yes ] || return 0
# Only output to the console when we're given /dev/null
stdin=`readlink /proc/self/fd/0`
[ "${stdin#/dev/null}" != "$stdin" ] || return 0
func=$1
shift
loop=y $func "$@" </dev/console >/dev/console 2>&1 || true
}
log_success_msg () {
if log_use_usplash; then
usplash_write "STATUS $*" || true
fi
log_to_console log_success_msg "$@"
echo " * $@"
}
log_failure_msg () {
if log_use_usplash; then
usplash_write "STATUS $*" || true
fi
log_to_console log_failure_msg "$@"
if log_use_fancy_output; then
RED=`$TPUT setaf 1`
NORMAL=`$TPUT op`
echo " $RED*$NORMAL $@"
else
echo " * $@"
fi
}
log_warning_msg () {
if log_use_usplash; then
usplash_write "STATUS $*" || true
fi
log_to_console log_warning_msg "$@"
if log_use_fancy_output; then
YELLOW=`$TPUT setaf 3`
NORMAL=`$TPUT op`
echo " $YELLOW*$NORMAL $@"
else
echo " * $@"
fi
}
log_begin_msg () {
log_daemon_msg "$1"
}
log_daemon_msg () {
if [ -z "$1" ]; then
return 1
fi
if log_use_usplash; then
usplash_write "TEXT $*" || true
fi
log_to_console log_daemon_msg "$@"
# if [ "$INITOUTPUT" = "yes" ]; then
if log_use_fancy_output && $TPUT xenl >/dev/null 2>&1; then
COLS=`$TPUT cols`
if [ "$COLS" ] && [ "$COLS" -gt 6 ]; then
COL=`$EXPR $COLS - 7`
else
COLS=80
COL=73
fi
# We leave the cursor `hanging' about-to-wrap (see terminfo(5)
# xenl, which is approximately right). That way if the script
# prints anything then we will be on the next line and not
# overwrite part of the message.
# Previous versions of this code attempted to colour-code the
# asterisk but this can't be done reliably because in practice
# init scripts sometimes print messages even when they succeed
# and we won't be able to reliably know where the colourful
# asterisk ought to go.
printf " * $* "
# Enough trailing spaces for ` [fail]' to fit in; if the message
# is too long it wraps here rather than later, which is what we
# want.
$TPUT hpa `$EXPR $COLS - 1`
printf ' '
else
echo " * $@"
COL=
fi
# fi
}
log_progress_msg () {
:
}
log_end_msg () {
if [ -z "$1" ]; then
return 1
fi
if log_use_usplash; then
if [ "$1" -eq 0 ]; then
usplash_write "SUCCESS OK" || true
else
usplash_write "FAILURE failed" || true
fi
fi
log_to_console log_end_msg "$@"
# if [ "$INITOUTPUT" = "yes" ]; then
if [ "$COL" ] && [ -x "$TPUT" ]; then
printf "\r"
$TPUT hpa $COL
if [ "$1" -eq 0 ]; then
echo "[ OK ]"
else
printf '['
$TPUT setaf 1 # red
printf fail
$TPUT op # normal
echo ']'
fi
else
if [ "$1" -eq 0 ]; then
echo " ...done."
else
echo " ...fail!"
fi
fi
# fi
return $1
}
log_action_msg () {
if log_use_usplash; then
usplash_write "TEXT $*" || true
fi
log_to_console log_action_msg "$@"
echo " * $@"
}
log_action_begin_msg () {
log_daemon_msg "$@..."
}
log_action_cont_msg () {
log_daemon_msg "$@..."
}
log_action_end_msg () {
# In the future this may do something with $2 as well.
log_end_msg "$1" || true
}
答案1
/etc/lsb-base-logging.sh
除了与“INITOUTPUT”变量相关的行和. /etc/default/rcS
靠近开头的行之外,我的与您的完全相同。
似乎您不应该注释掉这些行,而应该在文件INITOUTPUT=yes
中添加/etc/default/rcS
。该变量用于控制在系统启动期间是否执行某些日志输出。
至于脚本的目的,这里有以下内容/usr/share/doc/lsb-base/README.Debian.gz
:
Debian lsb-base 软件包提供了一系列日志记录函数来 允许简化对 init 脚本操作的记录。这些函数是 特定于 Debian 和(在某些情况下)其他派生发行版。
你的 Ubuntu 是什么版本?