Created
March 8, 2012 22:00
-
-
Save davidcornu/2003728 to your computer and use it in GitHub Desktop.
Convenient command line methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/ruby /Users/davidcornu/manager.rb $1 $2 $3 $4 $5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SYSTEM =================================== | |
if ARGV[0] == "flushdns" | |
puts "Flushing DNS Cache" | |
@command = "sudo dscacheutil -flushcache" | |
# SIMPLE HTTP ============================== | |
elsif ARGV[0] == "serve" | |
puts "Starting Python HTTP Server" | |
@command = "python -m SimpleHTTPServer" | |
# MEDIA SERVER ============================= | |
elsif ARGV[0] == "ms" | |
if ARGV[1] == "start" | |
puts "Starting Media Server" | |
@command = "cd /Users/davidcornu/Development/artfox/media_server/; ./start.sh" | |
elsif ARGV[1] == "stop" | |
puts "Shutting Down Media Server" | |
@command = "cd /Users/davidcornu/Development/artfox/media_server/; ./stop.sh" | |
elsif ARGV[1] == "update" | |
puts "Updating Media Server" | |
@command = "cd /Users/davidcornu/Development/artfox/media_server/; ./update.sh" | |
end | |
# MYSQL ==================================== | |
elsif ARGV[0] == "mysql" | |
if ARGV[1] == "start" | |
@command = "mysql.server start" | |
elsif ARGV[1] == "stop" | |
@command = "mysql.server stop" | |
end | |
# REDIS ==================================== | |
elsif ARGV[0] == "redis" | |
if ARGV[1] == "start" | |
puts "Starting Redis" | |
@command = "nohup redis-server > /dev/null &" | |
elsif ARGV[1] == "stop" | |
puts "Stopping Redis" | |
@command = "kill `pidof redis-server`" | |
end | |
# ELASTIC SEARCH =========================== | |
elsif ARGV[0] == "elastic" | |
if ARGV[1] == "run" | |
puts "Starting Elastic Search" | |
@command = "elasticsearch -f -D es.config=/usr/local/Cellar/elasticsearch/0.18.7/config/elasticsearch.yml" | |
end | |
# APACHE =================================== | |
elsif ARGV[0] == "ap" | |
if ARGV[1] == "start" | |
puts "Starting Apache" | |
@command = "sudo apachectl start" | |
elsif ARGV[1] == "stop" | |
puts "Shutting Down Apache" | |
@command = "sudo apachectl stop" | |
elsif ARGV[1] == "restart" | |
puts "Restarting Apache" | |
@command = "sudo apachectl restart" | |
end | |
end | |
if @command | |
if system @command | |
puts "Done!" | |
else | |
puts "Error!" | |
end | |
else | |
puts "Unknown Command!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Second file lives in
/usr/local/bin/dav
and needs to bechmod +x