Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Import nginx version 0.14.3

  • Loading branch information...
commit 49f6c803f642b3816befb1a084f269d36078c762 1 parent 1cd1478
@jtimberman jtimberman authored
View
61 cookbooks/nginx/README.rdoc
@@ -0,0 +1,61 @@
+= DESCRIPTION:
+
+Installs nginx from package OR source code and sets up configuration handling similar to Debian's Apache2 scripts.
+
+= REQUIREMENTS:
+
+== Cookbooks:
+
+* build-essential (for nginx::source)
+
+== Platform:
+
+Debian or Ubuntu though may work where 'build-essential' works, but other platforms are untested.
+
+= ATTRIBUTES:
+
+* version - sets the version to install.
+* install_path - for nginx::source, sets the --prefix installation.
+* src_binary - for nginx::source, sets the binary location.
+* dir - configuration dir.
+* log_dir - where logs go.
+* user - user to run as.
+* binary - path to nginx binary.
+* configure_flags - for nginx::source, the flags to use for compilation.
+* gzip* - configure the gzip module.
+* keepalive - whether to use keepalive.
+* keepalive_timeout
+* worker_processes - number of workers to spawn.
+* worker_connections - number of connections per worker.
+* server_names_hash_bucket_size
+
+= USAGE:
+
+Provides two ways to install and configure nginx.
+
+* Install via native package (nginx::default)
+* Install via compiled source (nginx::source)
+
+Both recipes implement configuration handling similar to the Debian Apache2 site enable/disable.
+
+There's some redundancy in that the config handling hasn't been separated from the installation method (yet), so use only one of the recipes.
+
+= LICENSE and AUTHOR:
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+Author:: Adam Jacob (<adam@opscode.com>)
+Author:: AJ Christensen (<aj@opscode.com>)
+
+Copyright:: 2008-2010, Opscode, Inc
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
View
44 cookbooks/nginx/attributes/default.rb
@@ -0,0 +1,44 @@
+default[:nginx][:version] = "0.7.67"
+default[:nginx][:install_path] = "/opt/nginx-#{nginx[:version]}"
+default[:nginx][:src_binary] = "#{nginx[:install_path]}/sbin/nginx"
+
+case platform
+when "debian","ubuntu"
+ set[:nginx][:dir] = "/etc/nginx"
+ set[:nginx][:log_dir] = "/var/log/nginx"
+ set[:nginx][:user] = "www-data"
+ set[:nginx][:binary] = "/usr/sbin/nginx"
+else
+ set[:nginx][:dir] = "/etc/nginx"
+ set[:nginx][:log_dir] = "/var/log/nginx"
+ set[:nginx][:user] = "www-data"
+ set[:nginx][:binary] = "/usr/sbin/nginx"
+end
+
+default[:nginx][:configure_flags] = [
+ "--prefix=#{nginx[:install_path]}",
+ "--conf-path=#{nginx[:dir]}/nginx.conf",
+ "--with-http_ssl_module",
+ "--with-http_gzip_static_module"
+]
+
+default[:nginx][:gzip] = "on"
+default[:nginx][:gzip_http_version] = "1.0"
+default[:nginx][:gzip_comp_level] = "2"
+default[:nginx][:gzip_proxied] = "any"
+default[:nginx][:gzip_types] = [
+ "text/plain",
+ "text/html",
+ "text/css",
+ "application/x-javascript",
+ "text/xml",
+ "application/xml",
+ "application/xml+rss",
+ "text/javascript"
+]
+
+default[:nginx][:keepalive] = "on"
+default[:nginx][:keepalive_timeout] = 65
+default[:nginx][:worker_processes] = cpu[:total]
+default[:nginx][:worker_connections] = 2048
+default[:nginx][:server_names_hash_bucket_size] = 64
View
35 cookbooks/nginx/definitions/nginx_site.rb
@@ -0,0 +1,35 @@
+#
+# Cookbook Name:: nginx
+# Definition:: nginx_site
+# Author:: AJ Christensen <aj@junglist.gen.nz>
+#
+# Copyright 2008-2009, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+define :nginx_site, :enable => true do
+ if params[:enable]
+ execute "nxensite #{params[:name]}" do
+ command "/usr/sbin/nxensite #{params[:name]}"
+ notifies :restart, resources(:service => "nginx")
+ not_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
+ end
+ else
+ execute "nxdissite #{params[:name]}" do
+ command "/usr/sbin/nxdissite #{params[:name]}"
+ notifies :restart, resources(:service => "nginx")
+ only_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
+ end
+ end
+end
View
73 cookbooks/nginx/files/default/mime.types
@@ -0,0 +1,73 @@
+types {
+ text/html html htm shtml;
+ text/css css;
+ text/xml xml;
+ image/gif gif;
+ image/jpeg jpeg jpg;
+ application/x-javascript js;
+ application/json json;
+ application/atom+xml atom;
+ application/rss+xml rss;
+
+ text/mathml mml;
+ text/plain txt;
+ text/vnd.sun.j2me.app-descriptor jad;
+ text/vnd.wap.wml wml;
+ text/x-component htc;
+
+ image/png png;
+ image/tiff tif tiff;
+ image/vnd.wap.wbmp wbmp;
+ image/x-icon ico;
+ image/x-jng jng;
+ image/x-ms-bmp bmp;
+ image/svg+xml svg;
+
+ application/java-archive jar war ear;
+ application/mac-binhex40 hqx;
+ application/msword doc;
+ application/pdf pdf;
+ application/postscript ps eps ai;
+ application/rtf rtf;
+ application/vnd.ms-excel xls;
+ application/vnd.ms-powerpoint ppt;
+ application/vnd.wap.wmlc wmlc;
+ application/vnd.wap.xhtml+xml xhtml;
+ application/vnd.google-earth.kml+xml kml;
+ application/vnd.google-earth.kmz kmz;
+ application/x-cocoa cco;
+ application/x-java-archive-diff jardiff;
+ application/x-java-jnlp-file jnlp;
+ application/x-makeself run;
+ application/x-perl pl pm;
+ application/x-pilot prc pdb;
+ application/x-rar-compressed rar;
+ application/x-redhat-package-manager rpm;
+ application/x-sea sea;
+ application/x-shockwave-flash swf;
+ application/x-stuffit sit;
+ application/x-tcl tcl tk;
+ application/x-x509-ca-cert der pem crt;
+ application/x-xpinstall xpi;
+ application/zip zip;
+
+ application/octet-stream bin exe dll;
+ application/octet-stream deb;
+ application/octet-stream dmg;
+ application/octet-stream eot;
+ application/octet-stream iso img;
+ application/octet-stream msi msp msm;
+
+ audio/midi mid midi kar;
+ audio/mpeg mp3;
+ audio/x-realaudio ra;
+
+ video/3gpp 3gpp 3gp;
+ video/mpeg mpeg mpg;
+ video/quicktime mov;
+ video/x-flv flv;
+ video/x-mng mng;
+ video/x-ms-asf asx asf;
+ video/x-ms-wmv wmv;
+ video/x-msvideo avi;
+}
View
255 cookbooks/nginx/metadata.json
@@ -0,0 +1,255 @@
+{
+ "providing": {
+ },
+ "attributes": {
+ "nginx/worker_connections": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "1024",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Number of connections per worker",
+ "display_name": "Nginx Worker Connections"
+ },
+ "nginx/gzip_types": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": [
+ "text/plain",
+ "text/html",
+ "text/css",
+ "application/x-javascript",
+ "text/xml",
+ "application/xml",
+ "application/xml+rss",
+ "text/javascript"
+ ],
+ "type": "array",
+ "recipes": [
+
+ ],
+ "description": "Supported MIME-types for gzip",
+ "display_name": "Nginx Gzip Types"
+ },
+ "nginx/binary": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "/usr/sbin/nginx",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Location of the nginx server binary",
+ "display_name": "Nginx Binary"
+ },
+ "nginx/user": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "www-data",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "User nginx will run as",
+ "display_name": "Nginx User"
+ },
+ "nginx/keepalive_timeout": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "65",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "display_name": "Nginx Keepalive Timeout"
+ },
+ "nginx/gzip_proxied": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "any",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Whether gzip is proxied",
+ "display_name": "Nginx Gzip Proxied"
+ },
+ "nginx/gzip_comp_level": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "2",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Amount of compression to use",
+ "display_name": "Nginx Gzip Compression Level"
+ },
+ "nginx/dir": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "/etc/nginx",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Location of nginx configuration files",
+ "display_name": "Nginx Directory"
+ },
+ "nginx/server_names_hash_bucket_size": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "64",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "display_name": "Nginx Server Names Hash Bucket Size"
+ },
+ "nginx/worker_processes": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "1",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Number of worker processes",
+ "display_name": "Nginx Worker Processes"
+ },
+ "nginx/gzip_http_version": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "1.0",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Version of HTTP Gzip",
+ "display_name": "Nginx Gzip HTTP Version"
+ },
+ "nginx/log_dir": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "/var/log/nginx",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Location for nginx logs",
+ "display_name": "Nginx Log Directory"
+ },
+ "nginx/gzip": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "on",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Whether gzip is enabled",
+ "display_name": "Nginx Gzip"
+ },
+ "nginx/keepalive": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+
+ ],
+ "default": "on",
+ "type": "string",
+ "recipes": [
+
+ ],
+ "description": "Whether to enable keepalive",
+ "display_name": "Nginx Keepalive"
+ }
+ },
+ "maintainer": "Opscode, Inc.",
+ "replacing": {
+ },
+ "dependencies": {
+ "runit": [
+
+ ],
+ "build-essential": [
+
+ ]
+ },
+ "recipes": {
+ "nginx::source": "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available",
+ "nginx": "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available"
+ },
+ "maintainer_email": "cookbooks@opscode.com",
+ "groupings": {
+ },
+ "recommendations": {
+ },
+ "platforms": {
+ "debian": [
+
+ ],
+ "fedora": [
+
+ ],
+ "centos": [
+
+ ],
+ "ubuntu": [
+
+ ],
+ "redhat": [
+
+ ]
+ },
+ "license": "Apache 2.0",
+ "version": "0.14.3",
+ "suggestions": {
+ },
+ "name": "nginx",
+ "conflicting": {
+ },
+ "long_description": "",
+ "description": "Installs and configures nginx"
+ }
View
86 cookbooks/nginx/metadata.rb
@@ -0,0 +1,86 @@
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs and configures nginx"
+version "0.14.3"
+
+recipe "nginx", "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available"
+recipe "nginx::source", "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available"
+
+%w{ ubuntu debian centos redhat fedora }.each do |os|
+ supports os
+end
+
+%w{ build-essential runit }.each do |cb|
+ depends cb
+end
+
+attribute "nginx/dir",
+ :display_name => "Nginx Directory",
+ :description => "Location of nginx configuration files",
+ :default => "/etc/nginx"
+
+attribute "nginx/log_dir",
+ :display_name => "Nginx Log Directory",
+ :description => "Location for nginx logs",
+ :default => "/var/log/nginx"
+
+attribute "nginx/user",
+ :display_name => "Nginx User",
+ :description => "User nginx will run as",
+ :default => "www-data"
+
+attribute "nginx/binary",
+ :display_name => "Nginx Binary",
+ :description => "Location of the nginx server binary",
+ :default => "/usr/sbin/nginx"
+
+attribute "nginx/gzip",
+ :display_name => "Nginx Gzip",
+ :description => "Whether gzip is enabled",
+ :default => "on"
+
+attribute "nginx/gzip_http_version",
+ :display_name => "Nginx Gzip HTTP Version",
+ :description => "Version of HTTP Gzip",
+ :default => "1.0"
+
+attribute "nginx/gzip_comp_level",
+ :display_name => "Nginx Gzip Compression Level",
+ :description => "Amount of compression to use",
+ :default => "2"
+
+attribute "nginx/gzip_proxied",
+ :display_name => "Nginx Gzip Proxied",
+ :description => "Whether gzip is proxied",
+ :default => "any"
+
+attribute "nginx/gzip_types",
+ :display_name => "Nginx Gzip Types",
+ :description => "Supported MIME-types for gzip",
+ :type => "array",
+ :default => [ "text/plain", "text/html", "text/css", "application/x-javascript", "text/xml", "application/xml", "application/xml+rss", "text/javascript" ]
+
+attribute "nginx/keepalive",
+ :display_name => "Nginx Keepalive",
+ :description => "Whether to enable keepalive",
+ :default => "on"
+
+attribute "nginx/keepalive_timeout",
+ :display_name => "Nginx Keepalive Timeout",
+ :default => "65"
+
+attribute "nginx/worker_processes",
+ :display_name => "Nginx Worker Processes",
+ :description => "Number of worker processes",
+ :default => "1"
+
+attribute "nginx/worker_connections",
+ :display_name => "Nginx Worker Connections",
+ :description => "Number of connections per worker",
+ :default => "1024"
+
+attribute "nginx/server_names_hash_bucket_size",
+ :display_name => "Nginx Server Names Hash Bucket Size",
+ :default => "64"
+
View
56 cookbooks/nginx/recipes/default.rb
@@ -0,0 +1,56 @@
+#
+# Cookbook Name:: nginx
+# Recipe:: default
+# Author:: AJ Christensen <aj@junglist.gen.nz>
+#
+# Copyright 2008-2009, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+package "nginx"
+
+directory node[:nginx][:log_dir] do
+ mode 0755
+ owner node[:nginx][:user]
+ action :create
+end
+
+%w{nxensite nxdissite}.each do |nxscript|
+ template "/usr/sbin/#{nxscript}" do
+ source "#{nxscript}.erb"
+ mode 0755
+ owner "root"
+ group "root"
+ end
+end
+
+template "nginx.conf" do
+ path "#{node[:nginx][:dir]}/nginx.conf"
+ source "nginx.conf.erb"
+ owner "root"
+ group "root"
+ mode 0644
+end
+
+template "#{node[:nginx][:dir]}/sites-available/default" do
+ source "default-site.erb"
+ owner "root"
+ group "root"
+ mode 0644
+end
+
+service "nginx" do
+ supports :status => true, :restart => true, :reload => true
+ action [ :enable, :start ]
+end
View
133 cookbooks/nginx/recipes/source.rb
@@ -0,0 +1,133 @@
+#
+# Cookbook Name:: nginx
+# Recipe:: source
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Joshua Timberman (<joshua@opscode.com>)
+#
+# Copyright 2009, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "build-essential"
+
+unless platform?("centos","redhat","fedora")
+ include_recipe "runit"
+end
+
+packages = value_for_platform(
+ ["centos","redhat","fedora"] => {'default' => ['pcre-devel', 'openssl-devel']},
+ "default" => ['libpcre3', 'libpcre3-dev', 'libssl-dev']
+ )
+
+packages.each do |devpkg|
+ package devpkg
+end
+
+nginx_version = node[:nginx][:version]
+configure_flags = node[:nginx][:configure_flags].join(" ")
+node.set[:nginx][:daemon_disable] = true
+
+remote_file "/tmp/nginx-#{nginx_version}.tar.gz" do
+ source "http://sysoev.ru/nginx/nginx-#{nginx_version}.tar.gz"
+ action :create_if_missing
+end
+
+bash "compile_nginx_source" do
+ cwd "/tmp"
+ code <<-EOH
+ tar zxf nginx-#{nginx_version}.tar.gz
+ cd nginx-#{nginx_version} && ./configure #{configure_flags}
+ make && make install
+ EOH
+ creates node[:nginx][:src_binary]
+end
+
+directory node[:nginx][:log_dir] do
+ mode 0755
+ owner node[:nginx][:user]
+ action :create
+end
+
+directory node[:nginx][:dir] do
+ owner "root"
+ group "root"
+ mode "0755"
+end
+
+unless platform?("centos","redhat","fedora")
+ runit_service "nginx"
+
+ service "nginx" do
+ subscribes :restart, resources(:bash => "compile_nginx_source")
+ end
+else
+ #install init db script
+ template "/etc/init.d/nginx" do
+ source "nginx.init.erb"
+ owner "root"
+ group "root"
+ mode "0755"
+ end
+
+ #install sysconfig file (not really needed but standard)
+ template "/etc/sysconfig/nginx" do
+ source "nginx.sysconfig.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ end
+
+ #register service
+ service "nginx" do
+ supports :status => true, :restart => true, :reload => true
+ action :enable
+ subscribes :restart, resources(:bash => "compile_nginx_source")
+ end
+end
+
+
+%w{ sites-available sites-enabled conf.d }.each do |dir|
+ directory "#{node[:nginx][:dir]}/#{dir}" do
+ owner "root"
+ group "root"
+ mode "0755"
+ end
+end
+
+%w{nxensite nxdissite}.each do |nxscript|
+ template "/usr/sbin/#{nxscript}" do
+ source "#{nxscript}.erb"
+ mode "0755"
+ owner "root"
+ group "root"
+ end
+end
+
+template "nginx.conf" do
+ path "#{node[:nginx][:dir]}/nginx.conf"
+ source "nginx.conf.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ notifies :restart, resources(:service => "nginx"), :immediately
+end
+
+cookbook_file "#{node[:nginx][:dir]}/mime.types" do
+ source "mime.types"
+ owner "root"
+ group "root"
+ mode "0644"
+ notifies :restart, resources(:service => "nginx"), :immediately
+end
View
11 cookbooks/nginx/templates/default/default-site.erb
@@ -0,0 +1,11 @@
+server {
+ listen 80;
+ server_name <%= node[:hostname] %>;
+
+ access_log <%= node[:nginx][:log_dir] %>/localhost.access.log;
+
+ location / {
+ root /var/www/nginx-default;
+ index index.html index.htm;
+ }
+}
View
40 cookbooks/nginx/templates/default/nginx.conf.erb
@@ -0,0 +1,40 @@
+user <%= node[:nginx][:user] %>;
+worker_processes <%= node[:nginx][:worker_processes] %>;
+<% if node[:nginx][:daemon_disable] -%>
+daemon off;
+<% end -%>
+
+error_log <%= node[:nginx][:log_dir] %>/error.log;
+pid /var/run/nginx.pid;
+
+events {
+ worker_connections <%= node[:nginx][:worker_connections] %>;
+}
+
+http {
+ include <%= node[:nginx][:dir] %>/mime.types;
+ default_type application/octet-stream;
+
+ access_log <%= node[:nginx][:log_dir] %>/access.log;
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+
+ <% if node[:nginx][:keepalive] == "on" %>
+ keepalive_timeout <%= node[:nginx][:keepalive_timeout] %>;
+ <% end %>
+
+ gzip <%= node[:nginx][:gzip] %>;
+ <% if node[:nginx][:gzip] == "on" %>
+ gzip_http_version <%= node[:nginx][:gzip_http_version] %>;
+ gzip_comp_level <%= node[:nginx][:gzip_comp_level] %>;
+ gzip_proxied <%= node[:nginx][:gzip_proxied] %>;
+ gzip_types <%= node[:nginx][:gzip_types].join(' ') %>;
+ <% end %>
+
+ server_names_hash_bucket_size <%= node[:nginx][:server_names_hash_bucket_size] %>;
+
+ include <%= node[:nginx][:dir] %>/conf.d/*.conf;
+ include <%= node[:nginx][:dir] %>/sites-enabled/*;
+}
View
92 cookbooks/nginx/templates/default/nginx.init.erb
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# nginx
+#
+# chkconfig: - 57 47
+# description: nginx
+# processname: nginx
+# config: /etc/sysconfig/nginx
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Check that networking is up.
+[ "$NETWORKING" = "no" ] && exit
+exec=<%= node[:nginx][:src_binary] %>
+prog=$(basename $exec)
+
+# default options, overruled by items in sysconfig
+NGINX_GLOBAL=""
+
+[ -e /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
+
+lockfile=/var/lock/subsys/nginx
+
+start() {
+ [ -x $exec ] || exit 5
+ echo -n $"Starting $prog: "
+ # if not running, start it up here, usually something like "daemon $exec"
+ options=""
+ if [ "${NGINX_GLOBAL}" != "" ]; then
+ options="-g ${NGINX_GLOBAL}"
+ fi
+ $exec $options
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ $exec -s stop
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ echo -n $"Reloading $prog: "
+ $exec -s reload
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status nginx
+ ;;
+ restart)
+ restart
+ ;;
+ reload|force-reload)
+ reload
+ ;;
+ condrestart)
+ [ -f $lockfile ] && restart || :
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
+ exit 1
+esac
+
+exit $?
View
1  cookbooks/nginx/templates/default/nginx.sysconfig.erb
@@ -0,0 +1 @@
+NGINX_GLOBAL=<%= node[:nginx][:global] %>
View
29 cookbooks/nginx/templates/default/nxdissite.erb
@@ -0,0 +1,29 @@
+#!/bin/sh -e
+
+SYSCONFDIR='<%= node[:nginx][:dir] %>'
+
+if [ -z $1 ]; then
+ echo "Which site would you like to disable?"
+ echo -n "Your choices are: "
+ ls $SYSCONFDIR/sites-enabled/* | \
+ sed -e "s,$SYSCONFDIR/sites-enabled/,,g" | xargs echo
+ echo -n "Site name? "
+ read SITENAME
+else
+ SITENAME=$1
+fi
+
+if [ $SITENAME = "default" ]; then
+ PRIORITY="000"
+fi
+
+if ! [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \
+ -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then
+ echo "This site is already disabled, or does not exist!"
+ exit 1
+fi
+
+if ! rm $SYSCONFDIR/sites-enabled/$SITENAME 2>/dev/null; then
+ rm -f $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME"
+fi
+echo "Site $SITENAME disabled; reload nginx to disable."
View
38 cookbooks/nginx/templates/default/nxensite.erb
@@ -0,0 +1,38 @@
+#!/bin/sh -e
+
+SYSCONFDIR='<%= node[:nginx][:dir] %>'
+
+if [ -z $1 ]; then
+ echo "Which site would you like to enable?"
+ echo -n "Your choices are: "
+ ls $SYSCONFDIR/sites-available/* | \
+ sed -e "s,$SYSCONFDIR/sites-available/,,g" | xargs echo
+ echo -n "Site name? "
+ read SITENAME
+else
+ SITENAME=$1
+fi
+
+if [ $SITENAME = "default" ]; then
+ PRIORITY="000"
+fi
+
+if [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \
+ -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then
+ echo "This site is already enabled!"
+ exit 0
+fi
+
+if ! [ -e $SYSCONFDIR/sites-available/$SITENAME ]; then
+ echo "This site does not exist!"
+ exit 1
+fi
+
+if [ $SITENAME = "default" ]; then
+ ln -sf $SYSCONFDIR/sites-available/$SITENAME \
+ $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME"
+else
+ ln -sf $SYSCONFDIR/sites-available/$SITENAME $SYSCONFDIR/sites-enabled/$SITENAME
+fi
+
+echo "Site $SITENAME installed; reload nginx to enable."
View
2  cookbooks/nginx/templates/default/sv-nginx-log-run.erb
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec svlogd -tt ./main
View
3  cookbooks/nginx/templates/default/sv-nginx-run.erb
@@ -0,0 +1,3 @@
+#!/bin/sh
+exec 2>&1
+exec <%= node[:nginx][:install_path] %>/sbin/nginx -c <%= node[:nginx][:dir] %>/nginx.conf
Please sign in to comment.
Something went wrong with that request. Please try again.