Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

policy_rc_d_enable() causes issues with installing Nginx on Ubuntu Noble #120

Open
DeBuXer opened this issue Jul 2, 2024 · 0 comments
Open

Comments

@DeBuXer
Copy link

DeBuXer commented Jul 2, 2024

In the packer files 10-upgrade-distro.sh and 80-install-context.sh for Ubuntu, there is the following line:

policy_rc_d_enable() (echo "exit 0" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d)

This only causes issues with installing Nginx from the Ubuntu repository on Ubuntu Noble. The following error message appears during the installation:

root@localhost:~# apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  nginx-common
Suggested packages:
  fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
  nginx nginx-common
0 upgraded, 2 newly installed, 0 to remove and 64 not upgraded.
Need to get 552 kB of archives.
After this operation, 1596 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 nginx-common all 1.24.0-2ubuntu7 [31.2 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 nginx amd64 1.24.0-2ubuntu7 [521 kB]
Fetched 552 kB in 1s (724 kB/s)
Preconfiguring packages ...
Selecting previously unselected package nginx-common.
(Reading database ... 69464 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.24.0-2ubuntu7_all.deb ...
Unpacking nginx-common (1.24.0-2ubuntu7) ...
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_1.24.0-2ubuntu7_amd64.deb ...
Unpacking nginx (1.24.0-2ubuntu7) ...
Setting up nginx (1.24.0-2ubuntu7) ...
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
invoke-rc.d: initscript nginx, action "start" failed.
× nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-07-02 13:53:49 UTC; 11ms ago
       Docs: man:nginx(8)
    Process: 2442 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 3ms

Jul 02 13:53:49 localhost.localdomain systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
Jul 02 13:53:49 localhost.localdomain nginx[2442]: 2024/07/02 13:53:49 [emerg] 2442#2442: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
Jul 02 13:53:49 localhost.localdomain nginx[2442]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 02 13:53:49 localhost.localdomain systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jul 02 13:53:49 localhost.localdomain systemd[1]: nginx.service: Failed with result 'exit-code'.
Jul 02 13:53:49 localhost.localdomain systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
dpkg: error processing package nginx (--configure):
 installed nginx package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of nginx-common:
 nginx-common depends on nginx (<< 1.24.0-2ubuntu7.1~); however:
  Package nginx is not configured yet.

dpkg: error processing package nginx-common (--configure):
 dependency problems - leaving unconfigured
Processing triggers for ufw (0.36.2-6) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for man-db (2.12.0-4build2) ...
Errors were encountered while processing:
 nginx
 nginx-common
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@localhost:~#

After removing /usr/sbin/policy-rc.d, the installation succeeds without any issues. I tested this by downloading the Ubuntu 24.04 image from the Marketplace, deleting the policy-rc.d file, and then installing Nginx from the Ubuntu repository.

root@localhost:~# cat /usr/sbin/policy-rc.d 
exit 0
root@localhost:~# rm /usr/sbin/policy-rc.d 
root@localhost:~# apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  nginx-common
Suggested packages:
  fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
  nginx nginx-common
0 upgraded, 2 newly installed, 0 to remove and 64 not upgraded.
Need to get 552 kB of archives.
After this operation, 1596 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 nginx-common all 1.24.0-2ubuntu7 [31.2 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 nginx amd64 1.24.0-2ubuntu7 [521 kB]
Fetched 552 kB in 1s (785 kB/s)
Preconfiguring packages ...
Selecting previously unselected package nginx-common.
(Reading database ... 69464 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.24.0-2ubuntu7_all.deb ...
Unpacking nginx-common (1.24.0-2ubuntu7) ...
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_1.24.0-2ubuntu7_amd64.deb ...
Unpacking nginx (1.24.0-2ubuntu7) ...
Setting up nginx (1.24.0-2ubuntu7) ...
Setting up nginx-common (1.24.0-2ubuntu7) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
Processing triggers for ufw (0.36.2-6) ...
Processing triggers for man-db (2.12.0-4build2) ...
Scanning processes...                                                                                                                                                                         
Scanning linux images...                                                                                                                                                                      

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@localhost:~# 

The solution might be to modify the policy_rc_d_enable() function to something like policy_rc_d_delete() (rm -f /usr/sbin/policy-rc.d), as this file does not seem to exist by default in at least Ubuntu Focal, Jammy, and Noble, and therefore is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant