由于删除后脚本错误,无法删除/清除包

由于删除后脚本错误,无法删除/清除包

之前我曾意外地从安装中删除了 Apache,以尝试删除 LDAP 服务器上不需要的软件包。我没有意识到的是,我还安装了 Fusion Directory,现在我无法重新安装 Apache 或 Fusion Directory,因为每次尝试使用 apt/dpkg 进行操作时都会出现错误:

ckilgore@ubuntu-ldap-server:/etc/apache2/conf-available$ sudo apt install apache2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apache2 is already the newest version (2.4.18-2ubuntu3.1).
The following packages will be REMOVED:
  fusiondirectory
0 upgraded, 0 newly installed, 1 to remove and 24 not upgraded.
1 not fully installed or removed.
After this operation, 6,822 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 98501 files and directories currently installed.)
Removing fusiondirectory (1.0.8.8-3ubuntu2) ...
apache2_invoke fusiondirectory postrm: No action required
apache2.service is not active, cannot reload.
invoke-rc.d: initscript apache2, action "reload" failed.
dpkg: error processing package fusiondirectory (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 fusiondirectory
E: Sub-process /usr/bin/dpkg returned an error code (1)

我真正想做的是完全卸载 Apache 和 Fusion Directory,重新安装并重新导入 Fusion Directory 的配置。但是,由于存在此问题,我无法做到这一点。解决此问题的最佳方法是什么?

以下是来自 syslog 和 apt log 的条目

系统日志

Sep 17 09:26:50 ubuntu-ldap-server fusiondirectory: apache2_invoke fusiondirectory postrm: No action required
Sep 17 09:26:50 ubuntu-ldap-server systemd[1]: Reloading.
Sep 17 09:26:51 ubuntu-ldap-server systemd[1]: apt-daily.timer: Adding 8h 34min 29.316164s random time.
Sep 17 09:26:51 ubuntu-ldap-server systemd[1]: Started ACPI event daemon.
Sep 17 09:26:51 ubuntu-ldap-server systemd[1]: apache2.service: Unit cannot be reloaded because it is inactive.
Sep 17 09:29:53 ubuntu-ldap-server fusiondirectory: apache2_invoke fusiondirectory postrm: No action required
Sep 17 09:29:54 ubuntu-ldap-server systemd[1]: Reloading.
Sep 17 09:29:54 ubuntu-ldap-server systemd[1]: apt-daily.timer: Adding 6min 36.572554s random time.
Sep 17 09:29:54 ubuntu-ldap-server systemd[1]: Starting Daily apt activities...
Sep 17 09:29:54 ubuntu-ldap-server systemd[1]: Started ACPI event daemon.
Sep 17 09:29:54 ubuntu-ldap-server systemd[1]: apache2.service: Unit cannot be reloaded because it is inactive.
Sep 17 09:29:55 ubuntu-ldap-server systemd[1]: Started Daily apt activities.
Sep 17 09:29:55 ubuntu-ldap-server systemd[1]: apt-daily.timer: Adding 6h 12min 2.585803s random time.
Sep 17 09:29:55 ubuntu-ldap-server systemd[1]: apt-daily.timer: Adding 9h 49min 31.073000s random time.

期限日志

Log started: 2016-09-17  09:29:52
(Reading database ... ^M(Reading database ... 5%^M(Reading database ... 10%^M(Reading database ... 15%^M(Reading database ... 20%^M(Reading database ... 25%^M(Reading database ... 30%^M(Reading database ... 35%^M(Reading database ... 40%^M(Reading database ... 45%^M(Reading database ... 50%^M(Reading database ... 55%^M(Reading database ... 60%^M(Reading database ... 65%^M(Reading database ... 70%^M(Reading database ... 75%^M(Reading database ... 80%^M(Reading database ... 85%^M(Reading database ... 90%^M(Reading database ... 95%^M(Reading database ... 100%^M(Reading database ... 98501 files and directories currently installed.)^M
Removing fusiondirectory (1.0.8.8-3ubuntu2) ...^M
apache2_invoke fusiondirectory postrm: No action required^M
apache2.service is not active, cannot reload.^M
invoke-rc.d: initscript apache2, action "reload" failed.^M
dpkg: error processing package fusiondirectory (--remove):^M
 subprocess installed post-removal script returned error exit status 1^M
Errors were encountered while processing:^M
 fusiondirectory^M

答案1

您可以手动编辑文件/var/lib/dpkg/info/fusiondirectory.postrm修复删除错误。如果 Apache 仍在运行,请停止它,然后使用 root 权限打开该文件并找到其中的部分:

if [ -x /usr/sbin/apache2 ]; then
    if [ -x /usr/sbin/invoke-rc.d ]; then
        invoke-rc.d apache2 reload
    else
        /etc/init.d/apache2 reload
    fi
fi

评论一下然后尝试

sudo apt-get install -f

修复错误或只是

sudo apt-get remove fusiondirectory

最后删除 fusiondirectory。

相关内容