Bug 168836

Summary: www/nginx 1.2.x init script fail to start if /var/tmp is mounted as tmpfs
Product: Ports & Packages Reporter: Mario Vazquez <mariovazq>
Component: Individual Port(s)Assignee: Sergey A. Osokin <osa>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Mario Vazquez 2012-06-08 06:50:11 UTC
When /var/tmp is mounted using tmpfs, it starts with clean contents each time the system boots.  Nginx from ports requires a directory inside /var/tmp which is created when the port is installed.  But since the Nginx script do not check or recreate that dir, it will fail to start giving this message.

Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: [emerg] mkdir() "/var/tmp/nginx/client_body_temp" failed (2: No such file or directory)
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed
Starting nginx.
nginx: [emerg] mkdir() "/var/tmp/nginx/client_body_temp" failed (2: No such file or directory)
/usr/local/etc/rc.d/nginx: WARNING: failed to start nginx

Fix: Maybe not the best place, but I added 3 lines in the nginx init script to check and create the needed directory if it's missing.  I added the 3 lines to the nginx_checkconfig function.

 nginx_checkconfig()
 {
       if [ ! -d "/var/tmp/nginx" ] ; then
               mkdir /var/tmp/nginx
       fi
       ...

I included a patch that make the changes.

Patch attached with submission follows:
How-To-Repeat: 1. Mount /var/tmp as tmpfs
    My current fstab line is:
     tmpfs    /var/tmp      tmpfs rw,nosuid,noexec,mode=01777       0 0
2. Reboot the system or start Nginx.
Comment 1 Tilman Keskinoz freebsd_committer freebsd_triage 2012-06-08 13:23:13 UTC
Responsible Changed
From-To: freebsd-ports-bugs->osa

over to maintainer
Comment 2 Sergey A. Osokin freebsd_committer freebsd_triage 2012-06-13 05:46:56 UTC
State Changed
From-To: open->closed

I committed my version, thank you for report!