centostrano 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +215 -0
- data/COPYING +19 -0
- data/LICENSE +339 -0
- data/README +166 -0
- data/THANKS +5 -0
- data/bin/centify +137 -0
- data/docs/ANNOUNCE.deprec2 +47 -0
- data/docs/README.install +88 -0
- data/docs/README.nagios +28 -0
- data/docs/README.rails +20 -0
- data/docs/README.svn +31 -0
- data/docs/ROADMAP.txt +74 -0
- data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
- data/docs/deprec-1.x/notes.txt +12 -0
- data/docs/deprec_banner.gif +0 -0
- data/lib/centostrano.rb +9 -0
- data/lib/deprec/capistrano_extensions.rb +391 -0
- data/lib/deprec/centostrano.rb +46 -0
- data/lib/deprec/recipes/apache.rb +188 -0
- data/lib/deprec/recipes/canonical.rb +57 -0
- data/lib/deprec/recipes/deprec.rb +188 -0
- data/lib/deprec/recipes/deprecated.rb +71 -0
- data/lib/deprec/recipes/example.rb +115 -0
- data/lib/deprec/recipes/git.rb +106 -0
- data/lib/deprec/recipes/gitosis.rb +134 -0
- data/lib/deprec/recipes/logrotate.rb +54 -0
- data/lib/deprec/recipes/memcache.rb +53 -0
- data/lib/deprec/recipes/merb.rb +57 -0
- data/lib/deprec/recipes/mongrel.rb +220 -0
- data/lib/deprec/recipes/monit.rb +139 -0
- data/lib/deprec/recipes/mysql.rb +147 -0
- data/lib/deprec/recipes/nginx.rb +172 -0
- data/lib/deprec/recipes/postgresql.rb +132 -0
- data/lib/deprec/recipes/rails.rb +297 -0
- data/lib/deprec/recipes/ruby.rb +71 -0
- data/lib/deprec/recipes/sphinx.rb +89 -0
- data/lib/deprec/recipes/ssh.rb +93 -0
- data/lib/deprec/recipes/svn.rb +167 -0
- data/lib/deprec/recipes/users.rb +90 -0
- data/lib/deprec/recipes.rb +33 -0
- data/lib/deprec/templates/aoe/aoe-init +55 -0
- data/lib/deprec/templates/aoe/fence_aoemask +351 -0
- data/lib/deprec/templates/apache/httpd-vhost-app.conf.erb +144 -0
- data/lib/deprec/templates/apache/httpd.conf +465 -0
- data/lib/deprec/templates/apache/index.html.erb +37 -0
- data/lib/deprec/templates/apache/master.css +72 -0
- data/lib/deprec/templates/centos/repository.erb +6 -0
- data/lib/deprec/templates/coraid/aoe-init +55 -0
- data/lib/deprec/templates/deprec/caprc.erb +14 -0
- data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
- data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
- data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
- data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
- data/lib/deprec/templates/mongrel/logrotate.erb +0 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +14 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
- data/lib/deprec/templates/monit/monit-init-script +104 -0
- data/lib/deprec/templates/monit/monitrc.erb +227 -0
- data/lib/deprec/templates/monit/nothing +0 -0
- data/lib/deprec/templates/mysql/create_databases.sql +20 -0
- data/lib/deprec/templates/mysql/database.yml.prod +6 -0
- data/lib/deprec/templates/mysql/database.yml.stage +6 -0
- data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
- data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
- data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
- data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
- data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
- data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
- data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
- data/lib/deprec/templates/nagios/htpasswd.users +1 -0
- data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
- data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
- data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
- data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
- data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
- data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
- data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
- data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
- data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
- data/lib/deprec/templates/network/hostname.erb +1 -0
- data/lib/deprec/templates/network/hosts.erb +2 -0
- data/lib/deprec/templates/network/interfaces.erb +22 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
- data/lib/deprec/templates/nginx/logrotate.erb +0 -0
- data/lib/deprec/templates/nginx/mime.types.erb +70 -0
- data/lib/deprec/templates/nginx/nginx-init-script +109 -0
- data/lib/deprec/templates/nginx/nginx.conf.erb +120 -0
- data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
- data/lib/deprec/templates/nginx/nothing.conf +1 -0
- data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
- data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
- data/lib/deprec/templates/postfix/aliases.erb +3 -0
- data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
- data/lib/deprec/templates/postfix/main.cf.erb +41 -0
- data/lib/deprec/templates/postfix/master.cf.erb +77 -0
- data/lib/deprec/templates/postgresql/pg_hba.conf.erb +76 -0
- data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
- data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
- data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
- data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
- data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
- data/lib/deprec/templates/trac/trac.ini.erb +106 -0
- data/lib/deprec/templates/trac/trac_deprec.png +0 -0
- data/lib/deprec/templates/trac/tracd-init.erb +43 -0
- data/lib/deprec/templates/xen/15-disable-hwclock +40 -0
- data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
- data/lib/deprec/templates/xen/xen-tools.conf.erb +220 -0
- data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
- data/lib/deprec/templates/xen/xend-init.erb +69 -0
- data/lib/deprec/templates/xen/xendomains.erb +137 -0
- data/lib/deprec/templates/xen/xm.tmpl.erb +85 -0
- data/lib/deprec_cmd_completion.sh +26 -0
- data/lib/vmbuilder_plugins/all.rb +20 -0
- data/lib/vmbuilder_plugins/apt.rb +93 -0
- data/lib/vmbuilder_plugins/emerge.rb +76 -0
- data/lib/vmbuilder_plugins/gem.rb +90 -0
- data/lib/vmbuilder_plugins/std.rb +203 -0
- metadata +207 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
2
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
6
|
+
<title>Apache2 installed by Centostrano (deprec 2 port to CentOS)</title>
|
7
|
+
<link rel="stylesheet" href="/master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
8
|
+
|
9
|
+
</head>
|
10
|
+
<body id="" onload="">
|
11
|
+
<div id="wrapper">
|
12
|
+
<h1>Apache2 installed by Centostrano (deprec 2 port to CentOS)</h1>
|
13
|
+
<h2>Commands</h2>
|
14
|
+
<dl>
|
15
|
+
<dt>cap centos:apache:start</dt><dd>Start apache</dd>
|
16
|
+
<dt>cap centos:apache:stop</dt><dd>Stop apache</dd>
|
17
|
+
<dt>cap centos:apache:restart</dt><dd>Stop restart</dd>
|
18
|
+
<dt>cap centos:apache:reload</dt><dd>Reload apache</dd>
|
19
|
+
|
20
|
+
<dt>cap centos:apache:install</dt><dd>Install apache</dd>
|
21
|
+
<dt>cap centos:apache:config_gen</dt><dd>Generate apache configs</dd>
|
22
|
+
|
23
|
+
<dt>cap centos:apache:activate</dt><dd>Start Apache when server boots</dd>
|
24
|
+
<dt>cap centos:apache:deactivate</dt><dd>Don't start Apache when server boots</dd>
|
25
|
+
|
26
|
+
</dl>
|
27
|
+
|
28
|
+
<dl>
|
29
|
+
<p>Installation options</p>
|
30
|
+
<% SRC_PACKAGES[:apache].each do |key, val| %>
|
31
|
+
<dt><%= key %></dt>
|
32
|
+
<dd><%= val %></dd>
|
33
|
+
<% end %>
|
34
|
+
</dl>
|
35
|
+
</div>
|
36
|
+
</body>
|
37
|
+
</html>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/*-----------------------------------------------------------------------------
|
2
|
+
Basic Stylesheet
|
3
|
+
|
4
|
+
version: 1
|
5
|
+
author: Mike Bailey
|
6
|
+
email: mike@bailey.net.au
|
7
|
+
website: http://mike.bailey.net.au/
|
8
|
+
-----------------------------------------------------------------------------*/
|
9
|
+
|
10
|
+
/* General stuff *************************************************************/
|
11
|
+
|
12
|
+
* {
|
13
|
+
padding:0;
|
14
|
+
margin: 0;
|
15
|
+
font-family: sans-serif;
|
16
|
+
}
|
17
|
+
|
18
|
+
body {
|
19
|
+
text-align: center;
|
20
|
+
min-width: 760;
|
21
|
+
}
|
22
|
+
|
23
|
+
.clear {
|
24
|
+
clear: both;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
padding: 0.5em;
|
29
|
+
}
|
30
|
+
|
31
|
+
dl {
|
32
|
+
border: 1px solid red;
|
33
|
+
padding: 1em;
|
34
|
+
}
|
35
|
+
|
36
|
+
dl p {
|
37
|
+
font-size: 1.5em;
|
38
|
+
padding: .5em 0;
|
39
|
+
}
|
40
|
+
|
41
|
+
dt {
|
42
|
+
padding: 0 0 0 1em;
|
43
|
+
}
|
44
|
+
|
45
|
+
dd {
|
46
|
+
padding: 0 0 1em 2em;
|
47
|
+
color: darkblue;
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
/* Layout ********************************************************************/
|
52
|
+
|
53
|
+
#wrapper {
|
54
|
+
width: 720px;
|
55
|
+
background: #d0d0d0;
|
56
|
+
margin: 0 auto;
|
57
|
+
text-align: left;
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
/* Navigation links **********************************************************/
|
62
|
+
|
63
|
+
ul#navlinks {
|
64
|
+
width: 720px;
|
65
|
+
list-style: none;
|
66
|
+
background: #FAA819;
|
67
|
+
float: left;
|
68
|
+
}
|
69
|
+
|
70
|
+
ul li {
|
71
|
+
float:left;
|
72
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
[<%= options[:repository][:code] %>]
|
2
|
+
name=<%= options[:repository][:name] %>
|
3
|
+
baseurl=<%= options[:repository][:baseurl] %>
|
4
|
+
enabled=<%= options[:repository][:enabled] %>
|
5
|
+
gpgcheck=<%= options[:repository][:gpgcheck] %>
|
6
|
+
gpgkey=<%= options[:repository][:gpgkey] %>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
# aoe-init - example init script for ATA over Ethernet storage
|
3
|
+
#
|
4
|
+
# Edit this script for your purposes. (Changing "eth1" to the
|
5
|
+
# appropriate interface name, adding commands, etc.) You might
|
6
|
+
# need to tune the sleep times.
|
7
|
+
#
|
8
|
+
# Install this script in /etc/init.d with the other init scripts.
|
9
|
+
#
|
10
|
+
# Make it executable:
|
11
|
+
# chmod 755 /etc/init.d/aoe-init
|
12
|
+
#
|
13
|
+
# Install symlinks for boot time:
|
14
|
+
# cd /etc/rc3.d && ln -s ../init.d/aoe-init S99aoe-init
|
15
|
+
# cd /etc/rc5.d && ln -s ../init.d/aoe-init S99aoe-init
|
16
|
+
#
|
17
|
+
# Install symlinks for shutdown time:
|
18
|
+
# cd /etc/rc0.d && ln -s ../init.d/aoe-init K01aoe-init
|
19
|
+
# cd /etc/rc1.d && ln -s ../init.d/aoe-init K01aoe-init
|
20
|
+
# cd /etc/rc2.d && ln -s ../init.d/aoe-init K01aoe-init
|
21
|
+
# cd /etc/rc6.d && ln -s ../init.d/aoe-init K01aoe-init
|
22
|
+
#
|
23
|
+
|
24
|
+
case "$1" in
|
25
|
+
"start")
|
26
|
+
# load any needed network drivers here
|
27
|
+
|
28
|
+
# replace "eth1" with your aoe network interface
|
29
|
+
ifconfig eth1 up
|
30
|
+
|
31
|
+
# time for network interface to come up
|
32
|
+
sleep 4
|
33
|
+
|
34
|
+
modprobe aoe
|
35
|
+
|
36
|
+
# time for AoE discovery and udev
|
37
|
+
sleep 7
|
38
|
+
|
39
|
+
# add your raid assemble commands here
|
40
|
+
# add any LVM commands if needed (e.g. vgchange)
|
41
|
+
# add your filesystem mount commands here
|
42
|
+
|
43
|
+
test -d /var/lock/subsys && touch /var/lock/subsys/aoe-init
|
44
|
+
;;
|
45
|
+
"stop")
|
46
|
+
# add your filesystem umount commands here
|
47
|
+
# deactivate LVM volume groups if needed
|
48
|
+
# add your raid stop commands here
|
49
|
+
rmmod aoe
|
50
|
+
rm -f /var/lock/subsys/aoe-init
|
51
|
+
;;
|
52
|
+
*)
|
53
|
+
echo "usage: `basename $0` {start|stop}" 1>&2
|
54
|
+
;;
|
55
|
+
esac
|
@@ -0,0 +1,14 @@
|
|
1
|
+
ssh_options[:paranoid] = false
|
2
|
+
ssh_options[:forward_agent] = true
|
3
|
+
|
4
|
+
|
5
|
+
# Just import the general purpose tasks
|
6
|
+
require '/deprec/general_purpose' if respond_to?(:namespace)
|
7
|
+
|
8
|
+
# Enable all deprec tasks all the time. This will change the
|
9
|
+
# behviour of some standard cap tasks (like 'cap deploy') so
|
10
|
+
# only enable it if you know what you're doing!
|
11
|
+
#
|
12
|
+
# require 'deprec/recipes' unless respond_to?(:namespace)
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# http://linux-ha.org/ha.cf
|
2
|
+
logfacility daemon
|
3
|
+
keepalive 1
|
4
|
+
deadtime 10
|
5
|
+
warntime 5
|
6
|
+
initdead 120 # depend on your hardware
|
7
|
+
udpport 694
|
8
|
+
ping <%= heartbeat_ping %>
|
9
|
+
bcast <%= heartbeat_bcast %>
|
10
|
+
auto_failback <%= heartbeat_auto_failback %>
|
11
|
+
<% heartbeat_nodes.each do |node| -%>
|
12
|
+
node <%= node %>
|
13
|
+
<% end -%>
|
14
|
+
respawn hacluster /usr/lib/heartbeat/ipfail
|
15
|
+
use_logd yes
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= heartbeat_preferred_node %> <%= heartbeat_resources %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# see "man logrotate" for details
|
2
|
+
# rotate log files weekly
|
3
|
+
weekly
|
4
|
+
|
5
|
+
# keep 4 weeks worth of backlogs
|
6
|
+
rotate 4
|
7
|
+
|
8
|
+
# create new (empty) log files after rotating old ones
|
9
|
+
create
|
10
|
+
|
11
|
+
# uncomment this if you want your log files compressed
|
12
|
+
#compress
|
13
|
+
|
14
|
+
# packages drop log rotation information into this directory
|
15
|
+
include /etc/logrotate.d
|
16
|
+
|
17
|
+
# no packages own wtmp, or btmp -- we'll rotate them here
|
18
|
+
/var/log/wtmp {
|
19
|
+
missingok
|
20
|
+
monthly
|
21
|
+
create 0664 root utmp
|
22
|
+
rotate 1
|
23
|
+
}
|
24
|
+
|
25
|
+
/var/log/btmp {
|
26
|
+
missingok
|
27
|
+
monthly
|
28
|
+
create 0664 root utmp
|
29
|
+
rotate 1
|
30
|
+
}
|
31
|
+
|
32
|
+
# system-specific logs may be configured here
|
File without changes
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
|
4
|
+
#
|
5
|
+
# mongrel_cluster Startup script for Mongrel clusters.
|
6
|
+
#
|
7
|
+
# chkconfig: - 85 15
|
8
|
+
# description: mongrel_cluster manages multiple Mongrel processes for use \
|
9
|
+
# behind a load balancer.
|
10
|
+
#
|
11
|
+
|
12
|
+
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin
|
13
|
+
CONF_DIR=/etc/mongrel_cluster
|
14
|
+
PID_DIR=/var/run/mongrel_cluster
|
15
|
+
# USER=mongrel
|
16
|
+
|
17
|
+
EVENT=1
|
18
|
+
|
19
|
+
RETVAL=0
|
20
|
+
|
21
|
+
# Gracefully exit if the controller is missing.
|
22
|
+
which mongrel_cluster_ctl >/dev/null || exit 0
|
23
|
+
|
24
|
+
# Go no further if config directory is missing.
|
25
|
+
[ -d "$CONF_DIR" ] || exit 0
|
26
|
+
|
27
|
+
case "$1" in
|
28
|
+
start)
|
29
|
+
# Create pid directory
|
30
|
+
mkdir -p $PID_DIR
|
31
|
+
# chown $USER:$USER $PID_DIR
|
32
|
+
|
33
|
+
mongrel_cluster_ctl start --clean -c $CONF_DIR
|
34
|
+
RETVAL=$?
|
35
|
+
;;
|
36
|
+
stop)
|
37
|
+
mongrel_cluster_ctl stop -c $CONF_DIR
|
38
|
+
RETVAL=$?
|
39
|
+
;;
|
40
|
+
restart)
|
41
|
+
mongrel_cluster_ctl restart --clean -c $CONF_DIR
|
42
|
+
RETVAL=$?
|
43
|
+
;;
|
44
|
+
status)
|
45
|
+
mongrel_cluster_ctl status -c $CONF_DIR
|
46
|
+
RETVAL=$?
|
47
|
+
;;
|
48
|
+
*)
|
49
|
+
echo "Usage: mongrel_cluster {start|stop|restart|status}"
|
50
|
+
exit 1
|
51
|
+
;;
|
52
|
+
esac
|
53
|
+
|
54
|
+
exit $RETVAL
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/var/log/mongrel/<%= application %>/*.log {
|
2
|
+
daily
|
3
|
+
missingok
|
4
|
+
rotate 28
|
5
|
+
compress
|
6
|
+
notifempty
|
7
|
+
sharedscripts
|
8
|
+
extension gz
|
9
|
+
postrotate
|
10
|
+
for i in `ls /data/<%= @username %>/shared/log/*.pid`; do
|
11
|
+
kill -USR2 `cat $i`
|
12
|
+
done
|
13
|
+
endscript
|
14
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
---
|
2
|
+
user: <%= mongrel_user %>
|
3
|
+
group: <%= mongrel_group %>
|
4
|
+
cwd: <%= current_path %>
|
5
|
+
log_file: <%= mongrel_log_dir %>/mongrel.log
|
6
|
+
port: "<%= mongrel_port.to_s %>"
|
7
|
+
environment: <%= mongrel_environment %>
|
8
|
+
address: <%= mongrel_address %>
|
9
|
+
pid_file: <%= mongrel_pid_dir %>/mongrel.pid
|
10
|
+
servers: <%= mongrel_servers.to_s %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% mongrel_servers.times do |counter| -%>
|
2
|
+
check process mongrel-<%=mongrel_port+counter%> with pidfile <%= mongrel_pid_dir %>/mongrel.<%=mongrel_port+counter%>.pid
|
3
|
+
group mongrel_<%= application %>
|
4
|
+
start program = "/usr/local/bin/ruby /usr/local/bin/mongrel_rails start -d -e production -a 127.0.0.1 -c <%= deploy_to %>/current --user <%= mongrel_user %> --group <%= mongrel_group %> -p <%=mongrel_port+counter%> -P <%= mongrel_pid_dir %>/mongrel.<%=mongrel_port+counter%>.pid -l <%= mongrel_log_dir %>/mongrel.<%=mongrel_port+counter%>.log"
|
5
|
+
stop program = "/usr/local/bin/ruby /usr/local/bin/mongrel_rails stop -P <%= mongrel_pid_dir %>/mongrel.<%=mongrel_port+counter%>.pid"
|
6
|
+
|
7
|
+
if failed host 127.0.0.1 port <%=mongrel_port+counter%> protocol http
|
8
|
+
with timeout 10 seconds
|
9
|
+
then alert
|
10
|
+
|
11
|
+
if totalmem > 100 Mb then restart
|
12
|
+
if cpu > 60% for 2 cycles then alert
|
13
|
+
if cpu > 80% for 5 cycles then restart
|
14
|
+
if loadavg(5min) > 10 for 8 cycles then restart
|
15
|
+
if 3 restarts within 5 cycles then timeout
|
16
|
+
|
17
|
+
<% end -%>
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# /etc/init.d/monit start and stop monit daemon monitor process.
|
3
|
+
# Fredrik Steen, stone@debian.org
|
4
|
+
:
|
5
|
+
PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
6
|
+
DAEMON=/usr/local/bin/monit
|
7
|
+
CONFIG="/etc/monitrc"
|
8
|
+
NAME=monit
|
9
|
+
DESC="daemon monitor"
|
10
|
+
|
11
|
+
set -e
|
12
|
+
|
13
|
+
# Check if DAEMON binary exist
|
14
|
+
test -f $DAEMON || exit 0
|
15
|
+
|
16
|
+
ARGS="-c $CONFIG"
|
17
|
+
|
18
|
+
monit_not_configured () {
|
19
|
+
echo -e "monit won't be started/stopped\n\tunless it it's configured"
|
20
|
+
if [ "$1" != "stop" ]
|
21
|
+
then
|
22
|
+
echo -e "\tplease configure monit and then edit /etc/default/monit"
|
23
|
+
echo -e "\tand set the \"startup\" variable to 1 in order to allow "
|
24
|
+
echo -e "\tmonit to start"
|
25
|
+
fi
|
26
|
+
exit 0
|
27
|
+
}
|
28
|
+
|
29
|
+
monit_check_config () {
|
30
|
+
# Check for emtpy config, probably default configfile.
|
31
|
+
if [ "`grep -s -v \"^#\" $CONFIG`" = "" ]; then
|
32
|
+
echo "empty config, please edit $CONFIG."
|
33
|
+
exit 0
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
monit_check_perms () {
|
38
|
+
# Check the permission on configfile.
|
39
|
+
# The permission must not have more than -rwx------ (0700) permissions.
|
40
|
+
|
41
|
+
# Skip checking, fix perms instead.
|
42
|
+
/bin/chmod go-rwx $CONFIG
|
43
|
+
|
44
|
+
}
|
45
|
+
|
46
|
+
monit_delayed_monitoring () {
|
47
|
+
if [ -x $DELAY ]; then
|
48
|
+
$DELAY &
|
49
|
+
elif [ -f $DELAY ]; then
|
50
|
+
echo
|
51
|
+
echo "[WARNING] A delayed start file exists ($DELAY) but it is not executable."
|
52
|
+
fi
|
53
|
+
}
|
54
|
+
|
55
|
+
monit_check_syntax () {
|
56
|
+
$DAEMON -t;
|
57
|
+
# if [ $? ] ; then
|
58
|
+
# echo "syntax good"
|
59
|
+
# else
|
60
|
+
# echo "syntax bad"
|
61
|
+
# fi
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
monit_checks () {
|
66
|
+
# Check for emtpy configfile
|
67
|
+
monit_check_config
|
68
|
+
# Check permissions of configfile
|
69
|
+
monit_check_perms
|
70
|
+
}
|
71
|
+
|
72
|
+
case "$1" in
|
73
|
+
start)
|
74
|
+
echo -n "Starting $DESC: "
|
75
|
+
monit_checks $1
|
76
|
+
echo -n "$NAME"
|
77
|
+
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
|
78
|
+
--exec $DAEMON > /dev/null 2>&1 -- $ARGS
|
79
|
+
monit_delayed_monitoring
|
80
|
+
echo "."
|
81
|
+
;;
|
82
|
+
stop)
|
83
|
+
echo -n "Stopping $DESC: "
|
84
|
+
#monit_checks $1
|
85
|
+
echo -n "$NAME"
|
86
|
+
start-stop-daemon --retry 5 --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
|
87
|
+
--exec $DAEMON > /dev/null 2>&1
|
88
|
+
echo "."
|
89
|
+
;;
|
90
|
+
restart|force-reload)
|
91
|
+
$0 stop
|
92
|
+
$0 start
|
93
|
+
;;
|
94
|
+
syntax)
|
95
|
+
monit_check_syntax
|
96
|
+
;;
|
97
|
+
*)
|
98
|
+
N=/etc/init.d/$NAME
|
99
|
+
echo "Usage: $N {start|stop|restart|force-reload|syntax}" >&2
|
100
|
+
exit 1
|
101
|
+
;;
|
102
|
+
esac
|
103
|
+
|
104
|
+
exit 0
|