citrin 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2)
10
+ rcov (0.9.10)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.6.4)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Mike
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
File without changes
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = citrin
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to citrin
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Mike. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "citrin"
18
+ gem.homepage = "http://github.com/servasat/citrin"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Client for citrin RailsServer management}
21
+ gem.description = %Q{This Gem helps you manage your citrin RailsServer (http://www.rails-server.ch). It creates or deletes Apache Configuration, MySQL Databases and Subversion Repositories.}
22
+ gem.email = "mike@citrin.ch"
23
+ gem.authors = ["Mike"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "citrin #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
data/bin/citrin ADDED
@@ -0,0 +1,9 @@
1
+ require "pathname"
2
+ bin_file = Pathname.new(__FILE__).realpath
3
+
4
+ $:.unshift File.expand_path("../lib", bin_file)
5
+
6
+
7
+
8
+ require "citrin/cli"
9
+ Citrin::CLI.start(*ARGV)
data/citrin.gemspec ADDED
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{citrin}
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Mike}]
12
+ s.date = %q{2012-01-11}
13
+ s.description = %q{This Gem helps you manage your citrin RailsServer (http://www.rails-server.ch). It creates or deletes Apache Configuration, MySQL Databases and Subversion Repositories.}
14
+ s.email = %q{mike@citrin.ch}
15
+ s.executables = [%q{citrin}]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/citrin",
31
+ "citrin.gemspec",
32
+ "commands/create_database",
33
+ "commands/create_svn",
34
+ "commands/create_webserver",
35
+ "commands/help",
36
+ "lib/citrin.rb",
37
+ "lib/citrin/cli.rb",
38
+ "test/helper.rb",
39
+ "test/test_citrin.rb"
40
+ ]
41
+ s.homepage = %q{http://github.com/servasat/citrin}
42
+ s.licenses = [%q{MIT}]
43
+ s.require_paths = [%q{lib}]
44
+ s.rubygems_version = %q{1.8.7}
45
+ s.summary = %q{Client for citrin RailsServer management}
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
54
+ s.add_development_dependency(%q<rcov>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<shoulda>, [">= 0"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
59
+ s.add_dependency(%q<rcov>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<shoulda>, [">= 0"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
65
+ s.add_dependency(%q<rcov>, [">= 0"])
66
+ end
67
+ end
68
+
@@ -0,0 +1,54 @@
1
+ #!/bin/bash
2
+
3
+ dbuser=$(grep mysql-user /etc/citrin/citrin.conf | split -d"=" -f 2)
4
+ dbpwd=$(grep mysql-password /etc/citrin/citrin.conf | split -d"=" -f 2 )
5
+ name=#{args[0]}
6
+ env=#{args[1]}
7
+ if [ -z $name ] ; then
8
+ echo "usage: $0 appname [env]"
9
+ exit 1;
10
+ fi
11
+ if [ -z $env ] ; then
12
+ env="prod"
13
+ fi
14
+
15
+ if [ $env != "prod" -a $env != "dev" -a $env != "test" ]; then
16
+ echo "usage: $0 appname env"
17
+ echo "Options for env: prod dev test"
18
+ exit 2;
19
+ fi
20
+
21
+ db_name="${name}_$env"
22
+ db_user="${name}_$env"
23
+ db_user_pw=$(pwgen -1)
24
+ mysql --user $dbuser --password=$dbpwd -e "create database $db_name;"
25
+ #echo "Database $db_name created"
26
+
27
+ mysql --user $dbuser --password=$dbpwd -e "GRANT ALL ON $db_user.* TO '$db_name'@'localhost';"
28
+ mysql --user $dbuser --password=$dbpwd -e "SET PASSWORD FOR '$db_user'@'localhost' = PASSWORD('$db_user_pw');"
29
+ #echo "User $db_user with password $db_user_pw created"
30
+
31
+
32
+ echo "Put this in your config/database.yml"
33
+
34
+ if [ $env = "prod" ]; then
35
+ fullenv="production"
36
+ elif [ $env = "dev" ]; then
37
+ fullenv="development"
38
+ elif [ $env = "test" ]; then
39
+ fullenv="test"
40
+ else
41
+ echo "Invalid Env"
42
+ exit 3
43
+ fi
44
+
45
+ echo "$fullenv:"
46
+ echo " adapter: mysql2"
47
+ echo " encoding: utf8"
48
+ echo " database: $db_name"
49
+ echo " username: $db_user"
50
+ echo " password: $db_user_pw"
51
+
52
+ echo ""
53
+ echo "and run"
54
+ echo " RAILS_ENV=$fullenv rake db:migrate"
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ name=$1
3
+
4
+ if [ -z $name ] ; then
5
+ echo "usage: $0 appname [env]"
6
+ exit 1;
7
+ fi
8
+ proj_owner=www-data
9
+ svn_path=/var/svn/$name/
10
+ function create_svn {
11
+ echo "CREATING SVN"
12
+ svnadmin create $svn_path
13
+ chown -R $proj_owner.www-data $svn_path
14
+
15
+ echo "svn co svn+ssh://root@$(hostname -f)$svn_path"
16
+ }
17
+
18
+ create_svn
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+
3
+ name=$1
4
+ env=$2
5
+ prod_path="/var/www/rails_apps/prod/"
6
+ dev_path="/var/www/rails_apps/dev/"
7
+ path="$dev_path$name"
8
+ if [ -z $name ] ; then
9
+ echo "usage: $0 appname [environment]"
10
+ exit 1;
11
+ fi
12
+ if [ -e $path ] ; then
13
+ echo "Project already exits in $path";
14
+ exit 2;
15
+ fi
16
+
17
+ if [ -z $env ] ; then
18
+ env="prod"
19
+ fi
20
+
21
+ if [ $env != "prod" -a $env != "dev" ]; then
22
+ echo "usage: $0 dbname env"
23
+ echo "Options for env: prod dev"
24
+ exit 3;
25
+ fi
26
+
27
+
28
+
29
+ function configure_apache {
30
+ if [ $env = "prod" ]; then
31
+ conf_template="/etc/apache2/templates/prod_rails.conf"
32
+ conffile="/etc/apache2/sites-enabled/prod.$name.conf"
33
+ url=$name.$(hostname -f)
34
+ app_root=/var/www/rails_apps/prod/$name
35
+ elif [ $env = "dev" ]; then
36
+ conf_template="/etc/apache2/templates/dev_rails.conf"
37
+ conffile="/etc/apache2/sites-enabled/dev.$name.conf"
38
+ url=dev.$name.$(hostname -f)
39
+ app_root=/var/www/rails_apps/dev/$name
40
+ else
41
+ echo "Invalid Env"
42
+ exit 3
43
+ fi
44
+
45
+ cp -p $conf_template $conffile
46
+ sed_str=$(echo $app_root | sed -e 's/\(\/\|\\\|&\)/\\&/g')
47
+ sed -i "s/PROJECT_ROOT/$sed_str/g" $conffile
48
+ sed -i "s/URL/$url/g" $conffile
49
+
50
+ service apache2 reload 2>&1 > /dev/null
51
+
52
+
53
+ echo ""
54
+ echo "Apache VirtualHost Konfiguration unter: $conffile"
55
+ echo "App Root unter: $app_root"
56
+ echo "URL: http://$url"
57
+
58
+ }
59
+
60
+ configure_apache
data/commands/help ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ echo "Usage: citrin command [args]
3
+ Commands are:
4
+ create_database appname
5
+ create_webserver appname
6
+ create_svn appname"
data/lib/citrin/cli.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'citrin'
2
+
3
+ class Citrin::CLI
4
+
5
+ def self.start(*args)
6
+ command = args.shift.strip rescue "help"
7
+ puts `#{File.dirname(__FILE__)}/../../commands/#{command} #{args}`
8
+ end
9
+
10
+ end
data/lib/citrin.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Citrin
2
+ def self.do
3
+ "Hello World from the all mighty helloworld Gem!"
4
+ end
5
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'citrin'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestCitrin < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: citrin
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Mike
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-11 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: shoulda
22
+ prerelease: false
23
+ type: :development
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: bundler
36
+ prerelease: false
37
+ type: :development
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 23
44
+ segments:
45
+ - 1
46
+ - 0
47
+ - 0
48
+ version: 1.0.0
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: jeweler
52
+ prerelease: false
53
+ type: :development
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 7
60
+ segments:
61
+ - 1
62
+ - 6
63
+ - 4
64
+ version: 1.6.4
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: rcov
68
+ prerelease: false
69
+ type: :development
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ version_requirements: *id004
80
+ description: This Gem helps you manage your citrin RailsServer (http://www.rails-server.ch). It creates or deletes Apache Configuration, MySQL Databases and Subversion Repositories.
81
+ email: mike@citrin.ch
82
+ executables:
83
+ - citrin
84
+ extensions: []
85
+
86
+ extra_rdoc_files:
87
+ - LICENSE.txt
88
+ - README
89
+ - README.rdoc
90
+ files:
91
+ - .document
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README
96
+ - README.rdoc
97
+ - Rakefile
98
+ - VERSION
99
+ - bin/citrin
100
+ - citrin.gemspec
101
+ - commands/create_database
102
+ - commands/create_svn
103
+ - commands/create_webserver
104
+ - commands/help
105
+ - lib/citrin.rb
106
+ - lib/citrin/cli.rb
107
+ - test/helper.rb
108
+ - test/test_citrin.rb
109
+ homepage: http://github.com/servasat/citrin
110
+ licenses:
111
+ - MIT
112
+ post_install_message:
113
+ rdoc_options: []
114
+
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
125
+ version: "0"
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ requirements: []
136
+
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.7
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Client for citrin RailsServer management
142
+ test_files: []
143
+