Bug 168836 - www/nginx 1.2.x init script fail to start if /var/tmp is mounted as tmpfs
Summary: www/nginx 1.2.x init script fail to start if /var/tmp is mounted as tmpfs
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Sergey A. Osokin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-08 06:50 UTC by Mario Vazquez
Modified: 2012-06-13 05:47 UTC (History)
0 users

See Also:


Attachments
file.diff (303 bytes, patch)
2012-06-08 06:50 UTC, Mario Vazquez
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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!