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

#chruby(version = :master) ⇒ 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=:master)
  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

#gems(ruby = "ruby-2.3.0") ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/dolphin/setup.rb', line 129

def gems(ruby="ruby-2.3.0")
  menu = [
    %{
      cd #{@app_dir}
      # switch to the target ruby
      chruby #{ruby}
      # first gem-ctags so latter gems can be tagged
      gem install gem-ctags
      # handle gems
      gem install bundler specific_install
      # debugging tools
      gem install letters did_you_mean
      # pry
      gem install pry pry-rescue pry-stack_explorer hirb
      # CLI / deploy
      gem install dolphin boson
      # dir / file tools
      gem install fled markdown2confluence
      # shell tool
      gem install ru
      # github tool
      gem install github
    },
  ]

  execute menu
end

#newrelicObject



158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/dolphin/setup.rb', line 158

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

#rmrb(version, brand = 'ruby') ⇒ Object



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

def rmrb(version, brand='ruby')
  menu = [
    "
      # uninstall ruby
      sudo rm -rf /opt/rubies/#{brand}-#{version}
      rm -rf ~/.rubies/#{brand}-#{version}
      # uninstall gems
      rm -rf ~/.gem/#{brand}/#{version}
    ",
  ]

  execute menu
end

#ruby(version = "ruby") ⇒ Object



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

def ruby(version="ruby")
  menu = [
    "
      # install ruby
      # sudo /usr/local/bin/ruby-install #{version}
      /usr/local/bin/ruby-install #{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(dir = nil, version = "ruby-2.3.0") ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/dolphin/setup.rb', line 115

def select(dir=nil, version="ruby-2.3.0")
  dir ||= @app_dir
  menu = [
    "
      # select ruby
      cd #{dir}
      echo #{version} > .ruby-version
    ",
  ]

  execute menu
end