-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2eb8371
Showing
14 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.gem | ||
.bundle | ||
.idea | ||
Gemfile.lock | ||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in geordi.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
H1 | ||
== | ||
|
||
H2 | ||
-- | ||
|
||
foo | ||
|
||
bar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
sudo a2dissite \*; sudo a2ensite default $1 && sudo apache2ctl restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
|
||
call = ARGV.dup | ||
call = ['bundle', 'exec'] + call if File.exists?('Gemfile') | ||
exec *call | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env ruby | ||
|
||
fail_gently = ARGV.include?("--fail-gently") | ||
|
||
if ARGV.include?("-i") | ||
puts "*******************************************************" | ||
puts | ||
system("du -sh ~/dumps") | ||
puts | ||
puts "*******************************************************" | ||
exit | ||
end | ||
|
||
require "yaml" | ||
|
||
config_path = 'config/database.yml' | ||
unless File.exist?(config_path) | ||
if fail_gently | ||
puts "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" | ||
puts "* *" | ||
puts "* *" | ||
puts "* Script is not called from inside a Rails project, *" | ||
puts "* *" | ||
puts "* THE DATABASE WILL NOT BE DUMPED. *" | ||
puts "* *" | ||
puts "* *" | ||
puts "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" | ||
sleep 5 | ||
exit | ||
else | ||
raise "Call me from inside a Rails project." | ||
end | ||
end | ||
config = YAML::load(File.open(config_path)) | ||
|
||
environment = ARGV.reject{ |arg| arg[0].chr == '-' }.first || 'production' | ||
config = config[environment] or raise "No production environment found. Please do `dumple [env_name]`" | ||
|
||
dump_dir = "#{ENV['HOME']}/dumps" | ||
unless File.directory?(dump_dir) | ||
Dir.mkdir(dump_dir) | ||
system("chmod 700 #{dump_dir}") | ||
end | ||
dump_path = "#{dump_dir}/#{config['database']}_#{Time.now.strftime("%Y%m%d_%H%M%S")}.dump" | ||
|
||
puts | ||
puts "Dumping database for environment \"#{environment}\"..." | ||
|
||
system "mysqldump -u\"#{config['username']}\" -p\"#{config['password']}\" #{config['database']} -r #{dump_path}" | ||
system "chmod 600 #{dump_path}" | ||
|
||
dump_size_kb = (File.size(dump_path) / 1024).round | ||
|
||
puts "Dumped to #{dump_path} (#{dump_size_kb} KB)" | ||
puts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
if ls vendor/gems/*/*.gemspec > /dev/null 2>&1; then | ||
tar cf tmp/gemfiles_for_remote_install Gemfile Gemfile.lock vendor/gems/*/*.gemspec | ||
else | ||
tar cf tmp/gemfiles_for_remote_install Gemfile Gemfile.lock | ||
fi | ||
scp tmp/gemfiles_for_remote_install $1:~ | ||
stty_orig=`stty -g` | ||
stty -echo | ||
ssh -t $1 "mkdir /tmp/install_gems; mv gemfiles_for_remote_install /tmp/install_gems; cd /tmp/install_gems; tar xf gemfiles_for_remote_install; bundle install; rm -rf /tmp/install_gems" | ||
stty $stty_orig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
cap $1 deploy && cap $1 deploy:migrate && cap $1 deploy:restart | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env ruby | ||
|
||
for env in ['development', 'test', 'cucumber', 'performance'] | ||
if File.exists? "config/environments/#{env}.rb" | ||
call = ['rake'] + ARGV + ["RAILS_ENV=#{env}"] | ||
puts call.join(' ') | ||
system *call | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env ruby | ||
|
||
branch = ARGV[0] or raise "Need the branch name as first argument" | ||
|
||
`git status`.include?('working directory clean') or raise 'Dirty working directory. Nothing was pushed.' | ||
`git checkout #{branch}` | ||
`git push origin #{branch}` | ||
`git config branch.#{branch}.remote origin` | ||
`git config branch.#{branch}.merge #{branch}` | ||
|
||
puts "#{branch} is now tracking origin/#{branch}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
echo "Removing execute flags:" | ||
for pattern in *.rb *.html *.erb *.haml *.yml *.css *.sass *.rake *.png *.jpg *.gif *.pdf *.txt *.rdoc Rakefile VERSION README Capfile | ||
do | ||
echo "- $pattern" | ||
find . -name "$pattern" -exec chmod -x {} \; | ||
done | ||
echo "Done." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env ruby | ||
|
||
def quoted_text(line) | ||
line.match(/["'].*["']/).to_s.gsub(/["']/, '') | ||
end | ||
|
||
def read_deploy_files | ||
all_deploy_files = Dir["config/deploy/*.rb"] | ||
|
||
deploy_file = all_deploy_files.find do |file| | ||
file.match(/\/#{@stage}.rb$/) | ||
end | ||
raise "Unknown stage: #{@stage}" unless deploy_file | ||
|
||
@specific = File.open(deploy_file).readlines | ||
@for_all = File.open("config/deploy.rb").readlines | ||
end | ||
|
||
def build_command | ||
path = quoted_text(@deploy_to) + "/current" | ||
|
||
@command = "ssh #{quoted_text(@user)}@#{quoted_text(@server)}" | ||
@command += %( -t "cd #{path} && bash --login") unless path.match /#\{/ | ||
end | ||
|
||
begin | ||
@stage = ARGV.shift | ||
|
||
raise "Usage: shell_for DEPLOYMENT_STAGE" unless @stage | ||
raise "Run me from inside a Rails project" unless File.exists?("config/deploy.rb") | ||
|
||
read_deploy_files | ||
@user = @specific.find{ |line| line =~ /^set :user, /} || @for_all.find{ |line| line =~ /^set :user, / } | ||
@server = @specific.find{ |line| line =~ /^server / } || @for_all.find{ |line| line =~ /^server / } | ||
@deploy_to = @specific.find{ |line| line =~ /^set :deploy_to, /} || @for_all.find{ |line| line =~ /^set :deploy_to, / } | ||
|
||
build_command | ||
|
||
exec @command | ||
|
||
rescue Exception => e | ||
$stderr.puts e.message | ||
exit 1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "geordi/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "geordi" | ||
s.version = Geordi::VERSION | ||
s.platform = Gem::Platform::RUBY | ||
s.authors = ["Henning Koch"] | ||
s.email = ["henning.koch@makandra.de"] | ||
s.homepage = "http://makandra.com" | ||
s.summary = 'Collection of command line tools used in our daily work with Ruby, Rails and Linux.' | ||
s.description = 'Collection of command line tools used in our daily work with Ruby, Rails and Linux.' | ||
|
||
s.rubyforge_project = "geordi" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
end |