capigen 0.1.1
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.
- data/Capfile +22 -0
- data/History.txt +3 -0
- data/License.txt +20 -0
- data/Manifest.txt +83 -0
- data/README.txt +35 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/init.rb +3 -0
- data/lib/capigen/config.rb +84 -0
- data/lib/capigen/helper.rb +51 -0
- data/lib/capigen/helpers/gem_helper.rb +15 -0
- data/lib/capigen/helpers/package_helper.rb +40 -0
- data/lib/capigen/helpers/script_helper.rb +30 -0
- data/lib/capigen/helpers/wget_helper.rb +17 -0
- data/lib/capigen/packagers/yum.rb +46 -0
- data/lib/capigen/profiles.rb +19 -0
- data/lib/capigen/recipes.yml +14 -0
- data/lib/capigen/templates.rb +65 -0
- data/lib/capigen/version.rb +9 -0
- data/lib/capigen.rb +26 -0
- data/recipes/README +12 -0
- data/recipes/bootstrap/patch.rb +87 -0
- data/recipes/centos.rb +40 -0
- data/recipes/deploy.rb +17 -0
- data/recipes/gems.rb +8 -0
- data/recipes/imagemagick.rb +9 -0
- data/recipes/install.rb +13 -0
- data/recipes/memcached.rb +15 -0
- data/recipes/mongrel_cluster.rb +49 -0
- data/recipes/monit.rb +16 -0
- data/recipes/mysql.rb +24 -0
- data/recipes/nginx.rb +42 -0
- data/recipes/profiles/centos-sick.rb +65 -0
- data/recipes/rails.rb +14 -0
- data/recipes/ruby.rb +14 -0
- data/recipes/sphinx.rb +62 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/capigen.rake +13 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/templates/capistrano/Capfile +22 -0
- data/templates/capistrano/deploy.rb.erb +61 -0
- data/templates/centos/setup.sh +17 -0
- data/templates/centos/sudoers +95 -0
- data/templates/imagemagick/install.sh +20 -0
- data/templates/memcached/install.sh +27 -0
- data/templates/memcached/memcached.initd.centos.erb +70 -0
- data/templates/memcached/memcached.monitrc.erb +4 -0
- data/templates/mongrel/mongrel_cluster.initd.erb +61 -0
- data/templates/mongrel/mongrel_cluster.monitrc.erb +15 -0
- data/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/templates/monit/cert.sh +14 -0
- data/templates/monit/install.sh +29 -0
- data/templates/monit/monit.cnf +34 -0
- data/templates/monit/monit.initd.centos.erb +68 -0
- data/templates/monit/monitrc.erb +28 -0
- data/templates/monit/patch_inittab.sh +15 -0
- data/templates/mysql/install.sh.erb +10 -0
- data/templates/mysql/install_db.sql.erb +5 -0
- data/templates/mysql/mysql.monitrc.erb +6 -0
- data/templates/nginx/install.sh.erb +42 -0
- data/templates/nginx/nginx.conf.erb +76 -0
- data/templates/nginx/nginx.initd.erb +62 -0
- data/templates/nginx/nginx.monitrc.erb +4 -0
- data/templates/nginx/nginx_vhost.conf.erb +94 -0
- data/templates/rails/database.yml.erb +42 -0
- data/templates/ruby/ruby_install.sh +26 -0
- data/templates/ruby/rubygems_install.sh +13 -0
- data/templates/sphinx/install.sh.erb +22 -0
- data/templates/sphinx/sphinx.conf.erb +496 -0
- data/templates/sphinx/sphinx.monitrc.erb +4 -0
- data/templates/sphinx/sphinx_app.initd.centos.erb +67 -0
- data/templates/sphinx/sphinx_app.initd.erb +57 -0
- data/website/index.html +93 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +141 -0
data/tasks/capigen.rake
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
task :capigen => :environment do
|
|
2
|
+
|
|
3
|
+
include Capigen::Helper
|
|
4
|
+
|
|
5
|
+
# auto_default = false
|
|
6
|
+
|
|
7
|
+
config = Capigen::Config.new
|
|
8
|
+
config.ask_all
|
|
9
|
+
|
|
10
|
+
config_binding = config.get_binding
|
|
11
|
+
write_template("capistrano/Capfile", config_binding, relative_to_root("Capfile"), true)
|
|
12
|
+
write_template("capistrano/deploy.rb.erb", config_binding, relative_to_root("config/deploy.rb"), true)
|
|
13
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
desc 'Release the website and new gem version'
|
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
|
3
|
+
puts "Remember to create SVN tag:"
|
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
|
6
|
+
puts "Suggested comment:"
|
|
7
|
+
puts "Tagging release #{CHANGES}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
|
12
|
+
|
|
13
|
+
task :check_version do
|
|
14
|
+
unless ENV['VERSION']
|
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
|
16
|
+
exit
|
|
17
|
+
end
|
|
18
|
+
unless ENV['VERSION'] == VERS
|
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
|
20
|
+
exit
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
namespace :manifest do
|
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
|
31
|
+
task :refresh do
|
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
|
33
|
+
end
|
|
34
|
+
end
|
data/tasks/website.rake
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
desc 'Generate website files'
|
|
2
|
+
task :website_generate => :ruby_env do
|
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
desc 'Upload website files to rubyforge'
|
|
9
|
+
task :website_upload do
|
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
|
12
|
+
local_dir = 'website'
|
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'Generate and upload website files'
|
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#
|
|
2
|
+
# This file is auto-generated from Capgen
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
|
6
|
+
|
|
7
|
+
set :project_root, File.dirname(__FILE__)
|
|
8
|
+
|
|
9
|
+
# Load bootstrapped patch.rb
|
|
10
|
+
Dir['vendor/plugins/*/recipes/bootstrap/patch.rb'].each { |patch| load(patch)}
|
|
11
|
+
|
|
12
|
+
# Load recipes from plugins
|
|
13
|
+
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
|
14
|
+
|
|
15
|
+
# Load project recipes
|
|
16
|
+
Dir['lib/recipes/*.rb'].each { |plugin| load(plugin) }
|
|
17
|
+
|
|
18
|
+
require 'erb'
|
|
19
|
+
|
|
20
|
+
# Load deploy
|
|
21
|
+
load 'config/deploy'
|
|
22
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#
|
|
2
|
+
# This file is auto-generated from Capgen
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
set :application, "<%= application %>"
|
|
6
|
+
set :repository, "<%= repository %>"
|
|
7
|
+
set :user, "<%= user %>"
|
|
8
|
+
set :bootstrap_user, Proc.new { Capistrano::CLI.ui.ask('Bootstrap user: ') }
|
|
9
|
+
|
|
10
|
+
set :deploy_via, :copy
|
|
11
|
+
set :copy_strategy, :export
|
|
12
|
+
|
|
13
|
+
# If you aren't deploying to /u/apps/#{application} on the target
|
|
14
|
+
# servers (which is the default), you can specify the actual location
|
|
15
|
+
# via the :deploy_to variable:
|
|
16
|
+
set :deploy_to, "<%= deploy_to %>"
|
|
17
|
+
|
|
18
|
+
# If you aren't using Subversion to manage your source code, specify
|
|
19
|
+
# your SCM below:
|
|
20
|
+
# set :scm, :subversion
|
|
21
|
+
|
|
22
|
+
role :web, "<%= web_host %>", :primary => true
|
|
23
|
+
role :db, "<%= db_host %>"
|
|
24
|
+
|
|
25
|
+
# How many releases to keep
|
|
26
|
+
# set :keep_releases, 3
|
|
27
|
+
|
|
28
|
+
#
|
|
29
|
+
# Other variables accessible in recipes
|
|
30
|
+
#
|
|
31
|
+
|
|
32
|
+
set :db_user, "<%= db_user %>"
|
|
33
|
+
set :db_pass, "<%= db_pass %>"
|
|
34
|
+
set :db_name, "<%= db_name %>"
|
|
35
|
+
set :db_host, "<%= db_host %>"
|
|
36
|
+
set :db_port, "<%= db_port %>"
|
|
37
|
+
set :sphinx_host, "<%= sphinx_host %>"
|
|
38
|
+
set :sphinx_port, "<%= sphinx_port %>"
|
|
39
|
+
|
|
40
|
+
set :mongrel_port, "<%= mongrel_port %>"
|
|
41
|
+
set :mongrel_size, "<%= mongrel_size %>"
|
|
42
|
+
set :domain_name, "<%= domain_name %>"
|
|
43
|
+
set :web_host, "<%= web_host %>"
|
|
44
|
+
set :db_host, "<%= db_host %>"
|
|
45
|
+
|
|
46
|
+
set :mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password: ') }
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# Callbacks
|
|
50
|
+
#
|
|
51
|
+
<% recipes["before_setup"].each do |recipe| %>
|
|
52
|
+
before "deploy:setup", "<%= recipe %>"<% end %>
|
|
53
|
+
|
|
54
|
+
<% recipes["after_setup"].each do |recipe| %>
|
|
55
|
+
after "deploy:setup", "<%= recipe %>"<% end %>
|
|
56
|
+
|
|
57
|
+
<% recipes["after_update_code"].each do |recipe| %>
|
|
58
|
+
after "deploy:update_code", "<%= recipe %>"<% end %>
|
|
59
|
+
|
|
60
|
+
# Auto cleanup after deploy?
|
|
61
|
+
after "deploy", "deploy:cleanup"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
trap ERROR ERR
|
|
5
|
+
|
|
6
|
+
# Add admin group
|
|
7
|
+
cat /etc/group | grep admin || /usr/sbin/groupadd admin
|
|
8
|
+
|
|
9
|
+
# Install sudoers
|
|
10
|
+
install -o root -m 440 /tmp/sudoers /etc/sudoers
|
|
11
|
+
rm -f /tmp/sudoers
|
|
12
|
+
|
|
13
|
+
# Change inittab to runlevel 3
|
|
14
|
+
sed -i -e 's/^id:5:initdefault:/id:3:initdefault:/g' /etc/inittab
|
|
15
|
+
|
|
16
|
+
# Create web apps directory
|
|
17
|
+
mkdir -p /var/www/apps
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
## Sudoers allows particular users to run various commands as
|
|
2
|
+
## the root user, without needing the root password.
|
|
3
|
+
##
|
|
4
|
+
## Examples are provided at the bottom of the file for collections
|
|
5
|
+
## of related commands, which can then be delegated out to particular
|
|
6
|
+
## users or groups.
|
|
7
|
+
##
|
|
8
|
+
## This file must be edited with the 'visudo' command.
|
|
9
|
+
|
|
10
|
+
## Host Aliases
|
|
11
|
+
## Groups of machines. You may prefer to use hostnames (perhap using
|
|
12
|
+
## wildcards for entire domains) or IP addresses instead.
|
|
13
|
+
# Host_Alias FILESERVERS = fs1, fs2
|
|
14
|
+
# Host_Alias MAILSERVERS = smtp, smtp2
|
|
15
|
+
|
|
16
|
+
## User Aliases
|
|
17
|
+
## These aren't often necessary, as you can use regular groups
|
|
18
|
+
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
|
|
19
|
+
## rather than USERALIAS
|
|
20
|
+
# User_Alias ADMINS = jsmith, mikem
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Command Aliases
|
|
24
|
+
## These are groups of related commands...
|
|
25
|
+
|
|
26
|
+
## Networking
|
|
27
|
+
Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
|
|
28
|
+
|
|
29
|
+
## Installation and management of software
|
|
30
|
+
Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
|
|
31
|
+
|
|
32
|
+
## Services
|
|
33
|
+
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
|
|
34
|
+
|
|
35
|
+
## Updating the locate database
|
|
36
|
+
Cmnd_Alias LOCATE = /usr/sbin/updatedb
|
|
37
|
+
|
|
38
|
+
## Storage
|
|
39
|
+
Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount
|
|
40
|
+
|
|
41
|
+
## Delegating permissions
|
|
42
|
+
Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp
|
|
43
|
+
|
|
44
|
+
## Processes
|
|
45
|
+
Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall
|
|
46
|
+
|
|
47
|
+
## Drivers
|
|
48
|
+
Cmnd_Alias DRIVERS = /sbin/modprobe
|
|
49
|
+
|
|
50
|
+
# Defaults specification
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
# Disable "ssh hostname sudo <cmd>", because it will show the password in clear.
|
|
54
|
+
# You have to run "ssh -t hostname sudo <cmd>".
|
|
55
|
+
#
|
|
56
|
+
#Defaults requiretty
|
|
57
|
+
|
|
58
|
+
Defaults env_reset
|
|
59
|
+
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
|
|
60
|
+
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
|
|
61
|
+
LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
|
|
62
|
+
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
|
|
63
|
+
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
|
|
64
|
+
_XKB_CHARSET XAUTHORITY"
|
|
65
|
+
|
|
66
|
+
## Next comes the main part: which users can run what software on
|
|
67
|
+
## which machines (the sudoers file can be shared between multiple
|
|
68
|
+
## systems).
|
|
69
|
+
## Syntax:
|
|
70
|
+
##
|
|
71
|
+
## user MACHINE=COMMANDS
|
|
72
|
+
##
|
|
73
|
+
## The COMMANDS section may have other options added to it.
|
|
74
|
+
##
|
|
75
|
+
## Allow root to run any commands anywhere
|
|
76
|
+
root ALL=(ALL) ALL
|
|
77
|
+
%admin ALL=(ALL) ALL
|
|
78
|
+
|
|
79
|
+
## Allows members of the 'sys' group to run networking, software,
|
|
80
|
+
## service management apps and more.
|
|
81
|
+
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
|
|
82
|
+
|
|
83
|
+
## Allows people in group wheel to run all commands
|
|
84
|
+
# %wheel ALL=(ALL) ALL
|
|
85
|
+
|
|
86
|
+
## Same thing without a password
|
|
87
|
+
# %wheel ALL=(ALL) NOPASSWD: ALL
|
|
88
|
+
|
|
89
|
+
## Allows members of the users group to mount and unmount the
|
|
90
|
+
## cdrom as root
|
|
91
|
+
# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
|
|
92
|
+
|
|
93
|
+
## Allows members of the users group to shutdown this system
|
|
94
|
+
# %users localhost=/sbin/shutdown -h now
|
|
95
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
trap ERROR ERR
|
|
5
|
+
|
|
6
|
+
cd /tmp
|
|
7
|
+
|
|
8
|
+
wget -nv ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
|
|
9
|
+
|
|
10
|
+
tar zxpf ImageMagick.tar.gz
|
|
11
|
+
cd ImageMagick-*
|
|
12
|
+
echo "Configuring ImageMagick..."
|
|
13
|
+
./configure > configure.log
|
|
14
|
+
echo "Compiling ImageMagick..."
|
|
15
|
+
make > make.log
|
|
16
|
+
echo "Installing ImageMagick..."
|
|
17
|
+
make install > make_install.log
|
|
18
|
+
|
|
19
|
+
cd ..
|
|
20
|
+
rm -rf ImageMagick*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
trap ERROR ERR
|
|
5
|
+
|
|
6
|
+
cd /tmp
|
|
7
|
+
|
|
8
|
+
wget -nv http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz
|
|
9
|
+
|
|
10
|
+
tar zxpf memcached-1.2.4.tar.gz
|
|
11
|
+
|
|
12
|
+
cd memcached-1.2.4
|
|
13
|
+
echo "Configuring memcached..."
|
|
14
|
+
./configure --prefix=/usr/local > configure.log
|
|
15
|
+
echo "Compiling memcached..."
|
|
16
|
+
make > make.log
|
|
17
|
+
echo "Installing memcached..."
|
|
18
|
+
make install > make_install.log
|
|
19
|
+
|
|
20
|
+
cd ..
|
|
21
|
+
rm -rf memcached-1.2.4*
|
|
22
|
+
|
|
23
|
+
install -o root /tmp/memcached.initd /etc/init.d/memcached
|
|
24
|
+
rm -f /tmp/memcached.initd
|
|
25
|
+
/sbin/chkconfig --level 345 memcached on
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
# memcached: Memcached
|
|
3
|
+
#
|
|
4
|
+
# chkconfig: - 86 14
|
|
5
|
+
# description: memcached
|
|
6
|
+
# processname: memcached
|
|
7
|
+
#
|
|
8
|
+
# Author: Gabriel Handford http://ducktyper.com
|
|
9
|
+
|
|
10
|
+
# Source function library
|
|
11
|
+
. /etc/rc.d/init.d/functions
|
|
12
|
+
|
|
13
|
+
RETVAL=0
|
|
14
|
+
|
|
15
|
+
DESC="memcached"
|
|
16
|
+
NAME="memcached"
|
|
17
|
+
DAEMON=/usr/local/bin/memcached
|
|
18
|
+
PIDFILE=<%= memcached_pid_path %>
|
|
19
|
+
MEM=<%= memcached_memory %>
|
|
20
|
+
PORT=<%= memcached_port %>
|
|
21
|
+
# Have to be root in order to save in /var/run
|
|
22
|
+
USER=root
|
|
23
|
+
|
|
24
|
+
start() {
|
|
25
|
+
daemon $DAEMON -d -m $MEM -p $PORT -u $USER -P $PIDFILE
|
|
26
|
+
RETVAL=$?
|
|
27
|
+
echo
|
|
28
|
+
return $RETVAL;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
stop() {
|
|
32
|
+
kill -QUIT `cat $PIDFILE` || echo -n " not running"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
reload() {
|
|
36
|
+
kill -HUP `cat $PIDFILE` || echo -n " can't reload"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
case "$1" in
|
|
40
|
+
start)
|
|
41
|
+
echo -n "Starting $DESC: $NAME"
|
|
42
|
+
start
|
|
43
|
+
RETVAL=$?;
|
|
44
|
+
;;
|
|
45
|
+
stop)
|
|
46
|
+
echo "Stopping $DESC: $NAME"
|
|
47
|
+
stop
|
|
48
|
+
RETVAL=$?;
|
|
49
|
+
;;
|
|
50
|
+
reload)
|
|
51
|
+
echo -n "Reloading $DESC configuration..."
|
|
52
|
+
reload
|
|
53
|
+
RETVAL=$?;
|
|
54
|
+
echo "reloaded."
|
|
55
|
+
;;
|
|
56
|
+
restart)
|
|
57
|
+
echo -n "Restarting $DESC: $NAME"
|
|
58
|
+
stop
|
|
59
|
+
# Sleep after stop
|
|
60
|
+
sleep 1
|
|
61
|
+
start
|
|
62
|
+
RETVAL=$?;
|
|
63
|
+
;;
|
|
64
|
+
*)
|
|
65
|
+
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
|
|
66
|
+
RETVAL=3;
|
|
67
|
+
;;
|
|
68
|
+
esac
|
|
69
|
+
|
|
70
|
+
exit $RETVAL;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
|
|
4
|
+
#
|
|
5
|
+
# mongrel_cluster_<%= application %> Startup script for Mongrel clusters (<%= application %>)
|
|
6
|
+
#
|
|
7
|
+
# chkconfig: - 85 15
|
|
8
|
+
# description: mongrel_cluster_<%= application %> manages multiple Mongrel processes for use \
|
|
9
|
+
# behind a load balancer.
|
|
10
|
+
#
|
|
11
|
+
# Modified by: Gabriel Handford http://ducktyper.com
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
trap ERROR ERR
|
|
16
|
+
|
|
17
|
+
CONF_DIR=<%= mongrel_config_path %>
|
|
18
|
+
PID_DIR=<%= pid_path %>
|
|
19
|
+
USER=<%= user %>
|
|
20
|
+
|
|
21
|
+
RETVAL=0
|
|
22
|
+
|
|
23
|
+
fail() {
|
|
24
|
+
echo "Failed to start: $1"
|
|
25
|
+
exit 1
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Gracefully exit if the controller is missing.
|
|
29
|
+
which mongrel_cluster_ctl >/dev/null || fail "mongrel_cluster_ctl not found"
|
|
30
|
+
|
|
31
|
+
# Go no further if config directory is missing.
|
|
32
|
+
[ -d "$CONF_DIR" ] || fail "$CONF_DIR not found"
|
|
33
|
+
|
|
34
|
+
case "$1" in
|
|
35
|
+
start)
|
|
36
|
+
# Create pid directory
|
|
37
|
+
mkdir -p $PID_DIR
|
|
38
|
+
chown $USER:$USER $PID_DIR
|
|
39
|
+
|
|
40
|
+
mongrel_cluster_ctl start -c $CONF_DIR --clean
|
|
41
|
+
RETVAL=$?
|
|
42
|
+
;;
|
|
43
|
+
stop)
|
|
44
|
+
mongrel_cluster_ctl stop -c $CONF_DIR
|
|
45
|
+
RETVAL=$?
|
|
46
|
+
;;
|
|
47
|
+
restart)
|
|
48
|
+
mongrel_cluster_ctl restart -c $CONF_DIR
|
|
49
|
+
RETVAL=$?
|
|
50
|
+
;;
|
|
51
|
+
status)
|
|
52
|
+
mongrel_cluster_ctl status -c $CONF_DIR
|
|
53
|
+
RETVAL=$?
|
|
54
|
+
;;
|
|
55
|
+
*)
|
|
56
|
+
echo "Usage: $0 {start|stop|restart|status}"
|
|
57
|
+
exit 1
|
|
58
|
+
;;
|
|
59
|
+
esac
|
|
60
|
+
|
|
61
|
+
exit $RETVAL
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<% processes.each do |process| %>
|
|
2
|
+
|
|
3
|
+
check process mongrel_cluster_<%= application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
|
|
4
|
+
group mongrel_cluster_<%= application %>
|
|
5
|
+
start program = "<%= process[:name] %> start <%= process[:start_options] %>"
|
|
6
|
+
stop program = "<%= process[:name] %> stop <%= process[:stop_options] %>"
|
|
7
|
+
if failed host 127.0.0.1 port <%= process[:port] %> protocol http
|
|
8
|
+
and request "/" then alert
|
|
9
|
+
if totalmem > 100 Mb then restart
|
|
10
|
+
if cpu is greater than 60% for 2 cycles then alert
|
|
11
|
+
if cpu > 80% for 5 cycles then restart
|
|
12
|
+
if loadavg(5min) greater than 10 for 8 cycles then restart
|
|
13
|
+
if 3 restarts within 5 cycles then timeout
|
|
14
|
+
|
|
15
|
+
<% end %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
trap ERROR ERR
|
|
5
|
+
|
|
6
|
+
mkdir -p /var/certs
|
|
7
|
+
mv /tmp/monit.cnf /var/certs/monit.cnf
|
|
8
|
+
|
|
9
|
+
echo "Generating PEM..."
|
|
10
|
+
openssl req -new -x509 -days 365 -nodes -config /var/certs/monit.cnf -out /var/certs/monit.pem -keyout /var/certs/monit.pem -batch > debug_req.log
|
|
11
|
+
openssl gendh 512 >> /var/certs/monit.pem
|
|
12
|
+
echo "Generating x509..."
|
|
13
|
+
openssl x509 -subject -dates -fingerprint -noout -in /var/certs/monit.pem > debug_x509.log
|
|
14
|
+
chmod 700 /var/certs/monit.pem
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
trap ERROR ERR
|
|
5
|
+
|
|
6
|
+
cd /tmp
|
|
7
|
+
|
|
8
|
+
wget -nv http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz
|
|
9
|
+
|
|
10
|
+
tar zxpf monit-4.10.1.tar.gz
|
|
11
|
+
|
|
12
|
+
cd monit-4.10.1
|
|
13
|
+
echo "Configuring monit..."
|
|
14
|
+
./configure > configure.log
|
|
15
|
+
echo "Compiling monit..."
|
|
16
|
+
make > make.log
|
|
17
|
+
echo "Installing monit..."
|
|
18
|
+
make install > make_install.log
|
|
19
|
+
|
|
20
|
+
cd ..
|
|
21
|
+
rm -rf monit-4.10.1*
|
|
22
|
+
|
|
23
|
+
mkdir -p /etc/monit
|
|
24
|
+
|
|
25
|
+
install -o root -m 700 /tmp/monitrc /etc/monitrc
|
|
26
|
+
rm -f /tmp/monitrc
|
|
27
|
+
|
|
28
|
+
install -o root /tmp/monit.initd /etc/init.d/monit
|
|
29
|
+
rm -f /tmp/monit.initd
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# create RSA certs - Server
|
|
2
|
+
|
|
3
|
+
RANDFILE = /var/certs/openssl.rnd
|
|
4
|
+
|
|
5
|
+
[ req ]
|
|
6
|
+
default_bits = 1024
|
|
7
|
+
encrypt_key = yes
|
|
8
|
+
distinguished_name = req_dn
|
|
9
|
+
x509_extensions = cert_type
|
|
10
|
+
|
|
11
|
+
[ req_dn ]
|
|
12
|
+
countryName = Country Name (2 letter code)
|
|
13
|
+
countryName_default = US
|
|
14
|
+
|
|
15
|
+
stateOrProvinceName = State or Province Name (full name)
|
|
16
|
+
stateOrProvinceName_default = Washington DC
|
|
17
|
+
|
|
18
|
+
localityName = Locality Name (eg, city)
|
|
19
|
+
localityName_default = Washington DC
|
|
20
|
+
|
|
21
|
+
organizationName = Organization Name (eg, company)
|
|
22
|
+
organizationName_default = Revolution
|
|
23
|
+
|
|
24
|
+
organizationalUnitName = Organizational Unit Name (eg, section)
|
|
25
|
+
organizationalUnitName_default = Ninjas
|
|
26
|
+
|
|
27
|
+
commonName = Common Name (FQDN of your server)
|
|
28
|
+
commonName_default = localhost
|
|
29
|
+
|
|
30
|
+
emailAddress = Email Address
|
|
31
|
+
emailAddress_default = gabrielh@gmail.com
|
|
32
|
+
|
|
33
|
+
[ cert_type ]
|
|
34
|
+
nsCertType = server
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
# monit: Monit
|
|
3
|
+
#
|
|
4
|
+
# chkconfig: - 86 14
|
|
5
|
+
# description: monit
|
|
6
|
+
# processname: monit
|
|
7
|
+
#
|
|
8
|
+
# Author: Gabriel Handford http://ducktyper.com
|
|
9
|
+
|
|
10
|
+
# Source function library
|
|
11
|
+
. /etc/rc.d/init.d/functions
|
|
12
|
+
|
|
13
|
+
RETVAL=0
|
|
14
|
+
|
|
15
|
+
DESC="monit"
|
|
16
|
+
NAME=monit
|
|
17
|
+
DAEMON=/usr/local/bin/monit
|
|
18
|
+
CONFFILE=/etc/monitrc
|
|
19
|
+
LOGFILE=/var/log/monit.log
|
|
20
|
+
PIDFILE=/var/run/monit.pid
|
|
21
|
+
|
|
22
|
+
start() {
|
|
23
|
+
daemon $DAEMON -l $LOGFILE -p $PIDFILE -c $CONFFILE
|
|
24
|
+
RETVAL=$?
|
|
25
|
+
echo
|
|
26
|
+
return $RETVAL;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
stop() {
|
|
30
|
+
kill -QUIT `cat $PIDFILE` || echo -n " not running"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
reload() {
|
|
34
|
+
kill -HUP `cat $PIDFILE` || echo -n " can't reload"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
case "$1" in
|
|
38
|
+
start)
|
|
39
|
+
#echo -n "Starting $DESC: $NAME"
|
|
40
|
+
start
|
|
41
|
+
RETVAL=$?;
|
|
42
|
+
;;
|
|
43
|
+
stop)
|
|
44
|
+
echo "Stopping $DESC: $NAME"
|
|
45
|
+
stop
|
|
46
|
+
RETVAL=$?;
|
|
47
|
+
;;
|
|
48
|
+
reload)
|
|
49
|
+
echo -n "Reloading $DESC configuration..."
|
|
50
|
+
reload
|
|
51
|
+
RETVAL=$?;
|
|
52
|
+
echo "reloaded."
|
|
53
|
+
;;
|
|
54
|
+
restart)
|
|
55
|
+
echo -n "Restarting $DESC: $NAME"
|
|
56
|
+
stop
|
|
57
|
+
# Sleep after stop
|
|
58
|
+
sleep 1
|
|
59
|
+
start
|
|
60
|
+
RETVAL=$?;
|
|
61
|
+
;;
|
|
62
|
+
*)
|
|
63
|
+
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
|
|
64
|
+
RETVAL=3;
|
|
65
|
+
;;
|
|
66
|
+
esac
|
|
67
|
+
|
|
68
|
+
exit $RETVAL;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
set daemon 60
|
|
2
|
+
set logfile syslog facility log_daemon
|
|
3
|
+
set mailserver localhost
|
|
4
|
+
set mail-format { from: monit@localhost }
|
|
5
|
+
set alert root@localhost
|
|
6
|
+
|
|
7
|
+
# Http settings
|
|
8
|
+
# ---------------------------
|
|
9
|
+
|
|
10
|
+
set httpd port <%= monit_port %>
|
|
11
|
+
ssl enable
|
|
12
|
+
pemfile /var/certs/monit.pem
|
|
13
|
+
allow admin:<%= monit_password %>
|
|
14
|
+
|
|
15
|
+
# Core processes
|
|
16
|
+
# ---------------------------
|
|
17
|
+
|
|
18
|
+
check process sshd with pidfile /var/run/sshd.pid
|
|
19
|
+
start program "/sbin/service sshd start"
|
|
20
|
+
stop program "/sbin/service sshd stop"
|
|
21
|
+
if failed port 22 protocol ssh then restart
|
|
22
|
+
if 5 restarts within 5 cycles then timeout
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Includes
|
|
26
|
+
# ---------------------------
|
|
27
|
+
|
|
28
|
+
include /etc/monit/*.monitrc
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
trap ERROR ERR
|
|
5
|
+
|
|
6
|
+
NO_MONIT=0
|
|
7
|
+
grep -q monit /etc/inittab > /dev/null || export NO_MONIT=1
|
|
8
|
+
|
|
9
|
+
if [ $NO_MONIT == 1 ]; then
|
|
10
|
+
echo "Patching inittab with monit..."
|
|
11
|
+
echo "" >> /etc/inittab
|
|
12
|
+
echo "# Run monit in standard run-levels" >> /etc/inittab
|
|
13
|
+
echo "mo:345:respawn:/usr/local/bin/monit -Ic /etc/monitrc -l /var/log/monit.log -p /var/run/monit.pid" >> /etc/inittab
|
|
14
|
+
telinit q
|
|
15
|
+
fi
|