runa-chef 0.8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.rdoc +136 -0
- data/bin/chef-client +26 -0
- data/bin/chef-solo +26 -0
- data/bin/knife +27 -0
- data/bin/shef +45 -0
- data/distro/README +2 -0
- data/distro/common/man/man1/chef-indexer.1 +42 -0
- data/distro/common/man/man1/chef-server.1 +108 -0
- data/distro/common/man/man8/chef-client.8 +61 -0
- data/distro/common/man/man8/chef-solo.8 +58 -0
- data/distro/common/man/man8/knife.8 +359 -0
- data/distro/debian/etc/init.d/chef-client +175 -0
- data/distro/debian/etc/init.d/chef-indexer +175 -0
- data/distro/debian/etc/init.d/chef-server +120 -0
- data/distro/redhat/etc/init.d/chef-client +78 -0
- data/distro/redhat/etc/init.d/chef-indexer +76 -0
- data/distro/redhat/etc/init.d/chef-server +78 -0
- data/distro/redhat/etc/sysconfig/chef-client +10 -0
- data/distro/redhat/etc/sysconfig/chef-indexer +8 -0
- data/distro/redhat/etc/sysconfig/chef-server +10 -0
- data/distro/suse/etc/init.d/chef-client +121 -0
- data/lib/chef.rb +49 -0
- data/lib/chef/api_client.rb +269 -0
- data/lib/chef/application.rb +98 -0
- data/lib/chef/application/agent.rb +18 -0
- data/lib/chef/application/client.rb +214 -0
- data/lib/chef/application/knife.rb +138 -0
- data/lib/chef/application/server.rb +19 -0
- data/lib/chef/application/solo.rb +214 -0
- data/lib/chef/cache.rb +61 -0
- data/lib/chef/cache/checksum.rb +70 -0
- data/lib/chef/certificate.rb +154 -0
- data/lib/chef/client.rb +323 -0
- data/lib/chef/compile.rb +158 -0
- data/lib/chef/config.rb +195 -0
- data/lib/chef/cookbook.rb +198 -0
- data/lib/chef/cookbook/metadata.rb +487 -0
- data/lib/chef/cookbook/metadata/version.rb +87 -0
- data/lib/chef/cookbook_loader.rb +180 -0
- data/lib/chef/couchdb.rb +273 -0
- data/lib/chef/daemon.rb +170 -0
- data/lib/chef/data_bag.rb +216 -0
- data/lib/chef/data_bag_item.rb +227 -0
- data/lib/chef/exceptions.rb +39 -0
- data/lib/chef/file_cache.rb +205 -0
- data/lib/chef/knife.rb +300 -0
- data/lib/chef/knife/client_bulk_delete.rb +41 -0
- data/lib/chef/knife/client_create.rb +55 -0
- data/lib/chef/knife/client_delete.rb +37 -0
- data/lib/chef/knife/client_edit.rb +37 -0
- data/lib/chef/knife/client_list.rb +40 -0
- data/lib/chef/knife/client_reregister.rb +48 -0
- data/lib/chef/knife/client_show.rb +42 -0
- data/lib/chef/knife/configure.rb +84 -0
- data/lib/chef/knife/cookbook_bulk_delete.rb +47 -0
- data/lib/chef/knife/cookbook_delete.rb +41 -0
- data/lib/chef/knife/cookbook_download.rb +57 -0
- data/lib/chef/knife/cookbook_list.rb +41 -0
- data/lib/chef/knife/cookbook_metadata.rb +87 -0
- data/lib/chef/knife/cookbook_show.rb +75 -0
- data/lib/chef/knife/cookbook_upload.rb +173 -0
- data/lib/chef/knife/data_bag_create.rb +43 -0
- data/lib/chef/knife/data_bag_delete.rb +43 -0
- data/lib/chef/knife/data_bag_edit.rb +49 -0
- data/lib/chef/knife/data_bag_list.rb +42 -0
- data/lib/chef/knife/data_bag_show.rb +40 -0
- data/lib/chef/knife/ec2_instance_data.rb +46 -0
- data/lib/chef/knife/node_bulk_delete.rb +44 -0
- data/lib/chef/knife/node_create.rb +39 -0
- data/lib/chef/knife/node_delete.rb +36 -0
- data/lib/chef/knife/node_edit.rb +36 -0
- data/lib/chef/knife/node_from_file.rb +42 -0
- data/lib/chef/knife/node_list.rb +41 -0
- data/lib/chef/knife/node_run_list_add.rb +64 -0
- data/lib/chef/knife/node_run_list_remove.rb +45 -0
- data/lib/chef/knife/node_show.rb +46 -0
- data/lib/chef/knife/role_bulk_delete.rb +45 -0
- data/lib/chef/knife/role_create.rb +44 -0
- data/lib/chef/knife/role_delete.rb +36 -0
- data/lib/chef/knife/role_edit.rb +37 -0
- data/lib/chef/knife/role_from_file.rb +46 -0
- data/lib/chef/knife/role_list.rb +40 -0
- data/lib/chef/knife/role_show.rb +43 -0
- data/lib/chef/knife/search.rb +94 -0
- data/lib/chef/log.rb +39 -0
- data/lib/chef/mixin/check_helper.rb +31 -0
- data/lib/chef/mixin/checksum.rb +32 -0
- data/lib/chef/mixin/command.rb +390 -0
- data/lib/chef/mixin/convert_to_class_name.rb +57 -0
- data/lib/chef/mixin/create_path.rb +56 -0
- data/lib/chef/mixin/deep_merge.rb +33 -0
- data/lib/chef/mixin/find_preferred_file.rb +92 -0
- data/lib/chef/mixin/from_file.rb +50 -0
- data/lib/chef/mixin/generate_url.rb +58 -0
- data/lib/chef/mixin/language.rb +107 -0
- data/lib/chef/mixin/language_include_attribute.rb +56 -0
- data/lib/chef/mixin/language_include_recipe.rb +53 -0
- data/lib/chef/mixin/params_validate.rb +197 -0
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +79 -0
- data/lib/chef/mixin/template.rb +94 -0
- data/lib/chef/nanite.rb +100 -0
- data/lib/chef/node.rb +463 -0
- data/lib/chef/node/attribute.rb +412 -0
- data/lib/chef/openid_registration.rb +181 -0
- data/lib/chef/platform.rb +268 -0
- data/lib/chef/provider.rb +101 -0
- data/lib/chef/provider/breakpoint.rb +36 -0
- data/lib/chef/provider/cron.rb +184 -0
- data/lib/chef/provider/deploy.rb +314 -0
- data/lib/chef/provider/deploy/revision.rb +70 -0
- data/lib/chef/provider/deploy/timestamped.rb +33 -0
- data/lib/chef/provider/directory.rb +72 -0
- data/lib/chef/provider/erl_call.rb +72 -0
- data/lib/chef/provider/execute.rb +58 -0
- data/lib/chef/provider/file.rb +195 -0
- data/lib/chef/provider/git.rb +203 -0
- data/lib/chef/provider/group.rb +120 -0
- data/lib/chef/provider/group/dscl.rb +128 -0
- data/lib/chef/provider/group/gpasswd.rb +50 -0
- data/lib/chef/provider/group/groupadd.rb +78 -0
- data/lib/chef/provider/group/pw.rb +88 -0
- data/lib/chef/provider/group/usermod.rb +57 -0
- data/lib/chef/provider/http_request.rb +106 -0
- data/lib/chef/provider/ifconfig.rb +131 -0
- data/lib/chef/provider/link.rb +157 -0
- data/lib/chef/provider/mdadm.rb +88 -0
- data/lib/chef/provider/mount.rb +117 -0
- data/lib/chef/provider/mount/mount.rb +208 -0
- data/lib/chef/provider/package.rb +160 -0
- data/lib/chef/provider/package/apt.rb +110 -0
- data/lib/chef/provider/package/dpkg.rb +109 -0
- data/lib/chef/provider/package/easy_install.rb +106 -0
- data/lib/chef/provider/package/freebsd.rb +153 -0
- data/lib/chef/provider/package/macports.rb +105 -0
- data/lib/chef/provider/package/portage.rb +124 -0
- data/lib/chef/provider/package/rpm.rb +99 -0
- data/lib/chef/provider/package/rubygems.rb +136 -0
- data/lib/chef/provider/package/yum-dump.py +125 -0
- data/lib/chef/provider/package/yum.rb +175 -0
- data/lib/chef/provider/package/zypper.rb +132 -0
- data/lib/chef/provider/remote_directory.rb +126 -0
- data/lib/chef/provider/remote_file.rb +141 -0
- data/lib/chef/provider/route.rb +118 -0
- data/lib/chef/provider/ruby_block.rb +33 -0
- data/lib/chef/provider/script.rb +42 -0
- data/lib/chef/provider/service.rb +135 -0
- data/lib/chef/provider/service/debian.rb +64 -0
- data/lib/chef/provider/service/freebsd.rb +156 -0
- data/lib/chef/provider/service/gentoo.rb +54 -0
- data/lib/chef/provider/service/init.rb +71 -0
- data/lib/chef/provider/service/redhat.rb +62 -0
- data/lib/chef/provider/service/simple.rb +114 -0
- data/lib/chef/provider/subversion.rb +156 -0
- data/lib/chef/provider/template.rb +175 -0
- data/lib/chef/provider/user.rb +170 -0
- data/lib/chef/provider/user/dscl.rb +280 -0
- data/lib/chef/provider/user/pw.rb +113 -0
- data/lib/chef/provider/user/useradd.rb +108 -0
- data/lib/chef/recipe.rb +105 -0
- data/lib/chef/resource.rb +380 -0
- data/lib/chef/resource/apt_package.rb +34 -0
- data/lib/chef/resource/bash.rb +33 -0
- data/lib/chef/resource/breakpoint.rb +35 -0
- data/lib/chef/resource/cron.rb +179 -0
- data/lib/chef/resource/csh.rb +33 -0
- data/lib/chef/resource/deploy.rb +359 -0
- data/lib/chef/resource/deploy_revision.rb +35 -0
- data/lib/chef/resource/directory.rb +76 -0
- data/lib/chef/resource/dpkg_package.rb +34 -0
- data/lib/chef/resource/easy_install_package.rb +41 -0
- data/lib/chef/resource/erl_call.rb +83 -0
- data/lib/chef/resource/execute.rb +127 -0
- data/lib/chef/resource/file.rb +84 -0
- data/lib/chef/resource/gem_package.rb +41 -0
- data/lib/chef/resource/git.rb +36 -0
- data/lib/chef/resource/group.rb +70 -0
- data/lib/chef/resource/http_request.rb +52 -0
- data/lib/chef/resource/ifconfig.rb +134 -0
- data/lib/chef/resource/link.rb +78 -0
- data/lib/chef/resource/macports_package.rb +29 -0
- data/lib/chef/resource/mdadm.rb +82 -0
- data/lib/chef/resource/mount.rb +135 -0
- data/lib/chef/resource/package.rb +80 -0
- data/lib/chef/resource/perl.rb +33 -0
- data/lib/chef/resource/portage_package.rb +33 -0
- data/lib/chef/resource/python.rb +33 -0
- data/lib/chef/resource/remote_directory.rb +91 -0
- data/lib/chef/resource/remote_file.rb +60 -0
- data/lib/chef/resource/route.rb +135 -0
- data/lib/chef/resource/ruby.rb +33 -0
- data/lib/chef/resource/ruby_block.rb +39 -0
- data/lib/chef/resource/scm.rb +137 -0
- data/lib/chef/resource/script.rb +51 -0
- data/lib/chef/resource/service.rb +134 -0
- data/lib/chef/resource/subversion.rb +34 -0
- data/lib/chef/resource/template.rb +60 -0
- data/lib/chef/resource/timestamped_deploy.rb +31 -0
- data/lib/chef/resource/user.rb +101 -0
- data/lib/chef/resource_collection.rb +212 -0
- data/lib/chef/resource_collection/stepable_iterator.rb +124 -0
- data/lib/chef/resource_definition.rb +67 -0
- data/lib/chef/rest.rb +298 -0
- data/lib/chef/role.rb +301 -0
- data/lib/chef/run_list.rb +164 -0
- data/lib/chef/runner.rb +130 -0
- data/lib/chef/search/query.rb +71 -0
- data/lib/chef/shef.rb +220 -0
- data/lib/chef/shef/ext.rb +297 -0
- data/lib/chef/shef/shef_session.rb +175 -0
- data/lib/chef/streaming_cookbook_uploader.rb +185 -0
- data/lib/chef/tasks/chef_repo.rake +245 -0
- data/lib/chef/util/file_edit.rb +125 -0
- data/lib/chef/util/fileedit.rb +121 -0
- data/lib/chef/webui_user.rb +231 -0
- metadata +398 -0
@@ -0,0 +1,175 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: chef-client
|
4
|
+
# Required-Start: $network
|
5
|
+
# Required-Stop: $network
|
6
|
+
# Default-Start: 2 3 4 5
|
7
|
+
# Default-Stop: 0 1 6
|
8
|
+
# Short-Description: Start a chef-client.
|
9
|
+
### END INIT INFO
|
10
|
+
#
|
11
|
+
# Copyright (c) 2009 Joshua Timberman, <joshua@opscode.com>
|
12
|
+
#
|
13
|
+
# chef-client Startup script for chef-client.
|
14
|
+
# chkconfig: - 98 02
|
15
|
+
# description: starts up chef-client in daemon mode.
|
16
|
+
|
17
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
18
|
+
DAEMON=/usr/bin/chef-client
|
19
|
+
NAME=chef-client
|
20
|
+
DESC=chef-client
|
21
|
+
LOGDIR=/var/log/chef
|
22
|
+
CONFIG=/etc/chef/client.rb
|
23
|
+
PIDFILE=/var/run/chef/client.pid
|
24
|
+
|
25
|
+
test -x $DAEMON || exit 0
|
26
|
+
|
27
|
+
. /lib/lsb/init-functions
|
28
|
+
|
29
|
+
if [ ! -d /var/run/chef ]; then
|
30
|
+
mkdir /var/run/chef
|
31
|
+
fi
|
32
|
+
|
33
|
+
DAEMON_OPTS="-d -c $CONFIG -i 1800 -s 20"
|
34
|
+
|
35
|
+
running_pid() {
|
36
|
+
pid=$1
|
37
|
+
name=$2
|
38
|
+
[ -z "$pid" ] && return 1
|
39
|
+
[ ! -d /proc/$pid ] && return 1
|
40
|
+
cmd=`awk '/Name:/ {print $2}' /proc/$pid/status`
|
41
|
+
[ "$cmd" != "$name" ] && return 1
|
42
|
+
return 0
|
43
|
+
}
|
44
|
+
|
45
|
+
running() {
|
46
|
+
[ ! -f "$PIDFILE" ] && return 1
|
47
|
+
pid=`cat $PIDFILE`
|
48
|
+
running_pid $pid $NAME || return 1
|
49
|
+
return 0
|
50
|
+
}
|
51
|
+
|
52
|
+
start_server() {
|
53
|
+
if [ -z "$DAEMONUSER" ] ; then
|
54
|
+
start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
|
55
|
+
errcode=$?
|
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
|
+
}
|
64
|
+
|
65
|
+
stop_server() {
|
66
|
+
if [ -z "$DAEMONUSER" ] ; then
|
67
|
+
killproc -p $PIDFILE $DAEMON
|
68
|
+
errcode=$?
|
69
|
+
else
|
70
|
+
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
|
71
|
+
--user $DAEMONUSER \
|
72
|
+
--exec $DAEMON
|
73
|
+
errcode=$?
|
74
|
+
fi
|
75
|
+
return $errcode
|
76
|
+
}
|
77
|
+
|
78
|
+
reload_server() {
|
79
|
+
[ ! -f "$PIDFILE" ] && return 1
|
80
|
+
pid=pidofproc $PIDFILE # This is the daemon's pid
|
81
|
+
/bin/kill -1 $pid
|
82
|
+
return $?
|
83
|
+
}
|
84
|
+
|
85
|
+
force_stop() {
|
86
|
+
[ ! -e "$PIDFILE" ] && return
|
87
|
+
if running ; then
|
88
|
+
/bin/kill -15 $pid
|
89
|
+
sleep "$DIETIME"s
|
90
|
+
if running ; then
|
91
|
+
/bin/kill -9 $pid
|
92
|
+
sleep "$DIETIME"s
|
93
|
+
if running ; then
|
94
|
+
echo "Cannot kill $NAME (pid=$pid)!"
|
95
|
+
exit 1
|
96
|
+
fi
|
97
|
+
fi
|
98
|
+
fi
|
99
|
+
rm -f $PIDFILE
|
100
|
+
}
|
101
|
+
|
102
|
+
case "$1" in
|
103
|
+
start)
|
104
|
+
log_daemon_msg "Starting $DESC " "$NAME"
|
105
|
+
if running ; then
|
106
|
+
log_progress_msg "apparently already running"
|
107
|
+
log_end_msg 0
|
108
|
+
exit 0
|
109
|
+
fi
|
110
|
+
if start_server ; then
|
111
|
+
[ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
|
112
|
+
if running ; then
|
113
|
+
log_end_msg 0
|
114
|
+
else
|
115
|
+
log_end_msg 1
|
116
|
+
fi
|
117
|
+
else
|
118
|
+
log_end_msg 1
|
119
|
+
fi
|
120
|
+
;;
|
121
|
+
stop)
|
122
|
+
log_daemon_msg "Stopping $DESC" "$NAME"
|
123
|
+
if running ; then
|
124
|
+
errcode=0
|
125
|
+
stop_server || errcode=$?
|
126
|
+
log_end_msg $errcode
|
127
|
+
else
|
128
|
+
log_progress_msg "apparently not running"
|
129
|
+
log_end_msg 0
|
130
|
+
exit 0
|
131
|
+
fi
|
132
|
+
;;
|
133
|
+
force-stop)
|
134
|
+
$0 stop
|
135
|
+
if running; then
|
136
|
+
log_daemon_msg "Stopping (force) $DESC" "$NAME"
|
137
|
+
errcode=0
|
138
|
+
force_stop || errcode=$?
|
139
|
+
log_end_msg $errcode
|
140
|
+
fi
|
141
|
+
;;
|
142
|
+
restart|force-reload)
|
143
|
+
log_daemon_msg "Restarting $DESC" "$NAME"
|
144
|
+
errcode=0
|
145
|
+
stop_server || errcode=$?
|
146
|
+
[ -n "$DIETIME" ] && sleep $DIETIME
|
147
|
+
start_server || errcode=$?
|
148
|
+
[ -n "$STARTTIME" ] && sleep $STARTTIME
|
149
|
+
running || errcode=$?
|
150
|
+
log_end_msg $errcode
|
151
|
+
;;
|
152
|
+
status)
|
153
|
+
log_daemon_msg "Checking status of $DESC" "$NAME"
|
154
|
+
if running ; then
|
155
|
+
log_progress_msg "running"
|
156
|
+
log_end_msg 0
|
157
|
+
else
|
158
|
+
log_progress_msg "apparently not running"
|
159
|
+
log_end_msg 1
|
160
|
+
exit 3
|
161
|
+
fi
|
162
|
+
;;
|
163
|
+
reload)
|
164
|
+
log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
|
165
|
+
log_warning_msg "cannot re-read the config file (use restart)."
|
166
|
+
;;
|
167
|
+
*)
|
168
|
+
N=/etc/init.d/$NAME
|
169
|
+
echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
|
170
|
+
exit 1
|
171
|
+
;;
|
172
|
+
esac
|
173
|
+
|
174
|
+
exit 0
|
175
|
+
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: chef-indexer
|
4
|
+
# Required-Start: $network
|
5
|
+
# Required-Stop: $network
|
6
|
+
# Default-Start: 2 3 4 5
|
7
|
+
# Default-Stop: 0 1 6
|
8
|
+
# Short-Description: Start a chef-indexer.
|
9
|
+
### END INIT INFO
|
10
|
+
#
|
11
|
+
# Copyright (c) 2009 Joshua Timberman, <joshua@opscode.com>
|
12
|
+
#
|
13
|
+
# chef-indexer Startup script for chef-indexer.
|
14
|
+
# chkconfig: - 98 02
|
15
|
+
# description: starts up chef-indexer in daemon mode.
|
16
|
+
|
17
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
18
|
+
DAEMON=/usr/bin/chef-indexer
|
19
|
+
NAME=chef-indexer
|
20
|
+
DESC=chef-indexer
|
21
|
+
LOGDIR=/var/log/chef
|
22
|
+
CONFIG=/etc/chef/indexer.rb
|
23
|
+
PIDFILE=/var/run/chef/indexer.pid
|
24
|
+
|
25
|
+
test -x $DAEMON || exit 0
|
26
|
+
|
27
|
+
. /lib/lsb/init-functions
|
28
|
+
|
29
|
+
if [ ! -d /var/run/chef ]; then
|
30
|
+
mkdir /var/run/chef
|
31
|
+
fi
|
32
|
+
|
33
|
+
DAEMON_OPTS="-d -c $CONFIG"
|
34
|
+
|
35
|
+
running_pid() {
|
36
|
+
pid=$1
|
37
|
+
name=$2
|
38
|
+
[ -z "$pid" ] && return 1
|
39
|
+
[ ! -d /proc/$pid ] && return 1
|
40
|
+
cmd=`cat /proc/$pid/cmdline | tr '\000' '\n' | awk 'NR==2'`
|
41
|
+
[ "$cmd" != "$name" ] && return 1
|
42
|
+
return 0
|
43
|
+
}
|
44
|
+
|
45
|
+
running() {
|
46
|
+
[ ! -f "$PIDFILE" ] && return 1
|
47
|
+
pid=`cat $PIDFILE`
|
48
|
+
running_pid $pid $DAEMON || return 1
|
49
|
+
return 0
|
50
|
+
}
|
51
|
+
|
52
|
+
start_server() {
|
53
|
+
if [ -z "$DAEMONUSER" ] ; then
|
54
|
+
start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
|
55
|
+
errcode=$?
|
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
|
+
}
|
64
|
+
|
65
|
+
stop_server() {
|
66
|
+
if [ -z "$DAEMONUSER" ] ; then
|
67
|
+
killproc -p $PIDFILE $DAEMON
|
68
|
+
errcode=$?
|
69
|
+
else
|
70
|
+
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
|
71
|
+
--user $DAEMONUSER \
|
72
|
+
--exec $DAEMON
|
73
|
+
errcode=$?
|
74
|
+
fi
|
75
|
+
return $errcode
|
76
|
+
}
|
77
|
+
|
78
|
+
reload_server() {
|
79
|
+
[ ! -f "$PIDFILE" ] && return 1
|
80
|
+
pid=pidofproc $PIDFILE # This is the daemon's pid
|
81
|
+
/bin/kill -1 $pid
|
82
|
+
return $?
|
83
|
+
}
|
84
|
+
|
85
|
+
force_stop() {
|
86
|
+
[ ! -e "$PIDFILE" ] && return
|
87
|
+
if running ; then
|
88
|
+
/bin/kill -15 $pid
|
89
|
+
sleep "$DIETIME"s
|
90
|
+
if running ; then
|
91
|
+
/bin/kill -9 $pid
|
92
|
+
sleep "$DIETIME"s
|
93
|
+
if running ; then
|
94
|
+
echo "Cannot kill $NAME (pid=$pid)!"
|
95
|
+
exit 1
|
96
|
+
fi
|
97
|
+
fi
|
98
|
+
fi
|
99
|
+
rm -f $PIDFILE
|
100
|
+
}
|
101
|
+
|
102
|
+
case "$1" in
|
103
|
+
start)
|
104
|
+
log_daemon_msg "Starting $DESC " "$NAME"
|
105
|
+
if running ; then
|
106
|
+
log_progress_msg "apparently already running"
|
107
|
+
log_end_msg 0
|
108
|
+
exit 3
|
109
|
+
fi
|
110
|
+
if start_server ; then
|
111
|
+
[ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
|
112
|
+
if running ; then
|
113
|
+
log_end_msg 0
|
114
|
+
else
|
115
|
+
log_end_msg 1
|
116
|
+
fi
|
117
|
+
else
|
118
|
+
log_end_msg 1
|
119
|
+
fi
|
120
|
+
;;
|
121
|
+
stop)
|
122
|
+
log_daemon_msg "Stopping $DESC" "$NAME"
|
123
|
+
if running ; then
|
124
|
+
errcode=0
|
125
|
+
stop_server || errcode=$?
|
126
|
+
log_end_msg $errcode
|
127
|
+
else
|
128
|
+
log_progress_msg "apparently not running"
|
129
|
+
log_end_msg 0
|
130
|
+
exit 0
|
131
|
+
fi
|
132
|
+
;;
|
133
|
+
force-stop)
|
134
|
+
$0 stop
|
135
|
+
if running; then
|
136
|
+
log_daemon_msg "Stopping (force) $DESC" "$NAME"
|
137
|
+
errcode=0
|
138
|
+
force_stop || errcode=$?
|
139
|
+
log_end_msg $errcode
|
140
|
+
fi
|
141
|
+
;;
|
142
|
+
restart|force-reload)
|
143
|
+
log_daemon_msg "Restarting $DESC" "$NAME"
|
144
|
+
errcode=0
|
145
|
+
stop_server || errcode=$?
|
146
|
+
[ -n "$DIETIME" ] && sleep $DIETIME
|
147
|
+
start_server || errcode=$?
|
148
|
+
[ -n "$STARTTIME" ] && sleep $STARTTIME
|
149
|
+
running || errcode=$?
|
150
|
+
log_end_msg $errcode
|
151
|
+
;;
|
152
|
+
status)
|
153
|
+
log_daemon_msg "Checking status of $DESC" "$NAME"
|
154
|
+
if running ; then
|
155
|
+
log_progress_msg "running"
|
156
|
+
log_end_msg 0
|
157
|
+
else
|
158
|
+
log_progress_msg "apparently not running"
|
159
|
+
log_end_msg 1
|
160
|
+
exit 1
|
161
|
+
fi
|
162
|
+
;;
|
163
|
+
reload)
|
164
|
+
log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
|
165
|
+
log_warning_msg "cannot re-read the config file (use restart)."
|
166
|
+
;;
|
167
|
+
*)
|
168
|
+
N=/etc/init.d/$NAME
|
169
|
+
echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
|
170
|
+
exit 1
|
171
|
+
;;
|
172
|
+
esac
|
173
|
+
|
174
|
+
exit 0
|
175
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: chef-server
|
4
|
+
# Required-Start: $network
|
5
|
+
# Required-Stop: $network
|
6
|
+
# Default-Start: 2 3 4 5
|
7
|
+
# Default-Stop: 0 1 6
|
8
|
+
# Short-Description: Start a chef-server.
|
9
|
+
### END INIT INFO
|
10
|
+
#
|
11
|
+
# Copyright (c) 2009 Joshua Timberman, <joshua@opscode.com>
|
12
|
+
#
|
13
|
+
# chef-server Startup script for chef-server.
|
14
|
+
# chkconfig: - 98 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
|
19
|
+
PIDFILE=/var/run/chef/server.%s.pid
|
20
|
+
MAINPID=/var/run/chef/server.main.pid
|
21
|
+
LOGFILE=/var/log/chef/merb.%s.log
|
22
|
+
MASTER=master
|
23
|
+
NAME=chef-server
|
24
|
+
DESC=chef-server
|
25
|
+
DAEMON_OPTS="-d -c2 -P $PIDFILE -L $LOGFILE"
|
26
|
+
|
27
|
+
test -x $DAEMON || exit 0
|
28
|
+
|
29
|
+
. /lib/lsb/init-functions
|
30
|
+
|
31
|
+
if [ ! -d /var/run/chef ]; then
|
32
|
+
mkdir /var/run/chef
|
33
|
+
fi
|
34
|
+
|
35
|
+
running() {
|
36
|
+
[ ! -f "$MAINPID" ] && return 1
|
37
|
+
pid=`cat $MAINPID`
|
38
|
+
name=$MASTER
|
39
|
+
[ -z "$pid" ] && return 1
|
40
|
+
[ ! -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
|
43
|
+
return 0
|
44
|
+
}
|
45
|
+
|
46
|
+
start_server() {
|
47
|
+
$DAEMON $DAEMON_OPTS
|
48
|
+
errcode=$?
|
49
|
+
return $errcode
|
50
|
+
}
|
51
|
+
|
52
|
+
stop_server() {
|
53
|
+
$DAEMON -K all -P $PIDFILE
|
54
|
+
errcode=$?
|
55
|
+
return $errcode
|
56
|
+
}
|
57
|
+
|
58
|
+
reload_server() {
|
59
|
+
stop_server
|
60
|
+
start_server
|
61
|
+
}
|
62
|
+
|
63
|
+
case "$1" in
|
64
|
+
start)
|
65
|
+
log_daemon_msg "Starting $DESC "
|
66
|
+
if running ; then
|
67
|
+
log_progress_msg "apparently already running"
|
68
|
+
log_end_msg 0
|
69
|
+
exit 0
|
70
|
+
fi
|
71
|
+
if start_server ; then
|
72
|
+
sleep 1
|
73
|
+
if running ; then
|
74
|
+
log_end_msg 0
|
75
|
+
else
|
76
|
+
log_end_msg 1
|
77
|
+
fi
|
78
|
+
else
|
79
|
+
log_end_msg 1
|
80
|
+
fi
|
81
|
+
;;
|
82
|
+
stop)
|
83
|
+
log_daemon_msg "Stopping $DESC"
|
84
|
+
if running ; then
|
85
|
+
errcode=0
|
86
|
+
stop_server || errcode=$?
|
87
|
+
log_end_msg $errcode
|
88
|
+
else
|
89
|
+
log_progress_msg "apparently not running"
|
90
|
+
log_end_msg 0
|
91
|
+
exit 0
|
92
|
+
fi
|
93
|
+
;;
|
94
|
+
restart|force-reload)
|
95
|
+
log_daemon_msg "Restarting $DESC"
|
96
|
+
errcode=0
|
97
|
+
reload_server
|
98
|
+
running && errcode=$?
|
99
|
+
log_end_msg $errcode
|
100
|
+
;;
|
101
|
+
status)
|
102
|
+
log_daemon_msg "Checking status of $DESC"
|
103
|
+
if running ; then
|
104
|
+
log_progress_msg "running"
|
105
|
+
log_end_msg 0
|
106
|
+
else
|
107
|
+
log_progress_msg "apparently not running"
|
108
|
+
log_end_msg 1
|
109
|
+
exit 3
|
110
|
+
fi
|
111
|
+
;;
|
112
|
+
*)
|
113
|
+
N=/etc/init.d/$NAME
|
114
|
+
echo "Usage: $N {start|stop|restart|status}" >&2
|
115
|
+
exit 1
|
116
|
+
;;
|
117
|
+
esac
|
118
|
+
|
119
|
+
exit 0
|
120
|
+
|