from-scratch 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +2 -1
  3. data/Berksfile.lock +20 -1
  4. data/cookbooks/bluepill/CHANGELOG.md +93 -0
  5. data/cookbooks/bluepill/README.md +91 -0
  6. data/cookbooks/bluepill/attributes/default.rb +44 -0
  7. data/cookbooks/bluepill/metadata.json +1 -0
  8. data/cookbooks/bluepill/providers/service.rb +172 -0
  9. data/cookbooks/bluepill/recipes/default.rb +48 -0
  10. data/cookbooks/bluepill/recipes/rsyslog.rb +28 -0
  11. data/cookbooks/bluepill/resources/service.rb +27 -0
  12. data/cookbooks/bluepill/templates/default/bluepill_init.fedora.erb +34 -0
  13. data/cookbooks/bluepill/templates/default/bluepill_init.freebsd.erb +32 -0
  14. data/cookbooks/bluepill/templates/default/bluepill_init.lsb.erb +37 -0
  15. data/cookbooks/bluepill/templates/default/bluepill_init.rhel.erb +34 -0
  16. data/cookbooks/bluepill/templates/default/bluepill_rsyslog.conf.erb +1 -0
  17. data/cookbooks/nginx/CHANGELOG.md +435 -0
  18. data/cookbooks/nginx/README.md +521 -0
  19. data/cookbooks/nginx/attributes/auth_request.rb +23 -0
  20. data/cookbooks/nginx/attributes/default.rb +131 -0
  21. data/cookbooks/nginx/attributes/devel.rb +24 -0
  22. data/cookbooks/nginx/attributes/echo.rb +24 -0
  23. data/cookbooks/nginx/attributes/geoip.rb +31 -0
  24. data/cookbooks/nginx/attributes/headers_more.rb +24 -0
  25. data/cookbooks/nginx/attributes/lua.rb +28 -0
  26. data/cookbooks/nginx/attributes/naxsi.rb +24 -0
  27. data/cookbooks/nginx/attributes/openssl_source.rb +23 -0
  28. data/cookbooks/nginx/attributes/pagespeed.rb +9 -0
  29. data/cookbooks/nginx/attributes/passenger.rb +58 -0
  30. data/cookbooks/nginx/attributes/rate_limiting.rb +23 -0
  31. data/cookbooks/nginx/attributes/repo.rb +35 -0
  32. data/cookbooks/nginx/attributes/set_misc.rb +8 -0
  33. data/cookbooks/nginx/attributes/socketproxy.rb +13 -0
  34. data/cookbooks/nginx/attributes/source.rb +42 -0
  35. data/cookbooks/nginx/attributes/status.rb +22 -0
  36. data/cookbooks/nginx/attributes/syslog.rb +24 -0
  37. data/cookbooks/nginx/attributes/upload_progress.rb +26 -0
  38. data/cookbooks/nginx/definitions/nginx_site.rb +50 -0
  39. data/cookbooks/nginx/files/default/mime.types +78 -0
  40. data/cookbooks/nginx/files/default/naxsi_core.rules +82 -0
  41. data/cookbooks/nginx/libraries/matchers.rb +20 -0
  42. data/cookbooks/nginx/metadata.json +351 -0
  43. data/cookbooks/nginx/recipes/authorized_ips.rb +32 -0
  44. data/cookbooks/nginx/recipes/commons.rb +24 -0
  45. data/cookbooks/nginx/recipes/commons_conf.rb +42 -0
  46. data/cookbooks/nginx/recipes/commons_dir.rb +57 -0
  47. data/cookbooks/nginx/recipes/commons_script.rb +29 -0
  48. data/cookbooks/nginx/recipes/default.rb +31 -0
  49. data/cookbooks/nginx/recipes/headers_more_module.rb +50 -0
  50. data/cookbooks/nginx/recipes/http_auth_request_module.rb +52 -0
  51. data/cookbooks/nginx/recipes/http_echo_module.rb +46 -0
  52. data/cookbooks/nginx/recipes/http_geoip_module.rb +113 -0
  53. data/cookbooks/nginx/recipes/http_gzip_static_module.rb +30 -0
  54. data/cookbooks/nginx/recipes/http_mp4_module.rb +2 -0
  55. data/cookbooks/nginx/recipes/http_perl_module.rb +23 -0
  56. data/cookbooks/nginx/recipes/http_realip_module.rb +38 -0
  57. data/cookbooks/nginx/recipes/http_spdy_module.rb +23 -0
  58. data/cookbooks/nginx/recipes/http_ssl_module.rb +23 -0
  59. data/cookbooks/nginx/recipes/http_stub_status_module.rb +36 -0
  60. data/cookbooks/nginx/recipes/ipv6.rb +23 -0
  61. data/cookbooks/nginx/recipes/lua.rb +47 -0
  62. data/cookbooks/nginx/recipes/naxsi_module.rb +52 -0
  63. data/cookbooks/nginx/recipes/ngx_devel_module.rb +44 -0
  64. data/cookbooks/nginx/recipes/ngx_lua_module.rb +47 -0
  65. data/cookbooks/nginx/recipes/ohai_plugin.rb +35 -0
  66. data/cookbooks/nginx/recipes/openssl_source.rb +45 -0
  67. data/cookbooks/nginx/recipes/package.rb +52 -0
  68. data/cookbooks/nginx/recipes/pagespeed_module.rb +62 -0
  69. data/cookbooks/nginx/recipes/passenger.rb +56 -0
  70. data/cookbooks/nginx/recipes/repo.rb +41 -0
  71. data/cookbooks/nginx/recipes/repo_passenger.rb +39 -0
  72. data/cookbooks/nginx/recipes/set_misc.rb +30 -0
  73. data/cookbooks/nginx/recipes/socketproxy.rb +26 -0
  74. data/cookbooks/nginx/recipes/source.rb +205 -0
  75. data/cookbooks/nginx/recipes/syslog_module.rb +69 -0
  76. data/cookbooks/nginx/recipes/upload_progress_module.rb +53 -0
  77. data/cookbooks/nginx/templates/debian/nginx.init.erb +97 -0
  78. data/cookbooks/nginx/templates/default/default-site.erb +11 -0
  79. data/cookbooks/nginx/templates/default/modules/authorized_ip.erb +6 -0
  80. data/cookbooks/nginx/templates/default/modules/http_geoip.conf.erb +4 -0
  81. data/cookbooks/nginx/templates/default/modules/http_gzip_static.conf.erb +1 -0
  82. data/cookbooks/nginx/templates/default/modules/http_realip.conf.erb +7 -0
  83. data/cookbooks/nginx/templates/default/modules/nginx_status.erb +14 -0
  84. data/cookbooks/nginx/templates/default/modules/passenger.conf.erb +13 -0
  85. data/cookbooks/nginx/templates/default/modules/socketproxy.conf.erb +89 -0
  86. data/cookbooks/nginx/templates/default/modules/upload_progress.erb +4 -0
  87. data/cookbooks/nginx/templates/default/nginx-upstart.conf.erb +39 -0
  88. data/cookbooks/nginx/templates/default/nginx.conf.erb +103 -0
  89. data/cookbooks/nginx/templates/default/nginx.init.erb +111 -0
  90. data/cookbooks/nginx/templates/default/nginx.pill.erb +15 -0
  91. data/cookbooks/nginx/templates/default/nginx.sysconfig.erb +1 -0
  92. data/cookbooks/nginx/templates/default/nxdissite.erb +29 -0
  93. data/cookbooks/nginx/templates/default/nxensite.erb +38 -0
  94. data/cookbooks/nginx/templates/default/plugins/nginx.rb.erb +66 -0
  95. data/cookbooks/nginx/templates/default/sv-nginx-log-run.erb +2 -0
  96. data/cookbooks/nginx/templates/default/sv-nginx-run.erb +4 -0
  97. data/cookbooks/nginx/templates/gentoo/nginx.init.erb +87 -0
  98. data/cookbooks/nginx/templates/suse/nginx.init.erb +115 -0
  99. data/cookbooks/nginx/templates/ubuntu/nginx.init.erb +97 -0
  100. data/cookbooks/ohai/CHANGELOG.md +69 -0
  101. data/cookbooks/ohai/README.md +89 -0
  102. data/cookbooks/ohai/attributes/default.rb +31 -0
  103. data/cookbooks/ohai/files/default/plugins/README +1 -0
  104. data/cookbooks/ohai/libraries/matchers.rb +14 -0
  105. data/cookbooks/ohai/metadata.json +1 -0
  106. data/cookbooks/ohai/providers/hint.rb +38 -0
  107. data/cookbooks/ohai/recipes/default.rb +52 -0
  108. data/cookbooks/ohai/resources/hint.rb +5 -0
  109. data/cookbooks/packagecloud/CHANGELOG.md +12 -0
  110. data/cookbooks/packagecloud/README.md +80 -0
  111. data/cookbooks/packagecloud/attributes/default.rb +8 -0
  112. data/cookbooks/packagecloud/libraries/helper.rb +43 -0
  113. data/cookbooks/packagecloud/libraries/matcher.rb +7 -0
  114. data/cookbooks/packagecloud/metadata.json +1 -0
  115. data/cookbooks/packagecloud/providers/repo.rb +212 -0
  116. data/cookbooks/packagecloud/resources/repo.rb +10 -0
  117. data/cookbooks/packagecloud/templates/.kitchen/logs/kitchen.log +29 -0
  118. data/cookbooks/packagecloud/templates/default/apt.erb +2 -0
  119. data/cookbooks/packagecloud/templates/default/yum.erb +15 -0
  120. data/cookbooks/rsyslog/CHANGELOG.md +193 -0
  121. data/cookbooks/rsyslog/README.md +276 -0
  122. data/cookbooks/rsyslog/attributes/default.rb +131 -0
  123. data/cookbooks/rsyslog/libraries/helpers.rb +25 -0
  124. data/cookbooks/rsyslog/metadata.json +1 -0
  125. data/cookbooks/rsyslog/providers/file_input.rb +44 -0
  126. data/cookbooks/rsyslog/recipes/client.rb +87 -0
  127. data/cookbooks/rsyslog/recipes/default.rb +89 -0
  128. data/cookbooks/rsyslog/recipes/server.rb +44 -0
  129. data/cookbooks/rsyslog/resources/file_input.rb +28 -0
  130. data/cookbooks/rsyslog/templates/default/35-server-per-host.conf.erb +62 -0
  131. data/cookbooks/rsyslog/templates/default/49-relp.conf.erb +10 -0
  132. data/cookbooks/rsyslog/templates/default/49-remote.conf.erb +30 -0
  133. data/cookbooks/rsyslog/templates/default/50-default.conf.erb +6 -0
  134. data/cookbooks/rsyslog/templates/default/file-input.conf.erb +15 -0
  135. data/cookbooks/rsyslog/templates/default/omnios-manifest.xml.erb +30 -0
  136. data/cookbooks/rsyslog/templates/default/rsyslog.conf.erb +117 -0
  137. data/cookbooks/rsyslog/templates/smartos/50-default.conf.erb +18 -0
  138. data/cookbooks/runit/.kitchen.cloud.yml +103 -0
  139. data/cookbooks/runit/.kitchen.yml +38 -0
  140. data/cookbooks/runit/.rspec +3 -0
  141. data/cookbooks/runit/.rubocop.yml +45 -0
  142. data/cookbooks/runit/Berksfile.disabled +11 -0
  143. data/cookbooks/runit/CHANGELOG.md +226 -0
  144. data/cookbooks/runit/CONTRIBUTING.md +266 -0
  145. data/cookbooks/runit/Cheffile +11 -0
  146. data/cookbooks/runit/Gemfile +17 -0
  147. data/cookbooks/runit/LICENSE +201 -0
  148. data/cookbooks/runit/README.md +435 -0
  149. data/cookbooks/runit/Rakefile +23 -0
  150. data/cookbooks/runit/TESTING.md +26 -0
  151. data/cookbooks/runit/attributes/default.rb +62 -0
  152. data/cookbooks/runit/files/default/runit.seed +1 -0
  153. data/cookbooks/runit/files/default/runsvdir +0 -0
  154. data/cookbooks/runit/files/ubuntu-6.10/runsvdir +6 -0
  155. data/cookbooks/runit/files/ubuntu-7.04/runsvdir +7 -0
  156. data/cookbooks/runit/files/ubuntu-7.10/runsvdir +7 -0
  157. data/cookbooks/runit/files/ubuntu-8.04/runsvdir +7 -0
  158. data/cookbooks/runit/libraries/default.rb +0 -0
  159. data/cookbooks/runit/libraries/helpers.rb +190 -0
  160. data/cookbooks/runit/libraries/matchers.rb +69 -0
  161. data/cookbooks/runit/libraries/provider_runit_service.rb +326 -0
  162. data/cookbooks/runit/libraries/resource_runit_service.rb +267 -0
  163. data/cookbooks/runit/metadata.json +50 -0
  164. data/cookbooks/runit/recipes/default.rb +91 -0
  165. data/cookbooks/runit/templates/debian/init.d.erb +66 -0
  166. data/cookbooks/runit/templates/default/log-config.erb +24 -0
  167. data/cookbooks/runit/templates/gentoo/runit-start.sh.erb +32 -0
  168. data/cookbooks/scratchify/Berksfile +2 -1
  169. data/cookbooks/scratchify/Berksfile.lock +20 -1
  170. data/cookbooks/scratchify/lib/from-scratch.rb +1 -4
  171. data/cookbooks/scratchify/lib/from-scratch/version.rb +1 -1
  172. data/cookbooks/scratchify/metadata.json +5 -2
  173. data/cookbooks/scratchify/recipes/default.rb +15 -1
  174. data/cookbooks/scratchify/recipes/nginx_site.rb +4 -0
  175. data/cookbooks/scratchify/recipes/pre_rvm.rb +5 -0
  176. data/cookbooks/scratchify/templates/nginx.erb +31 -0
  177. data/cookbooks/scratchify/templates/node.json.erb +21 -6
  178. data/cookbooks/yum-epel/CHANGELOG.md +84 -0
  179. data/cookbooks/yum-epel/README.md +172 -0
  180. data/cookbooks/yum-epel/attributes/default.rb +1 -0
  181. data/cookbooks/yum-epel/attributes/epel-debuginfo.rb +28 -0
  182. data/cookbooks/yum-epel/attributes/epel-source.rb +28 -0
  183. data/cookbooks/yum-epel/attributes/epel-testing-debuginfo.rb +28 -0
  184. data/cookbooks/yum-epel/attributes/epel-testing-source.rb +28 -0
  185. data/cookbooks/yum-epel/attributes/epel-testing.rb +28 -0
  186. data/cookbooks/yum-epel/attributes/epel.rb +28 -0
  187. data/cookbooks/yum-epel/metadata.json +1 -0
  188. data/cookbooks/yum-epel/recipes/default.rb +61 -0
  189. data/cookbooks/yum/CHANGELOG.md +294 -0
  190. data/cookbooks/yum/README.md +285 -0
  191. data/cookbooks/yum/attributes/main.rb +100 -0
  192. data/cookbooks/yum/libraries/matchers.rb +27 -0
  193. data/cookbooks/yum/metadata.json +1 -0
  194. data/cookbooks/yum/providers/globalconfig.rb +41 -0
  195. data/cookbooks/yum/providers/repository.rb +106 -0
  196. data/cookbooks/yum/recipes/default.rb +26 -0
  197. data/cookbooks/yum/resources/globalconfig.rb +109 -0
  198. data/cookbooks/yum/resources/repository.rb +69 -0
  199. data/cookbooks/yum/templates/default/main.erb +276 -0
  200. data/cookbooks/yum/templates/default/repo.erb +125 -0
  201. data/lib/from-scratch.rb +1 -0
  202. data/lib/from-scratch/version.rb +1 -1
  203. data/metadata.rb +5 -1
  204. data/recipes/default.rb +15 -1
  205. data/recipes/nginx_site.rb +4 -0
  206. data/recipes/pre_rvm.rb +5 -0
  207. data/templates/nginx.erb +31 -0
  208. data/templates/node.json.erb +21 -6
  209. metadata +194 -1
@@ -0,0 +1,111 @@
1
+ #!/bin/sh
2
+ #
3
+ # nginx
4
+ #
5
+ # chkconfig: - 57 47
6
+ # description: nginx
7
+ # processname: nginx
8
+ # config: /etc/sysconfig/nginx
9
+ #
10
+
11
+ # Source function library.
12
+ . /etc/rc.d/init.d/functions
13
+
14
+ # Source networking configuration.
15
+ . /etc/sysconfig/network
16
+
17
+ # Check that networking is up.
18
+ [ "$NETWORKING" = "no" ] && exit
19
+ exec=<%= node['nginx']['binary'] %>
20
+ prog=$(basename $exec)
21
+
22
+ # default options, overruled by items in sysconfig
23
+ NGINX_GLOBAL=""
24
+
25
+ [ -e /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
26
+
27
+ lockfile=/var/lock/subsys/nginx
28
+
29
+ start() {
30
+ [ -x $exec ] || exit 5
31
+ echo -n $"Starting $prog: "
32
+ # if not running, start it up here, usually something like "daemon $exec"
33
+ options=""
34
+ if [ "${NGINX_GLOBAL}" != "" ]; then
35
+ options="-g ${NGINX_GLOBAL}"
36
+ fi
37
+ $exec $options
38
+ retval=$?
39
+ echo
40
+ [ $retval -eq 0 ] && touch $lockfile
41
+ return $retval
42
+ }
43
+
44
+ stop() {
45
+ echo -n $"Stopping $prog: "
46
+ $exec -s stop
47
+ retval=$?
48
+ echo
49
+ [ $retval -eq 0 ] && rm -f $lockfile
50
+ return $retval
51
+ }
52
+
53
+ restart() {
54
+ stop
55
+ start
56
+ }
57
+
58
+ reload() {
59
+ echo -n $"Reloading $prog: "
60
+ $exec -s reload
61
+ retval=$?
62
+ echo
63
+ [ $retval -eq 0 ] && rm -f $lockfile
64
+ return $retval
65
+ }
66
+
67
+ configtest() {
68
+ if [ "$#" -ne 0 ] ; then
69
+ case "$1" in
70
+ -q)
71
+ FLAG=$1
72
+ ;;
73
+ *)
74
+ ;;
75
+ esac
76
+ shift
77
+ fi
78
+ ${exec} -t $FLAG
79
+ RETVAL=$?
80
+ return $RETVAL
81
+ }
82
+
83
+ # See how we were called.
84
+ case "$1" in
85
+ start)
86
+ start
87
+ ;;
88
+ stop)
89
+ stop
90
+ ;;
91
+ status)
92
+ status nginx
93
+ ;;
94
+ restart)
95
+ restart
96
+ ;;
97
+ reload|force-reload)
98
+ reload
99
+ ;;
100
+ condrestart)
101
+ [ -f $lockfile ] && restart || :
102
+ ;;
103
+ configtest)
104
+ configtest
105
+ ;;
106
+ *)
107
+ echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|configtest}"
108
+ exit 1
109
+ esac
110
+
111
+ exit $?
@@ -0,0 +1,15 @@
1
+ Bluepill.application("nginx", :log_file => "<%= node['nginx']['log_dir'] %>/bluepill-nginx.log") do |app|
2
+ app.process("nginx") do |process|
3
+ process.pid_file = "<%= node['nginx']['pid'] %>"
4
+ process.working_dir = "<%= node['nginx']['source']['prefix'] %>"
5
+ process.start_command = "<%= node['nginx']['binary'] %> -c <%= node['nginx']['dir'] %>/nginx.conf"
6
+ process.stop_command = "kill -QUIT {{PID}}"
7
+ process.restart_command = "kill -HUP {{PID}}"
8
+ process.daemonize = true
9
+ process.stdout = process.stderr = "<%= node['nginx']['log_dir'] %>/nginx.log"
10
+
11
+ process.monitor_children do |child_process|
12
+ child_process.stop_command = "kill -QUIT {{PID}}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ NGINX_GLOBAL=<%= node['nginx']['global'] %>
@@ -0,0 +1,29 @@
1
+ #!/bin/sh -e
2
+
3
+ SYSCONFDIR='<%= node['nginx']['dir'] %>'
4
+
5
+ if [ -z $1 ]; then
6
+ echo "Which site would you like to disable?"
7
+ echo -n "Your choices are: "
8
+ ls $SYSCONFDIR/sites-enabled/* | \
9
+ sed -e "s,$SYSCONFDIR/sites-enabled/,,g" | xargs echo
10
+ echo -n "Site name? "
11
+ read SITENAME
12
+ else
13
+ SITENAME=$1
14
+ fi
15
+
16
+ if [ $SITENAME = "default" ]; then
17
+ PRIORITY="000"
18
+ fi
19
+
20
+ if ! [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \
21
+ -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then
22
+ echo "This site is already disabled, or does not exist!"
23
+ exit 1
24
+ fi
25
+
26
+ if ! rm $SYSCONFDIR/sites-enabled/$SITENAME 2>/dev/null; then
27
+ rm -f $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME"
28
+ fi
29
+ echo "Site $SITENAME disabled; reload nginx to disable."
@@ -0,0 +1,38 @@
1
+ #!/bin/sh -e
2
+
3
+ SYSCONFDIR='<%= node['nginx']['dir'] %>'
4
+
5
+ if [ -z $1 ]; then
6
+ echo "Which site would you like to enable?"
7
+ echo -n "Your choices are: "
8
+ ls $SYSCONFDIR/sites-available/* | \
9
+ sed -e "s,$SYSCONFDIR/sites-available/,,g" | xargs echo
10
+ echo -n "Site name? "
11
+ read SITENAME
12
+ else
13
+ SITENAME=$1
14
+ fi
15
+
16
+ if [ $SITENAME = "default" ]; then
17
+ PRIORITY="000"
18
+ fi
19
+
20
+ if [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \
21
+ -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then
22
+ echo "This site is already enabled!"
23
+ exit 0
24
+ fi
25
+
26
+ if ! [ -e $SYSCONFDIR/sites-available/$SITENAME ]; then
27
+ echo "This site does not exist!"
28
+ exit 1
29
+ fi
30
+
31
+ if [ $SITENAME = "default" ]; then
32
+ ln -sf $SYSCONFDIR/sites-available/$SITENAME \
33
+ $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME"
34
+ else
35
+ ln -sf $SYSCONFDIR/sites-available/$SITENAME $SYSCONFDIR/sites-enabled/$SITENAME
36
+ fi
37
+
38
+ echo "Site $SITENAME installed; reload nginx to enable."
@@ -0,0 +1,66 @@
1
+ #
2
+ # Author:: Jamie Winsor (<jamie@vialstudios.com>)
3
+ #
4
+ # Copyright 2012, Riot Games
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "nginx"
20
+ provides "nginx/version"
21
+ provides "nginx/configure_arguments"
22
+ provides "nginx/prefix"
23
+ provides "nginx/conf_path"
24
+
25
+ def parse_flags(flags)
26
+ prefix = nil
27
+ conf_path = nil
28
+
29
+ flags.each do |flag|
30
+ case flag
31
+ when /^--prefix=(.+)$/
32
+ prefix = $1
33
+ when /^--conf-path=(.+)$/
34
+ conf_path = $1
35
+ end
36
+ end
37
+
38
+ [ prefix, conf_path ]
39
+ end
40
+
41
+ nginx Mash.new unless nginx
42
+ nginx[:version] = nil unless nginx[:version]
43
+ nginx[:configure_arguments] = Array.new unless nginx[:configure_arguments]
44
+ nginx[:prefix] = nil unless nginx[:prefix]
45
+ nginx[:conf_path] = nil unless nginx[:conf_path]
46
+
47
+ status, stdout, stderr = run_command(:no_status_check => true, :command => "<%= node['nginx']['binary'] %> -V")
48
+
49
+ if status == 0
50
+ stderr.split("\n").each do |line|
51
+ case line
52
+ when /^configure arguments:(.+)/
53
+ # This could be better: I'm splitting on configure arguments which removes them and also
54
+ # adds a blank string at index 0 of the array. This is why we drop index 0 and map to
55
+ # add the '--' prefix back to the configure argument.
56
+ nginx[:configure_arguments] = $1.split(/\s--/).drop(1).map { |ca| "--#{ca}" }
57
+
58
+ prefix, conf_path = parse_flags(nginx[:configure_arguments])
59
+
60
+ nginx[:prefix] = prefix
61
+ nginx[:conf_path] = conf_path
62
+ when /^nginx version: nginx\/(\d+\.\d+\.\d+)/
63
+ nginx[:version] = $1
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ exec svlogd -tt ./main
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ ulimit -n <%= node['nginx']['ulimit'] %>
3
+ exec 2>&1
4
+ exec <%= node['nginx']['src_binary'] %> -c <%= node['nginx']['dir'] %>/nginx.conf
@@ -0,0 +1,87 @@
1
+ #!/sbin/runscript
2
+ # Copyright 1999-2012 Gentoo Foundation
3
+ # Distributed under the terms of the GNU General Public License v2
4
+ # $Header: /var/cvsroot/gentoo-x86/www-servers/nginx/files/nginx.initd,v 1.1 2012/02/11 10:17:30 hollow Exp $
5
+
6
+ extra_commands="configtest"
7
+ extra_started_commands="upgrade reload"
8
+
9
+ description="Robust, small and high performance http and reverse proxy server"
10
+ description_configtest="Run nginx' internal config check."
11
+ description_upgrade="Upgrade the nginx binary without losing connections."
12
+ description_reload="Reload the nginx configuration without losing connections."
13
+
14
+ nginx_config=<%= node['nginx']['source']['conf_path'] %>
15
+
16
+ command=<%= node['nginx']['binary'] %>
17
+ command_args="-c ${nginx_config}"
18
+ pidfile=<%= node['nginx']['pid'] %>
19
+
20
+ depend() {
21
+ need net
22
+ use dns logger netmount
23
+ }
24
+
25
+ start_pre() {
26
+ if [ "${RC_CMD}" != "restart" ]; then
27
+ configtest || return 1
28
+ fi
29
+ }
30
+
31
+ stop_pre() {
32
+ if [ "${RC_CMD}" = "restart" ]; then
33
+ configtest || return 1
34
+ fi
35
+ }
36
+
37
+ stop_post() {
38
+ rm -f ${pidfile}
39
+ }
40
+
41
+ reload() {
42
+ configtest || return 1
43
+ ebegin "Refreshing nginx' configuration"
44
+ kill -HUP `cat ${pidfile}` &>/dev/null
45
+ eend $? "Failed to reload nginx"
46
+ }
47
+
48
+ upgrade() {
49
+ configtest || return 1
50
+ ebegin "Upgrading nginx"
51
+
52
+ einfo "Sending USR2 to old binary"
53
+ kill -USR2 `cat ${pidfile}` &>/dev/null
54
+
55
+ einfo "Sleeping 3 seconds before pid-files checking"
56
+ sleep 3
57
+
58
+ if [ ! -f ${pidfile}.oldbin ]; then
59
+ eerror "File with old pid not found"
60
+ return 1
61
+ fi
62
+
63
+ if [ ! -f ${pidfile} ]; then
64
+ eerror "New binary failed to start"
65
+ return 1
66
+ fi
67
+
68
+ einfo "Sleeping 3 seconds before WINCH"
69
+ sleep 3 ; kill -WINCH `cat ${pidfile}.oldbin`
70
+
71
+ einfo "Sending QUIT to old binary"
72
+ kill -QUIT `cat ${pidfile}.oldbin`
73
+
74
+ einfo "Upgrade completed"
75
+ eend $? "Upgrade failed"
76
+ }
77
+
78
+ configtest() {
79
+ ebegin "Checking nginx' configuration"
80
+ ${command} -c ${nginx_config} -t -q
81
+
82
+ if [ $? -ne 0 ]; then
83
+ ${command} -c ${nginx_config} -t
84
+ fi
85
+
86
+ eend $? "failed, please correct errors above"
87
+ }
@@ -0,0 +1,115 @@
1
+ #!/bin/sh
2
+ #
3
+ # nginx
4
+ #
5
+ ### BEGIN INIT INFO
6
+ # Provides: nginx
7
+ # Required-Start: $local_fs $remote_fs $network $syslog
8
+ # Required-Stop: $local_fs $remote_fs $network $syslog
9
+ # Default-Start: 2 3 4 5
10
+ # Default-Stop: 0 1 6
11
+ # Short-Description: starts the nginx web server
12
+ # Description: starts nginx using start-stop-daemon
13
+ ### END INIT INFO
14
+
15
+ # Source function library.
16
+ . /etc/rc.status
17
+
18
+ rc_reset
19
+
20
+ # Check that networking is up.
21
+ [ "$NETWORKING" = "no" ] && exit
22
+ exec=<%= node['nginx']['binary'] %>
23
+ prog=$(basename $exec)
24
+
25
+ # default options, overruled by items in sysconfig
26
+ NGINX_GLOBAL=""
27
+
28
+ [ -e /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
29
+
30
+ lockfile=/var/lock/subsys/nginx
31
+
32
+ start() {
33
+ [ -x $exec ] || exit 5
34
+ echo -n $"Starting $prog: "
35
+ # if not running, start it up here, usually something like "daemon $exec"
36
+ options=""
37
+ if [ "${NGINX_GLOBAL}" != "" ]; then
38
+ options="-g ${NGINX_GLOBAL}"
39
+ fi
40
+ $exec $options
41
+ retval=$?
42
+ echo
43
+ [ $retval -eq 0 ] && touch $lockfile
44
+ rc_status -v
45
+ }
46
+
47
+ stop() {
48
+ echo -n $"Stopping $prog: "
49
+ $exec -s stop
50
+ retval=$?
51
+ echo
52
+ [ $retval -eq 0 ] && rm -f $lockfile
53
+ rc_status -v
54
+ }
55
+
56
+ restart() {
57
+ stop
58
+ start
59
+ rc_status
60
+ }
61
+
62
+ reload() {
63
+ echo -n $"Reloading $prog: "
64
+ $exec -s reload
65
+ retval=$?
66
+ echo
67
+ [ $retval -eq 0 ] && rm -f $lockfile
68
+ rc_status -v
69
+ }
70
+
71
+ configtest() {
72
+ if [ "$#" -ne 0 ] ; then
73
+ case "$1" in
74
+ -q)
75
+ FLAG=$1
76
+ ;;
77
+ *)
78
+ ;;
79
+ esac
80
+ shift
81
+ fi
82
+ ${exec} -t $FLAG
83
+ RETVAL=$?
84
+ return $RETVAL
85
+ }
86
+
87
+ # See how we were called.
88
+ case "$1" in
89
+ start)
90
+ start
91
+ ;;
92
+ stop)
93
+ stop
94
+ ;;
95
+ status)
96
+ status nginx
97
+ ;;
98
+ restart)
99
+ restart
100
+ ;;
101
+ reload|force-reload)
102
+ reload
103
+ ;;
104
+ condrestart)
105
+ [ -f $lockfile ] && restart || :
106
+ ;;
107
+ configtest)
108
+ configtest
109
+ ;;
110
+ *)
111
+ echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|configtest}"
112
+ exit 1
113
+ esac
114
+
115
+ exit $?