Class: Hoof::Cli
Instance Method Summary collapse
- #init(name = nil) ⇒ Object
- #install(target = '') ⇒ Object
- #restart ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
- #uninstall(target = '') ⇒ Object
Instance Method Details
#init(name = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/hoof/cli.rb', line 33 def init name = nil name ||= File.basename Dir.getwd create_link File.(File.join("~/.hoof", name)), Dir.getwd append_to_file 'Gemfile', "\ngem 'unicorn'" end |
#install(target = '') ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/hoof/cli.rb', line 45 def install target = '' ext = File.(File.join(File.dirname(__FILE__), '..', '..', 'ext')) puts "Successfully installed NSS library" if system "cd #{ext} && make && sudo make install" puts "Successfully added iptables rules" if system <<-E sudo iptables -t nat -I OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports #{Hoof.http_port} && sudo iptables -t nat -I OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-ports #{Hoof.https_port} E end |
#restart ⇒ Object
22 23 24 |
# File 'lib/hoof/cli.rb', line 22 def restart daemon 'restart' end |
#start ⇒ Object
12 13 14 |
# File 'lib/hoof/cli.rb', line 12 def start daemon 'start' end |
#status ⇒ Object
40 41 42 |
# File 'lib/hoof/cli.rb', line 40 def status control 'status' end |
#stop ⇒ Object
17 18 19 |
# File 'lib/hoof/cli.rb', line 17 def stop daemon 'stop' end |
#uninstall(target = '') ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/hoof/cli.rb', line 55 def uninstall target = '' ext = File.(File.join(File.dirname(__FILE__), '..', '..', 'ext')) puts "Successfully uninstalled NSS library" if system "cd #{ext} && sudo make uninstall && make clean" puts "Successfully removed iptables rules" if system <<-E sudo iptables -t nat -D OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports #{Hoof.http_port} && sudo iptables -t nat -D OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-ports #{Hoof.https_port} E end |