bash 无法在 debian 8 (Jessie) 中使用 service 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30345399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 13:00:39  来源:igfitidea点击:

Unable to use service command with debian 8 (Jessie)

linuxbashservicedebian

提问by eento

In order to install LibreOffice 4.4 into my Debian 8 (Jessie), I just got all my bash scripts from my Debian 7.5 and run them into the same way into the D8 one.

为了将 LibreOffice 4.4 安装到我的 Debian 8 (Jessie) 中,我刚刚从 Debian 7.5 中获取了所有 bash 脚本,并以相同的方式将它们运行到 D8 中。

I know there was several changes into the new version but I'm not able to use my service like this anymore :

我知道新版本有几处更改,但我无法再像这样使用我的服务:

sudo service libreoffice start

When doing this doesn't start anything and I have to start it using :

这样做时不会启动任何东西,我必须使用以下命令启动它:

sudo /etc/init.d/libreoffice start

And strange thing, when doing (bad parameter) :

奇怪的是,在做(坏参数)时:

sudo service libreoffice dzedjiodjzedj

...the script is perfectly executed and it displays my catched error

...脚本完美执行并显示我捕获的错误

Here is my /etc/init.d/libreoffice file :

这是我的 /etc/init.d/libreoffice 文件:

    #
# libreoffice     This shell script takes care of starting and stopping the LibreOffice Daemon
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: libreofficedaemon
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Description: Init.d script to run a LibreOffice Daemon
# Short-Description: start and stop LibreOffice Daemon
### END INIT INFO

NAME="LibreOffice Service"
LIBREOFFICE_HOME=/opt/libreoffice4.4
LIBREOFFICE_USER=libreoffice
export LIBREOFFICE_HOME LIBREOFFICE_USER

start() {
        echo -ne "Starting $NAME. \n"
        su $LIBREOFFICE_USER -c "$LIBREOFFICE_HOME/start.sh"
}

stop() {
    echo -ne "Stopping $NAME. \n"
    su $LIBREOFFICE_USER -c "$LIBREOFFICE_HOME/stop.sh"
}

kill() {
    echo -ne "Force close of $NAME. "
    killall -u $LIBREOFFICE_USER
}

cd $LIBREOFFICE_HOME
case "" in
  start|stop)
        ;;
  restart) stop; start;;
  kill) kill;;
  *)
    echo "Usage: /etc/init.d/libreoffice {start|stop|restart|kill}"
    exit 1
    ;;
esac

exit 0

And I just run that issue with tomcat8 service yesterday, I just started manually the service and sudo service tomcat8 startworked after that but nothing for libreoffice one..

我昨天刚刚用 tomcat8 服务运行了这个问题,我只是手动启动了该服务并sudo service tomcat8 start在此之后工作,但对 libreoffice one 没有任何作用。

From the Debian Jessie Release Notes :

来自 Debian Jessie 发行说明:

When you are asked if any file in the /etc/init.d directory, or the /etc/manpath.config file should be replaced by the package maintainer's version, it's usually necessary to answer “yes” to ensure system consistency

当你被问到 /etc/init.d 目录中的任何文件或 /etc/manpath.config 文件是否应该被包维护者的版本替换时,通常需要回答“是”以确保系统一致性

回答by engines

With systemd you now have to use systemctl:

使用 systemd,您现在必须使用 systemctl:

sudo systemctl start libreoffice

Here's some more info

这里有更多信息