Class: Dolphin::Setup

Inherits:
Base
  • Object
show all
Defined in:
lib/dolphin/setup.rb

Overview

set up target servers

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dolphin::Base

Instance Method Details

#app_dirObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/dolphin/setup.rb', line 29

def app_dir
  menu = [
    "
      sudo mkdir -p #{@app_dir}
      sudo chown #{@user}:#{@user_group} #{@app_dir}
    ",
  ]

  execute menu
end

#bundlerObject



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/dolphin/setup.rb', line 112

def bundler
  menu = [
    "
      # install bundler
      cd #{@app_dir}
      sudo gem install bundler
    ",
  ]

  execute menu
end

#chruby(version = 'v0.3.7') ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dolphin/setup.rb', line 5

def chruby(version='v0.3.7')
  menu = [
    "
      # git clone
      if [ ! -d 'chruby' ]; then git clone https://github.com/postmodern/chruby.git ; fi
      cd chruby
      # update
      git fetch
      git checkout master
      git rebase origin/master
      # checkout tag
      git checkout #{version}
      # install
      sudo make install
      # system wise
      # sudo echo '[ -n \"$BASH_VERSION\" ] || [ -n \"$ZSH_VERSION\" ] || return' | sudo tee /etc/profile.d/chruby.sh
      # sudo echo 'source /usr/local/share/chruby/chruby.sh' | sudo tee -a /etc/profile.d/chruby.sh
    ",
  ]

  execute menu
end

#newrelicObject



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/dolphin/setup.rb', line 125

def newrelic
  menu = [
    "
      # install bundler
      sudo rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
      sudo yum -y install newrelic-sysmond
      sudo nrsysmond-config --set license_key=c55d35d552a49f06d5183c95d41de60cd9754237
    ",
  ]

  execute menu
end

#repoObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/dolphin/setup.rb', line 62

def repo
  # branch 'master' is always created by git
  if @branch == 'master'
    cmd = "git checkout master"
  else
    cmd = "git checkout -b #{@branch} origin/#{@branch}"
  end

  menu = [
    "
      # init git repository
      cd #{@app_dir}
      git clone #{@github}
    ",
    "
      # set up tracking branch
      cd #{@deploy_dir}
      #{cmd}
    ",
  ]

  execute menu
end

#ruby(version = "2.0.0-p247") ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/dolphin/setup.rb', line 87

def ruby(version="2.0.0-p247")
  menu = [
    "
      # install ruby
      sudo ruby-install ruby #{version}
    ",
  ]

  execute menu
end

#ruby_install(version = 'master') ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/dolphin/setup.rb', line 41

def ruby_install(version='master')
  menu = [
    "
      # git clone
      if [ ! -d 'ruby-install' ]; then git clone https://github.com/postmodern/ruby-install.git ; fi
      cd ruby-install
      # update
      git fetch
      git checkout master
      git rebase origin/master
      # checkout tag
      git checkout #{version}
      # install
      sudo make install
    ",
  ]

  execute menu
end

#select(version = "2.0.0-p247") ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/dolphin/setup.rb', line 99

def select(version="2.0.0-p247")
  menu = [
    "
      # select ruby
      cd #{@app_dir}
      echo ruby-#{version} > .ruby-version
    ",
  ]

  execute menu
end