itamae-plugin-recipe-nginx_build 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e722fe0602d40022384d75cedc85b8b9c784c259
4
- data.tar.gz: 34bd61da05ae005644e18073f45598752179d530
3
+ metadata.gz: 2b04cdd5719b7dba6c55e696134518fefa1d2cb6
4
+ data.tar.gz: d30db3a2978703f22cef085e9feca0db4337823d
5
5
  SHA512:
6
- metadata.gz: ee024e2d1b408f210f33c0a056de33644e3dcf08ea93455a5c65f2be651525d6c4aac2f7e93e2f7557ee2765fb79a8fc507cff94e3a11d053402d7b1690e2c2f
7
- data.tar.gz: 4268c9935813e96abc5da7242050219e78b746ab3338b18ff411e03e3754f1d08d4dbf1d2ab61876aeaa52c3dbb39a02c6854793d9812a930067a4f2264a5701
6
+ metadata.gz: 70d287037ebf0af11abadd65e74ab4e809b0bca18c1755e129d2bd710f04c58c5a986d1ae2b3915aa19805274fdc78f76bc7909aaf83d60c9f1536eab6d778ff
7
+ data.tar.gz: 28228bce16acc3d78ffec8b00ecf1febbfb941716b75965ef71223fb154d4f399e0d4113523e7788734039e3b6ef30a30c6b0010cadadd28ac00515546ff7ea9
@@ -9,7 +9,13 @@ nginx_build_version = node[:nginx_build][:version] if node[:nginx_build] && node
9
9
  nginx_build_bin = "/usr/local/bin/"
10
10
  nginx_build_bin = node[:nginx_build][:bin] if node[:nginx_build] && node[:nginx_build][:bin]
11
11
 
12
- %w(pcre pcre-devel).each do |pkg|
12
+ case node[:platform]
13
+ when 'debian', 'ubuntu', 'mint'
14
+ packages = %w(libpcre3 libpcre3-dev)
15
+ else
16
+ packages = %w(pcre pcre-devel)
17
+ end
18
+ packages.each do |pkg|
13
19
  package pkg
14
20
  end
15
21
 
@@ -23,4 +29,4 @@ mv nginx-build #{nginx_build_bin}
23
29
  EOS
24
30
  command nginx_build
25
31
  not_if "test -e #{nginx_build_bin}nginx-build"
26
- end
32
+ end
@@ -74,11 +74,18 @@ execute "build-nginx" do
74
74
  action :nothing
75
75
  end
76
76
 
77
+ case node[:platform]
78
+ when 'debian', 'ubuntu', 'mint'
79
+ init_nginx_template_path = "./templates/init_nginx_debian.erb"
80
+ else
81
+ init_nginx_template_path = "./templates/init_nginx.erb"
82
+ end
83
+
77
84
  template "/etc/init.d/nginx" do
78
85
  owner "root"
79
86
  group "root"
80
87
  mode "755"
81
- source "./templates/init_nginx.erb"
88
+ source init_nginx_template_path
82
89
  variables({
83
90
  "nginx_sbin" => nginx_sbin,
84
91
  "nginx_conf" => nginx_conf,
@@ -0,0 +1,207 @@
1
+ #!/bin/sh
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: nginx
5
+ # Required-Start: $local_fs $remote_fs $network $syslog $named
6
+ # Required-Stop: $local_fs $remote_fs $network $syslog $named
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: starts the nginx web server
10
+ # Description: starts nginx using start-stop-daemon
11
+ # config: <%=@nginx_conf%>
12
+ # pidfile: <%=@nginx_pid%>
13
+ ### END INIT INFO
14
+
15
+ DAEMON="<%=@nginx_sbin%>"
16
+ NAME=nginx
17
+ DESC=nginx
18
+ PID="<%=@nginx_pid%>"
19
+ DAEMON_OPTS="-c <%=@nginx_conf%>"
20
+
21
+ # Include nginx defaults if available
22
+ if [ -r /etc/default/nginx ]; then
23
+ . /etc/default/nginx
24
+ fi
25
+
26
+ STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"
27
+
28
+ test -x $DAEMON || exit 0
29
+
30
+ . /lib/init/vars.sh
31
+ . /lib/lsb/init-functions
32
+
33
+ # Check if the ULIMIT is set in /etc/default/nginx
34
+ if [ -n "$ULIMIT" ]; then
35
+ # Set the ulimits
36
+ ulimit $ULIMIT
37
+ fi
38
+
39
+ #
40
+ # Function that starts the daemon/service
41
+ #
42
+ do_start()
43
+ {
44
+ # Return
45
+ # 0 if daemon has been started
46
+ # 1 if daemon was already running
47
+ # 2 if daemon could not be started
48
+ start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON --test > /dev/null \
49
+ || return 1
50
+ start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON -- \
51
+ $DAEMON_OPTS 2>/dev/null \
52
+ || return 2
53
+ }
54
+
55
+ test_nginx_config() {
56
+ $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1
57
+ }
58
+
59
+ #
60
+ # Function that stops the daemon/service
61
+ #
62
+ do_stop()
63
+ {
64
+ # Return
65
+ # 0 if daemon has been stopped
66
+ # 1 if daemon was already stopped
67
+ # 2 if daemon could not be stopped
68
+ # other if a failure occurred
69
+ start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME
70
+ RETVAL="$?"
71
+
72
+ sleep 1
73
+ return "$RETVAL"
74
+ }
75
+
76
+ #
77
+ # Function that sends a SIGHUP to the daemon/service
78
+ #
79
+ do_reload() {
80
+ start-stop-daemon --stop --signal HUP --quiet --pidfile $PID --name $NAME
81
+ return 0
82
+ }
83
+
84
+ #
85
+ # Rotate log files
86
+ #
87
+ do_rotate() {
88
+ start-stop-daemon --stop --signal USR1 --quiet --pidfile $PID --name $NAME
89
+ return 0
90
+ }
91
+
92
+ #
93
+ # Online upgrade nginx executable
94
+ #
95
+ # "Upgrading Executable on the Fly"
96
+ # http://nginx.org/en/docs/control.html
97
+ #
98
+ do_upgrade() {
99
+ # Return
100
+ # 0 if nginx has been successfully upgraded
101
+ # 1 if nginx is not running
102
+ # 2 if the pid files were not created on time
103
+ # 3 if the old master could not be killed
104
+ if start-stop-daemon --stop --signal USR2 --quiet --pidfile $PID --name $NAME; then
105
+ # Wait for both old and new master to write their pid file
106
+ while [ ! -s "${PID}.oldbin" ] || [ ! -s "${PID}" ]; do
107
+ cnt=`expr $cnt + 1`
108
+ if [ $cnt -gt 10 ]; then
109
+ return 2
110
+ fi
111
+ sleep 1
112
+ done
113
+ # Everything is ready, gracefully stop the old master
114
+ if start-stop-daemon --stop --signal QUIT --quiet --pidfile "${PID}.oldbin" --name $NAME; then
115
+ return 0
116
+ else
117
+ return 3
118
+ fi
119
+ else
120
+ return 1
121
+ fi
122
+ }
123
+
124
+ case "$1" in
125
+ start)
126
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
127
+ do_start
128
+ case "$?" in
129
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
130
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
131
+ esac
132
+ ;;
133
+ stop)
134
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
135
+ do_stop
136
+ case "$?" in
137
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
138
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
139
+ esac
140
+ ;;
141
+ restart)
142
+ log_daemon_msg "Restarting $DESC" "$NAME"
143
+
144
+ # Check configuration before stopping nginx
145
+ if ! test_nginx_config; then
146
+ log_end_msg 1 # Configuration error
147
+ exit 0
148
+ fi
149
+
150
+ do_stop
151
+ case "$?" in
152
+ 0|1)
153
+ do_start
154
+ case "$?" in
155
+ 0) log_end_msg 0 ;;
156
+ 1) log_end_msg 1 ;; # Old process is still running
157
+ *) log_end_msg 1 ;; # Failed to start
158
+ esac
159
+ ;;
160
+ *)
161
+ # Failed to stop
162
+ log_end_msg 1
163
+ ;;
164
+ esac
165
+ ;;
166
+ reload|force-reload)
167
+ log_daemon_msg "Reloading $DESC configuration" "$NAME"
168
+
169
+ # Check configuration before reload nginx
170
+ #
171
+ # This is not entirely correct since the on-disk nginx binary
172
+ # may differ from the in-memory one, but that's not common.
173
+ # We prefer to check the configuration and return an error
174
+ # to the administrator.
175
+ if ! test_nginx_config; then
176
+ log_end_msg 1 # Configuration error
177
+ exit 0
178
+ fi
179
+
180
+ do_reload
181
+ log_end_msg $?
182
+ ;;
183
+ configtest|testconfig)
184
+ log_daemon_msg "Testing $DESC configuration"
185
+ test_nginx_config
186
+ log_end_msg $?
187
+ ;;
188
+ status)
189
+ status_of_proc -p $PID "$DAEMON" "$NAME" && exit 0 || exit $?
190
+ ;;
191
+ upgrade)
192
+ log_daemon_msg "Upgrading binary" "$NAME"
193
+ do_upgrade
194
+ log_end_msg 0
195
+ ;;
196
+ rotate)
197
+ log_daemon_msg "Re-opening $DESC log files" "$NAME"
198
+ do_rotate
199
+ log_end_msg $?
200
+ ;;
201
+ *)
202
+ echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}" >&2
203
+ exit 3
204
+ ;;
205
+ esac
206
+
207
+ :
@@ -2,7 +2,7 @@ module Itamae
2
2
  module Plugin
3
3
  module Recipe
4
4
  module NginxBuild
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-plugin-recipe-nginx_build
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - zaru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-19 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itamae
@@ -86,6 +86,7 @@ files:
86
86
  - lib/itamae/plugin/recipe/nginx_build/install.rb
87
87
  - lib/itamae/plugin/recipe/nginx_build/templates/configure.sh.erb
88
88
  - lib/itamae/plugin/recipe/nginx_build/templates/init_nginx.erb
89
+ - lib/itamae/plugin/recipe/nginx_build/templates/init_nginx_debian.erb
89
90
  - lib/itamae/plugin/recipe/nginx_build/templates/modules3rd.ini.erb
90
91
  - lib/itamae/plugin/recipe/nginx_build/version.rb
91
92
  homepage: https://github.com/zaru/itamae-plugin-recipe-nginx_build