Class: OpsKit::OdinSon
- Inherits:
-
Thor
- Object
- Thor
- OpsKit::OdinSon
- Includes:
- Thor::Actions
- Defined in:
- lib/opskit/cli.rb
Instance Method Summary collapse
Instance Method Details
#clean(name) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/opskit/cli.rb', line 45 def clean (name) OpsKit.configure name if Dir.exist? OpsKit.configuration.project_root return if no? "This will remove #{OpsKit.configuration.project_root} are you sure?" FileUtils.rm_rf(OpsKit.configuration.project_root) else return if no? "Can´t find the project continue cleaning?" end if yes? "clean vhost?" ask_for_url vhost = OpsKit::VHost.new( {template: OpsKit.configuration.template, url: OpsKit.configuration.url, docroot: OpsKit.configuration.docroot } ) say "Removing the hosts entry for #{vhost.conf[:url]}", :cyan run "sed '/127.0.0.1 #{vhost.conf[:url]}/d' /etc/hosts | sudo tee /etc/hosts" say "Disabling #{vhost.conf[:url]}", :cyan run "sudo a2dissite #{vhost.conf[:url]}" say "Remove #{vhost.vhost_location}", :cyan if File.exist? vhost.vhost_location run "sudo rm #{vhost.vhost_location}" else say "Couldn't find #{vhost.vhost_location}", :red end say "Reload the apache2 server", :cyan run "sudo service apache2 reload" end end |
#setup(repo, name = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/opskit/cli.rb', line 11 def setup (repo, name=nil) if !name name = repo.split('/').last.split(".git").first end OpsKit.configure name if Dir.exist? OpsKit.configuration.project_root return if no? "This project already exists do you want to overwrite it?" clean name end say "Cloning repo into #{OpsKit.configuration.project_root}", :cyan run "git clone #{repo} #{name}" if yes? "create vhost?" ask_for_url ask_for_docroot vhost = OpsKit::VHost.new( {template: OpsKit.configuration.template, url: OpsKit.configuration.url, docroot: OpsKit.configuration.docroot } ) say "Create vhost for #{vhost.conf[:url]} at #{vhost.vhost_location}", :cyan run "echo '#{vhost.render}' | sudo tee #{vhost.vhost_location}" run "sudo a2ensite #{vhost.conf[:url]}" say "Creating hosts entry", :cyan run "grep -q -F '127.0.0.1 #{vhost.conf[:url]}' /etc/hosts || echo '127.0.0.1 #{vhost.conf[:url]}' | sudo tee -a /etc/hosts" say "Reload the apache2 server", :cyan run "sudo service apache2 reload" end end |