获取符号链接的最可靠方法是重新安装包含 initscript 的软件包。
我注意到既没有dpkg-reconfigure也没有apt-get --reinstall install恢复符号链接。并非所有脚本都符合 LSB 标准并且不提供# Default-(Start|Stop)行。
下面(经过测试的)脚本在软件包的安装后脚本中查找update-rc.d添加启动脚本的命令。必须删除以前的链接才能工作,因此该update-rc.d -f [script-name] remove行。我已经验证所有链接都已正确放回,唯一丢失的文件是一个README文件,但这并不重要。
#!/bin/bash
cd /etc/init.d && for file in *; do
if [ -x "$file" ]; then
pkg=$(dpkg-query -S "/etc/init.d/$file" | cut -d: -f1)
if [ -z "$pkg" ]; then
echo "**WARNING** No related package found, skipping file: $file"
else
postinst="/var/lib/dpkg/info/$pkg.postinst"
if [ -r "$postinst" ]; then
update=$(grep -Po "(?<!#)\s*update-rc\.d\s+$file\s+((start|stop|defaults)[\s\dS\.]+)+" "$postinst" | sed -e 's/^\s*//' -e 's/\s\+/ /g')
if [ -n "$update" ]; then
sudo update-rc.d -f "$file" remove
sudo $update
else
if [ -e "/etc/init/$file.conf" ]; then
echo "$file has been moved to Upstart"
else
echo "No update-rc.d line found for $file"
fi
fi
else
echo "No post-installation script found for $pkg"
fi
fi
else
echo "Not an executable, ignoring file: $file"
fi
done
Run Code Online (Sandbox Code Playgroud)
如果要手动修复,可以使用以下方法:
dpkg-query -S /etc/init.d/[script-name] - 检索负责文件的包名称less /var/lib/dpkg/info/[package-name].postinst - 搜索“update-rc.d”以获取安装启动脚本所需的命令资源:
| 归档时间: |
|
| 查看次数: |
460 次 |
| 最近记录: |