Here's a simple way to reproduce the issue (assuming you have LXD
installed):

```
lxc launch ubuntu-daily:24.04 n1
echo "exit 0" | lxc exec n1 -- tee /usr/sbin/policy-rc.d
lxc exec n1 -- chmod +x /usr/sbin/policy-rc.d

lxc exec n1 -- apt-get update -qq
lxc exec n1 -- apt-get install -y nginx

lxc shell n1
```

And once inside `n1`, to learn more about where it fails during
postinst:

```
sed -i 's|set -e|set -ex|' /var/lib/dpkg/info/nginx.postinst
apt-get install -f
```

Will give this:

```
Setting up nginx (1.24.0-2ubuntu7.1) ...
+ invoke-rc.d --quiet nginx status
+ ss -nlt sport = 80
+ grep -v ^State
+ [ -z  ]
+ invoke-rc.d nginx start
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 Fri 2024-09-20 18:29:38 UTC; 6ms 
ago
       Docs: man:nginx(8)
    Process: 1404 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; 
master_process on; (code=exited, status=1/FAILURE)
        CPU: 2ms

Sep 20 18:29:38 n1 systemd[1]: Starting nginx.service - A high performance web 
server and a reverse proxy server...
Sep 20 18:29:38 n1 nginx[1404]: 2024/09/20 18:29:38 [emerg] 1404#1404: open() 
"/etc/nginx/nginx.conf" failed (2: No such file or directory)
Sep 20 18:29:38 n1 nginx[1404]: nginx: configuration file /etc/nginx/nginx.conf 
test failed
Sep 20 18:29:38 n1 systemd[1]: nginx.service: Control process exited, 
code=exited, status=1/FAILURE
Sep 20 18:29:38 n1 systemd[1]: nginx.service: Failed with result 'exit-code'.
Sep 20 18:29:38 n1 systemd[1]: Failed to start nginx.service - A high 
performance web server and a reverse proxy server.
+ exit 1
```

So `invoke-rc.d nginx start` tries to start (apparently intentional
based on Adam's interpretation of exit code 0) but that is tried before
the file `/etc/nginx/nginx.conf` is created. Only
`/etc/nginx/nginx.conf.dpkg-new` exist at that point.

It's not clear to me why only the `.dpkg-new` file exist but maybe
that's due to the split between `nginx` and `nginx-common` as teward
mentioned (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082373)?
Trying to install just `nginx-common` doesn't work as that automatically
pulls in `nginx` :/

** Bug watch added: Debian Bug tracker #1082373
   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082373

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2081308

Title:
  open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/2081308/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to