1

我一直在努力解决这个问题,我完全感到困惑。

我有这个 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 不推迟其处理?

4

1 回答 1

2

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

结果 apt-getldconfig通过用其他东西替换它来暂时阻止使用。我的问题的解决方案是非常简单地调用ldconfig.real而不是ldconfig在脚本中调用。

于 2013-11-01T14:58:36.697 回答