我一直在努力解决这个问题,我感到非常困惑。
我有这个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不推迟其处理?
答案 0 :(得分:2)
在这里找到了正确的线索:http://lists.debian.org/debian-glibc/2008/07/msg00169.html
原来apt-get暂时阻止使用ldconfig
代替其他东西。我的问题的解决方案是在脚本中简单地调用ldconfig.real
而不是ldconfig
。