chef 0.8.16 → 0.9.0.a3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chef might be problematic. Click here for more details.

Files changed (185) hide show
  1. data/bin/shef +1 -0
  2. data/distro/common/man/man1/chef-server-webui.1 +106 -0
  3. data/distro/common/man/man1/chef-server.1 +0 -1
  4. data/distro/common/man/man1/chef-solr-indexer.1 +55 -0
  5. data/distro/common/man/man1/chef-solr.1 +55 -0
  6. data/distro/common/man/man8/chef-client.8 +4 -2
  7. data/distro/common/man/man8/chef-solo.8 +1 -2
  8. data/distro/common/man/man8/chef-solr-rebuild.8 +37 -0
  9. data/distro/common/man/man8/knife.8 +668 -266
  10. data/distro/common/man/man8/shef.8 +45 -0
  11. data/distro/common/markdown/README +3 -0
  12. data/distro/common/markdown/knife.mkd +520 -0
  13. data/distro/debian/etc/default/chef-client +4 -0
  14. data/distro/debian/etc/default/chef-server +6 -0
  15. data/distro/debian/etc/default/chef-server-webui +6 -0
  16. data/distro/debian/etc/default/chef-solr +4 -0
  17. data/distro/debian/etc/default/chef-solr-indexer +4 -0
  18. data/distro/debian/etc/init.d/chef-client +41 -41
  19. data/distro/debian/etc/init.d/chef-server +10 -10
  20. data/distro/debian/etc/init.d/chef-server-webui +121 -0
  21. data/distro/debian/etc/init.d/chef-solr +177 -0
  22. data/distro/debian/etc/init.d/chef-solr-indexer +176 -0
  23. data/distro/redhat/etc/init.d/chef-client +76 -48
  24. data/distro/redhat/etc/init.d/chef-server +85 -51
  25. data/distro/redhat/etc/init.d/chef-server-webui +85 -51
  26. data/distro/redhat/etc/init.d/chef-solr +77 -49
  27. data/distro/redhat/etc/init.d/chef-solr-indexer +77 -48
  28. data/distro/redhat/etc/logrotate.d/chef-client +8 -0
  29. data/distro/redhat/etc/logrotate.d/chef-server +8 -0
  30. data/distro/redhat/etc/logrotate.d/chef-server-webui +8 -0
  31. data/distro/redhat/etc/logrotate.d/chef-solr +8 -0
  32. data/distro/redhat/etc/logrotate.d/chef-solr-indexer +8 -0
  33. data/distro/redhat/etc/sysconfig/chef-client +9 -4
  34. data/distro/redhat/etc/sysconfig/chef-server +10 -6
  35. data/distro/redhat/etc/sysconfig/chef-server-webui +10 -6
  36. data/distro/redhat/etc/sysconfig/chef-solr +3 -4
  37. data/distro/redhat/etc/sysconfig/chef-solr-indexer +3 -3
  38. data/lib/chef.rb +16 -5
  39. data/lib/chef/application/knife.rb +2 -2
  40. data/lib/chef/application/solo.rb +1 -7
  41. data/lib/chef/cache/checksum.rb +12 -5
  42. data/lib/chef/cache/file_cache_by_checksum.rb +52 -0
  43. data/lib/chef/checksum.rb +115 -0
  44. data/lib/chef/client.rb +193 -185
  45. data/lib/chef/config.rb +9 -1
  46. data/lib/chef/cookbook/cookbook_collection.rb +43 -0
  47. data/lib/chef/cookbook/file_system_file_vendor.rb +53 -0
  48. data/lib/chef/cookbook/file_vendor.rb +47 -0
  49. data/lib/chef/cookbook/metadata.rb +34 -35
  50. data/lib/chef/cookbook/metadata/version.rb +1 -1
  51. data/lib/chef/cookbook_loader.rb +70 -45
  52. data/lib/chef/cookbook_version.rb +760 -0
  53. data/lib/chef/couchdb.rb +8 -5
  54. data/lib/chef/data_bag_item.rb +5 -5
  55. data/lib/chef/exceptions.rb +10 -0
  56. data/lib/chef/file_access_control.rb +134 -0
  57. data/lib/chef/handler.rb +62 -0
  58. data/lib/chef/handler/json_file.rb +47 -0
  59. data/lib/chef/knife.rb +14 -2
  60. data/lib/chef/knife/bootstrap.rb +126 -0
  61. data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
  62. data/lib/chef/knife/cookbook_delete.rb +4 -4
  63. data/lib/chef/knife/cookbook_download.rb +57 -26
  64. data/lib/chef/knife/cookbook_metadata.rb +2 -2
  65. data/lib/chef/knife/cookbook_show.rb +30 -11
  66. data/lib/chef/knife/cookbook_upload.rb +113 -86
  67. data/lib/chef/knife/ec2_server_create.rb +146 -0
  68. data/lib/chef/knife/ec2_server_delete.rb +84 -0
  69. data/lib/chef/knife/ec2_server_list.rb +82 -0
  70. data/lib/chef/knife/status.rb +51 -0
  71. data/lib/chef/mixin/language_include_attribute.rb +16 -11
  72. data/lib/chef/mixin/language_include_recipe.rb +15 -16
  73. data/lib/chef/mixin/recipe_definition_dsl_core.rb +17 -20
  74. data/lib/chef/mixin/shell_out.rb +38 -0
  75. data/lib/chef/mixins.rb +1 -1
  76. data/lib/chef/node.rb +190 -63
  77. data/lib/chef/node/attribute.rb +92 -78
  78. data/lib/chef/platform.rb +24 -4
  79. data/lib/chef/provider.rb +28 -10
  80. data/lib/chef/provider/breakpoint.rb +2 -2
  81. data/lib/chef/provider/cookbook_file.rb +96 -0
  82. data/lib/chef/provider/cron.rb +2 -2
  83. data/lib/chef/provider/deploy.rb +12 -10
  84. data/lib/chef/provider/env.rb +152 -0
  85. data/lib/chef/provider/env/windows.rb +75 -0
  86. data/lib/chef/provider/file.rb +10 -14
  87. data/lib/chef/provider/group.rb +15 -2
  88. data/lib/chef/provider/group/dscl.rb +17 -25
  89. data/lib/chef/provider/group/gpasswd.rb +6 -3
  90. data/lib/chef/provider/group/pw.rb +3 -7
  91. data/lib/chef/provider/group/windows.rb +79 -0
  92. data/lib/chef/provider/link.rb +4 -5
  93. data/lib/chef/provider/mdadm.rb +25 -18
  94. data/lib/chef/provider/mount/mount.rb +28 -27
  95. data/lib/chef/provider/package.rb +35 -35
  96. data/lib/chef/provider/package/dpkg.rb +13 -10
  97. data/lib/chef/provider/package/easy_install.rb +6 -6
  98. data/lib/chef/provider/package/freebsd.rb +17 -51
  99. data/lib/chef/provider/package/rpm.rb +1 -1
  100. data/lib/chef/provider/package/rubygems.rb +391 -74
  101. data/lib/chef/provider/package/yum.rb +2 -2
  102. data/lib/chef/provider/package/zypper.rb +2 -1
  103. data/lib/chef/provider/remote_directory.rb +60 -83
  104. data/lib/chef/provider/remote_file.rb +17 -66
  105. data/lib/chef/provider/script.rb +20 -9
  106. data/lib/chef/provider/service.rb +23 -30
  107. data/lib/chef/provider/service/arch.rb +3 -3
  108. data/lib/chef/provider/service/debian.rb +22 -17
  109. data/lib/chef/provider/service/freebsd.rb +4 -4
  110. data/lib/chef/provider/service/init.rb +2 -2
  111. data/lib/chef/provider/service/redhat.rb +14 -16
  112. data/lib/chef/provider/service/simple.rb +7 -3
  113. data/lib/chef/provider/service/solaris.rb +85 -0
  114. data/lib/chef/provider/service/upstart.rb +12 -7
  115. data/lib/chef/provider/service/windows.rb +2 -2
  116. data/lib/chef/provider/template.rb +133 -118
  117. data/lib/chef/provider/user.rb +34 -17
  118. data/lib/chef/provider/user/dscl.rb +117 -114
  119. data/lib/chef/provider/user/windows.rb +124 -0
  120. data/lib/chef/providers.rb +7 -0
  121. data/lib/chef/recipe.rb +39 -20
  122. data/lib/chef/resource.rb +47 -52
  123. data/lib/chef/resource/apt_package.rb +4 -4
  124. data/lib/chef/resource/bash.rb +4 -4
  125. data/lib/chef/resource/cookbook_file.rb +45 -0
  126. data/lib/chef/resource/cron.rb +3 -3
  127. data/lib/chef/resource/csh.rb +4 -4
  128. data/lib/chef/resource/deploy.rb +3 -3
  129. data/lib/chef/resource/directory.rb +4 -4
  130. data/lib/chef/resource/dpkg_package.rb +4 -4
  131. data/lib/chef/resource/easy_install_package.rb +3 -3
  132. data/lib/chef/resource/env.rb +58 -0
  133. data/lib/chef/resource/erl_call.rb +3 -3
  134. data/lib/chef/resource/execute.rb +3 -3
  135. data/lib/chef/resource/file.rb +3 -3
  136. data/lib/chef/resource/freebsd_package.rb +3 -3
  137. data/lib/chef/resource/gem_package.rb +17 -9
  138. data/lib/chef/resource/git.rb +3 -3
  139. data/lib/chef/resource/group.rb +3 -3
  140. data/lib/chef/resource/http_request.rb +4 -4
  141. data/lib/chef/resource/ifconfig.rb +3 -3
  142. data/lib/chef/resource/link.rb +3 -3
  143. data/lib/chef/resource/log.rb +2 -2
  144. data/lib/chef/resource/macports_package.rb +2 -2
  145. data/lib/chef/resource/mdadm.rb +3 -3
  146. data/lib/chef/resource/mount.rb +2 -2
  147. data/lib/chef/resource/package.rb +4 -4
  148. data/lib/chef/resource/pacman_package.rb +4 -4
  149. data/lib/chef/resource/perl.rb +4 -4
  150. data/lib/chef/resource/portage_package.rb +4 -4
  151. data/lib/chef/resource/python.rb +4 -4
  152. data/lib/chef/resource/remote_directory.rb +3 -3
  153. data/lib/chef/resource/remote_file.rb +26 -3
  154. data/lib/chef/resource/route.rb +3 -3
  155. data/lib/chef/resource/ruby.rb +3 -3
  156. data/lib/chef/resource/ruby_block.rb +3 -2
  157. data/lib/chef/resource/scm.rb +7 -5
  158. data/lib/chef/resource/script.rb +4 -4
  159. data/lib/chef/resource/service.rb +3 -3
  160. data/lib/chef/resource/subversion.rb +4 -2
  161. data/lib/chef/resource/template.rb +3 -3
  162. data/lib/chef/resource/user.rb +3 -3
  163. data/lib/chef/resource/yum_package.rb +3 -3
  164. data/lib/chef/resource_collection.rb +9 -5
  165. data/lib/chef/resources.rb +2 -0
  166. data/lib/chef/rest.rb +4 -0
  167. data/lib/chef/role.rb +2 -0
  168. data/lib/chef/run_context.rb +108 -0
  169. data/lib/chef/run_list.rb +75 -98
  170. data/lib/chef/run_list/run_list_expansion.rb +156 -0
  171. data/lib/chef/run_list/run_list_item.rb +71 -0
  172. data/lib/chef/runner.rb +58 -61
  173. data/lib/chef/sandbox.rb +147 -0
  174. data/lib/chef/shef.rb +4 -3
  175. data/lib/chef/shef/ext.rb +12 -4
  176. data/lib/chef/shef/shef_session.rb +27 -23
  177. data/lib/chef/shell_out.rb +375 -0
  178. data/lib/chef/util/windows.rb +56 -0
  179. data/lib/chef/util/windows/net_group.rb +101 -0
  180. data/lib/chef/util/windows/net_user.rb +198 -0
  181. data/lib/chef/version.rb +20 -0
  182. metadata +112 -22
  183. data/lib/chef/compile.rb +0 -158
  184. data/lib/chef/cookbook.rb +0 -201
  185. data/lib/chef/mixin/generate_url.rb +0 -58
@@ -0,0 +1,4 @@
1
+ LOGFILE=/var/log/chef/client.log
2
+ CONFIG=/etc/chef/client.rb
3
+ INTERVAL=1800
4
+ SPLAY=20
@@ -0,0 +1,6 @@
1
+ LOGFILE=/var/log/chef/server.log
2
+ CONFIG=/etc/chef/server.rb
3
+ ADAPTER=thin
4
+ PORT=4000
5
+ USER=chef
6
+ GROUP=chef
@@ -0,0 +1,6 @@
1
+ LOGFILE=/var/log/chef/server-webui.log
2
+ CONFIG=/etc/chef/webui.rb
3
+ ADAPTER=thin
4
+ PORT=4040
5
+ USER=chef
6
+ GROUP=chef
@@ -0,0 +1,4 @@
1
+ LOGFILE=/var/log/chef/solr.log
2
+ CONFIG=/etc/chef/solr.rb
3
+ USER=chef
4
+ GROUP=chef
@@ -0,0 +1,4 @@
1
+ LOGFILE=/var/log/chef/solr-indexer.log
2
+ CONFIG=/etc/chef/solr.rb
3
+ USER=chef
4
+ GROUP=chef
@@ -1,86 +1,86 @@
1
1
  #! /bin/sh
2
2
  ### BEGIN INIT INFO
3
3
  # Provides: chef-client
4
- # Required-Start: $network
5
- # Required-Stop: $network
4
+ # Required-Start: $remote_fs $network
5
+ # Required-Stop: $remote_fs $network
6
6
  # Default-Start: 2 3 4 5
7
7
  # Default-Stop: 0 1 6
8
8
  # Short-Description: Start a chef-client.
9
9
  ### END INIT INFO
10
10
  #
11
- # Copyright (c) 2009 Joshua Timberman, <joshua@opscode.com>
11
+ # Copyright (c) 2009-2010 Opscode, Inc, <legal@opscode.com>
12
12
  #
13
13
  # chef-client Startup script for chef-client.
14
- # chkconfig: - 98 02
14
+ # chkconfig: - 99 02
15
15
  # description: starts up chef-client in daemon mode.
16
16
 
17
17
  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18
18
  DAEMON=/usr/bin/chef-client
19
19
  NAME=chef-client
20
20
  DESC=chef-client
21
- LOGDIR=/var/log/chef
22
- CONFIG=/etc/chef/client.rb
23
21
  PIDFILE=/var/run/chef/client.pid
24
22
 
25
23
  test -x $DAEMON || exit 0
26
24
 
27
25
  . /lib/lsb/init-functions
28
26
 
27
+ [ -r /etc/default/$NAME ] && . /etc/default/$NAME
28
+
29
29
  if [ ! -d /var/run/chef ]; then
30
30
  mkdir /var/run/chef
31
31
  fi
32
32
 
33
- DAEMON_OPTS="-d -c $CONFIG -i 1800 -s 20"
33
+ DAEMON_OPTS="-L $LOGFILE -d -c $CONFIG -i $INTERVAL -s $SPLAY"
34
34
 
35
- running_pid() {
35
+ running_pid() {
36
36
  pid=$1
37
- name=$2
38
- [ -z "$pid" ] && return 1
39
- [ ! -d /proc/$pid ] && return 1
37
+ name=$2
38
+ [ -z "$pid" ] && return 1
39
+ [ ! -d /proc/$pid ] && return 1
40
40
  cmd=`awk '/Name:/ {print $2}' /proc/$pid/status`
41
- [ "$cmd" != "$name" ] && return 1
42
- return 0
43
- }
41
+ [ "$cmd" != "$name" ] && return 1
42
+ return 0
43
+ }
44
44
 
45
- running() {
45
+ running() {
46
46
  [ ! -f "$PIDFILE" ] && return 1
47
47
  pid=`cat $PIDFILE`
48
- running_pid $pid $NAME || return 1
48
+ running_pid $pid $NAME || return 1
49
49
  return 0
50
- }
50
+ }
51
51
 
52
- start_server() {
53
- if [ -z "$DAEMONUSER" ] ; then
54
- start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
52
+ start_server() {
53
+ if [ -z "$DAEMONUSER" ] ; then
54
+ start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
55
55
  errcode=$?
56
56
  else
57
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
58
- --chuid $DAEMONUSER \
59
- --exec $DAEMON -- $DAEMON_OPTS
60
- errcode=$?
61
- fi
62
- return $errcode
63
- }
57
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
58
+ --chuid $DAEMONUSER \
59
+ --exec $DAEMON -- $DAEMON_OPTS
60
+ errcode=$?
61
+ fi
62
+ return $errcode
63
+ }
64
64
 
65
- stop_server() {
66
- if [ -z "$DAEMONUSER" ] ; then
67
- killproc -p $PIDFILE $DAEMON
65
+ stop_server() {
66
+ if [ -z "$DAEMONUSER" ] ; then
67
+ killproc -p $PIDFILE $DAEMON
68
68
  errcode=$?
69
69
  else
70
- start-stop-daemon --stop --quiet --pidfile $PIDFILE \
71
- --user $DAEMONUSER \
70
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
71
+ --user $DAEMONUSER \
72
72
  --exec $DAEMON
73
- errcode=$?
74
- fi
75
- return $errcode
76
- }
73
+ errcode=$?
74
+ fi
75
+ return $errcode
76
+ }
77
77
 
78
- reload_server() {
79
- [ ! -f "$PIDFILE" ] && return 1
80
- pid=pidofproc $PIDFILE # This is the daemon's pid
78
+ reload_server() {
79
+ [ ! -f "$PIDFILE" ] && return 1
80
+ pid=pidofproc $PIDFILE # This is the daemon's pid
81
81
  /bin/kill -1 $pid
82
82
  return $?
83
- }
83
+ }
84
84
 
85
85
  force_stop() {
86
86
  [ ! -e "$PIDFILE" ] && return
@@ -108,7 +108,7 @@ case "$1" in
108
108
  exit 0
109
109
  fi
110
110
  if start_server ; then
111
- [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
111
+ [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
112
112
  if running ; then
113
113
  log_end_msg 0
114
114
  else
@@ -1,45 +1,45 @@
1
1
  #! /bin/sh
2
2
  ### BEGIN INIT INFO
3
3
  # Provides: chef-server
4
- # Required-Start: $network
5
- # Required-Stop: $network
4
+ # Required-Start: $remote_fs $network rabbitmq-server couchdb
5
+ # Required-Stop: $remote_fs $network rabbitmq-server couchdb
6
6
  # Default-Start: 2 3 4 5
7
7
  # Default-Stop: 0 1 6
8
8
  # Short-Description: Start a chef-server.
9
9
  ### END INIT INFO
10
10
  #
11
- # Copyright (c) 2009 Joshua Timberman, <joshua@opscode.com>
11
+ # Copyright (c) 2009-2010 Opscode, Inc <legal@opscode.com>
12
12
  #
13
13
  # chef-server Startup script for chef-server.
14
- # chkconfig: - 98 02
14
+ # chkconfig: - 90 02
15
15
  # description: starts up chef-server webui.
16
16
 
17
17
  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18
18
  DAEMON=/usr/bin/chef-server
19
19
  PIDFILE=/var/run/chef/server.%s.pid
20
20
  MAINPID=/var/run/chef/server.main.pid
21
- LOGFILE=/var/log/chef/merb.%s.log
22
- MASTER=master
23
21
  NAME=chef-server
24
22
  DESC=chef-server
25
- DAEMON_OPTS="-d -c2 -P $PIDFILE -L $LOGFILE"
26
23
 
27
24
  test -x $DAEMON || exit 0
28
25
 
29
26
  . /lib/lsb/init-functions
30
27
 
28
+ [ -r /etc/default/$NAME ] && . /etc/default/$NAME
29
+
31
30
  if [ ! -d /var/run/chef ]; then
32
31
  mkdir /var/run/chef
32
+ chown $USER:$GROUP /var/run/chef
33
33
  fi
34
34
 
35
+ DAEMON_OPTS="-p $PORT -e production -d -a $ADAPTER -P $PIDFILE -L $LOGFILE -C $CONFIG -u $USER -G $GROUP"
36
+
35
37
  running() {
36
38
  [ ! -f "$MAINPID" ] && return 1
37
39
  pid=`cat $MAINPID`
38
- name=$MASTER
39
40
  [ -z "$pid" ] && return 1
40
41
  [ ! -d /proc/$pid ] && return 1
41
- cmd=`cat /proc/$pid/cmdline | tr '\000' '\n' | head -1 | awk -F:\ '{print $3}'`
42
- [ "$cmd" != "$name" ] && return 1
42
+ (ps -fp $pid | egrep -q "merb.*(merb : master|worker.*$PORT)") || return 1
43
43
  return 0
44
44
  }
45
45
 
@@ -0,0 +1,121 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: chef-server-webui
4
+ # Required-Start: $remote_fs $network chef-server
5
+ # Required-Stop: $remote_fs $network chef-server
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Start a chef-server-webui
9
+ ### END INIT INFO
10
+ #
11
+ # Copyright (c) 2009-2010 Opscode, Inc <legal@opscode.com>
12
+ #
13
+ # chef-server-webui Startup script for chef-server-webui.
14
+ # chkconfig: - 95 02
15
+ # description: starts up chef-server webui.
16
+
17
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18
+ DAEMON=/usr/bin/chef-server-webui
19
+ PIDFILE=/var/run/chef/server-webui.%s.pid
20
+ MAINPID=/var/run/chef/server-webui.main.pid
21
+ NAME=chef-server-webui
22
+ DESC=chef-server-webui
23
+
24
+ test -x $DAEMON || exit 0
25
+
26
+ . /lib/lsb/init-functions
27
+
28
+ [ -r /etc/default/$NAME ] && . /etc/default/$NAME
29
+
30
+ if [ ! -d /var/run/chef ]; then
31
+ mkdir /var/run/chef
32
+ chown $USER:$GROUP /var/run/chef
33
+ fi
34
+
35
+ DAEMON_OPTS="-p $PORT -e production -d -a $ADAPTER -P $PIDFILE -L $LOGFILE -C $CONFIG -u $USER -G $GROUP"
36
+
37
+ running() {
38
+ [ ! -f "$MAINPID" ] && return 1
39
+ pid=`cat $MAINPID`
40
+ name=$WORKER
41
+ [ -z "$pid" ] && return 1
42
+ [ ! -d /proc/$pid ] && return 1
43
+ (ps -fp $pid | egrep -q "merb.*(merb : master|worker.*$PORT)") || return 1
44
+ return 0
45
+ }
46
+
47
+ start_server() {
48
+ $DAEMON $DAEMON_OPTS
49
+ errcode=$?
50
+ return $errcode
51
+ }
52
+
53
+ stop_server() {
54
+ $DAEMON -K all -P $PIDFILE
55
+ errcode=$?
56
+ return $errcode
57
+ }
58
+
59
+ reload_server() {
60
+ stop_server
61
+ start_server
62
+ }
63
+
64
+ case "$1" in
65
+ start)
66
+ log_daemon_msg "Starting $DESC "
67
+ if running ; then
68
+ log_progress_msg "apparently already running"
69
+ log_end_msg 0
70
+ exit 0
71
+ fi
72
+ if start_server ; then
73
+ sleep 1
74
+ if running ; then
75
+ log_end_msg 0
76
+ else
77
+ log_end_msg 1
78
+ fi
79
+ else
80
+ log_end_msg 1
81
+ fi
82
+ ;;
83
+ stop)
84
+ log_daemon_msg "Stopping $DESC"
85
+ if running ; then
86
+ errcode=0
87
+ stop_server || errcode=$?
88
+ log_end_msg $errcode
89
+ else
90
+ log_progress_msg "apparently not running"
91
+ log_end_msg 0
92
+ exit 0
93
+ fi
94
+ ;;
95
+ restart|force-reload)
96
+ log_daemon_msg "Restarting $DESC"
97
+ errcode=0
98
+ reload_server
99
+ running && errcode=$?
100
+ log_end_msg $errcode
101
+ ;;
102
+ status)
103
+ log_daemon_msg "Checking status of $DESC"
104
+ if running ; then
105
+ log_progress_msg "running"
106
+ log_end_msg 0
107
+ else
108
+ log_progress_msg "apparently not running"
109
+ log_end_msg 1
110
+ exit 3
111
+ fi
112
+ ;;
113
+ *)
114
+ N=/etc/init.d/$NAME
115
+ echo "Usage: $N {start|stop|restart|status}" >&2
116
+ exit 1
117
+ ;;
118
+ esac
119
+
120
+ exit 0
121
+
@@ -0,0 +1,177 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: chef-solr
4
+ # Required-Start: $remote_fs $network
5
+ # Required-Stop: $remote_fs $network
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Start a chef-solr.
9
+ ### END INIT INFO
10
+ #
11
+ # Copyright (c) 2009-2010 Opscode, Inc <legal@opscode.com>
12
+ #
13
+ # chef-solr Startup script for chef-solr.
14
+ # chkconfig: - 84 02
15
+ # description: starts up chef-solr in daemon mode.
16
+
17
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18
+ DAEMON=/usr/sbin/chef-solr
19
+ DAEMON_NAME=java
20
+ NAME=chef-solr
21
+ DESC=chef-solr
22
+ PIDFILE=/var/run/chef/solr.pid
23
+
24
+ test -x $DAEMON || exit 0
25
+
26
+ . /lib/lsb/init-functions
27
+
28
+ [ -r /etc/default/$NAME ] && . /etc/default/$NAME
29
+
30
+ if [ ! -d /var/run/chef ]; then
31
+ mkdir /var/run/chef
32
+ chown $USER:$GROUP /var/run/chef
33
+ fi
34
+
35
+ DAEMON_OPTS="-d -P $PIDFILE -c $CONFIG -L $LOGFILE -u $USER -g $GROUP"
36
+
37
+ running_pid() {
38
+ pid=$1
39
+ name=$2
40
+ [ -z "$pid" ] && return 1
41
+ [ ! -d /proc/$pid ] && return 1
42
+ cmd=`cat /proc/$pid/cmdline | tr '\000' '\n' | head -1`
43
+ [ "$cmd" != "$name" ] && return 1
44
+ return 0
45
+ }
46
+
47
+ running() {
48
+ [ ! -f "$PIDFILE" ] && return 1
49
+ pid=`cat $PIDFILE`
50
+ running_pid $pid $DAEMON_NAME || return 1
51
+ return 0
52
+ }
53
+
54
+ start_server() {
55
+ if [ -z "$DAEMONUSER" ] ; then
56
+ start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
57
+ errcode=$?
58
+ else
59
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
60
+ --chuid $DAEMONUSER \
61
+ --exec $DAEMON -- $DAEMON_OPTS
62
+ errcode=$?
63
+ fi
64
+ return $errcode
65
+ }
66
+
67
+ stop_server() {
68
+ if [ -z "$DAEMONUSER" ] ; then
69
+ killproc -p $PIDFILE $DAEMON
70
+ errcode=$?
71
+ else
72
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
73
+ --user $DAEMONUSER \
74
+ --exec $DAEMON
75
+ errcode=$?
76
+ fi
77
+ return $errcode
78
+ }
79
+
80
+ reload_server() {
81
+ [ ! -f "$PIDFILE" ] && return 1
82
+ pid=pidofproc $PIDFILE # This is the daemon's pid
83
+ /bin/kill -1 $pid
84
+ return $?
85
+ }
86
+
87
+ force_stop() {
88
+ [ ! -e "$PIDFILE" ] && return
89
+ if running ; then
90
+ /bin/kill -15 $pid
91
+ sleep "$DIETIME"s
92
+ if running ; then
93
+ /bin/kill -9 $pid
94
+ sleep "$DIETIME"s
95
+ if running ; then
96
+ echo "Cannot kill $NAME (pid=$pid)!"
97
+ exit 1
98
+ fi
99
+ fi
100
+ fi
101
+ rm -f $PIDFILE
102
+ }
103
+
104
+ case "$1" in
105
+ start)
106
+ log_daemon_msg "Starting $DESC " "$NAME"
107
+ if running ; then
108
+ log_progress_msg "apparently already running"
109
+ log_end_msg 0
110
+ exit 3
111
+ fi
112
+ if start_server ; then
113
+ [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
114
+ if running ; then
115
+ log_end_msg 0
116
+ else
117
+ log_end_msg 1
118
+ fi
119
+ else
120
+ log_end_msg 1
121
+ fi
122
+ ;;
123
+ stop)
124
+ log_daemon_msg "Stopping $DESC" "$NAME"
125
+ if running ; then
126
+ errcode=0
127
+ stop_server || errcode=$?
128
+ log_end_msg $errcode
129
+ else
130
+ log_progress_msg "apparently not running"
131
+ log_end_msg 0
132
+ exit 0
133
+ fi
134
+ ;;
135
+ force-stop)
136
+ $0 stop
137
+ if running; then
138
+ log_daemon_msg "Stopping (force) $DESC" "$NAME"
139
+ errcode=0
140
+ force_stop || errcode=$?
141
+ log_end_msg $errcode
142
+ fi
143
+ ;;
144
+ restart|force-reload)
145
+ log_daemon_msg "Restarting $DESC" "$NAME"
146
+ errcode=0
147
+ stop_server || errcode=$?
148
+ [ -n "$DIETIME" ] && sleep $DIETIME
149
+ start_server || errcode=$?
150
+ [ -n "$STARTTIME" ] && sleep $STARTTIME
151
+ running || errcode=$?
152
+ log_end_msg $errcode
153
+ ;;
154
+ status)
155
+ log_daemon_msg "Checking status of $DESC" "$NAME"
156
+ if running ; then
157
+ log_progress_msg "running"
158
+ log_end_msg 0
159
+ else
160
+ log_progress_msg "apparently not running"
161
+ log_end_msg 1
162
+ exit 1
163
+ fi
164
+ ;;
165
+ reload)
166
+ log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
167
+ log_warning_msg "cannot re-read the config file (use restart)."
168
+ ;;
169
+ *)
170
+ N=/etc/init.d/$NAME
171
+ echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
172
+ exit 1
173
+ ;;
174
+ esac
175
+
176
+ exit 0
177
+