【问题标题】:Baffling Debian installation script: service starts but then quits mysteriously - Why?令人费解的 Debian 安装脚本:服务启动但又神秘地退出 - 为什么?
【发布时间】:2013-11-01 22:58:36
【问题描述】:

我已经为此苦苦挣扎了一段时间,我完全感到困惑。

我有这个 postinst Debian 脚本,它应该在安装(服务可执行文件)完成后启动服务。据我所知,服务确实成功启动,但随后它立即神秘地退出。一旦 Synaptic 结束,从命令行重新启动服务就可以正常工作。

我尝试编写一个虚拟包来验证这一点。虚拟包安装 /etc/init/service-dummy.conf 和指向该文件的符号链接,名为 /etc/init.d/service-dummy(就像原始服务一样)。 service-dummy.conf 的内容与 service.conf 相同。假人启动服务......然后服务继续运行。所以我什至无法重现我的问题!

postinst 脚本会这样做:

#!/bin/sh
set -e
case "$1" in
   configure)
    # (instructions which config, make and install the freshly installed source code)
    ldconfig
    echo "Install concluded"
    if [ -e "/etc/init/service-dummy.conf" ]; then
       echo "Starting service-dummy root service" | tee service.log
       service service-dummy restart | tee --append service.log
    else
       echo "service-dummy.conf not installed"
    fi
    echo "Postinst complete"
   ;;
   *)
    echo "postinst called with unknown argument '$1'" >&2
   ;;
esac
# exit 1 to ensure installer stalls
exit 1

Synaptic 显示日志:

...
Starting service-dummy root service
stop: Unknown instance:
service-dummy start/running, process 9207
Postinst complete
dpkg: error processing service-dummy (--configure):
 subprocess installed post-installation script returned error exit status 1
...

好像暴发户需要刷新?

我尝试了更多的东西,然后我确实让它工作了,有点:我尝试启动服务,然后用退出 1 中止脚本,当脚本第二次运行时(postinst,相同的参数,所以我否则检测第二次运行),我再次启动服务,这次它坚持了。

日志中有一条关键线索:

Postinst complete (aborting script)
dpkg: error processing service-dummy (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
 service-dummy
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:
Setting up service-dummy ...
service-dummy postinst configure
Starting service-dummy a second time
stop: Unknown instance:
service-dummy start/running, process 4034
Postinst complete (aborting script recovery attempt)

所以我想我现在的问题变成了:

如何强制 ldconfig 不延迟其处理?

【问题讨论】:

    标签: deb


    【解决方案1】:

    在这里找到正确的线索:http://lists.debian.org/debian-glibc/2008/07/msg00169.html

    结果是 apt-get 暂时阻止使用 ldconfig,将其替换为其他内容。我的问题的解决方案是在脚本中非常简单地调用ldconfig.real 而不是ldconfig。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-16
      • 2021-02-05
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 2018-09-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多