Created
May 19, 2011 19:53
-
-
Save darrend/981585 to your computer and use it in GitHub Desktop.
a halfassed model for utility scripting for specific cases
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/env ruby | |
# just some hackity hack to manage the remote tomcat on old-darrend-desktop | |
class TomcatOldEnvironment | |
def initialize targetslot | |
@targetslot = targetslot | |
end | |
def targetslot | |
raise "Unknown targetslot #{@targetslot}" unless (@targetslot==='pobs' || @targetslot==='eui') | |
@targetslot | |
end | |
def tcold_help arguments | |
puts self.methods.select { |e| e =~ /tcold_/ } | |
end | |
def tcold_deploy arguments | |
warfile, dir = *case targetslot | |
when "pobs": ["pobs", "forpobs"] | |
when "eui": ["ROOT", "foreui"] | |
end | |
tcold_down arguments | |
sleep 5 | |
dothis "scp #{arguments[0]} old-darrend-desktop:/home/darrend/tomcat/#{dir}/webapps/#{warfile}.war" | |
dothis "ssh old-darrend-desktop 'rm -rf /home/darrend/tomcat/#{dir}/webapps/#{warfile}/'" | |
tcold_up arguments | |
end | |
def tcold_config arguments | |
case targetslot | |
when "pobs" | |
dothis "ssh old-darrend-desktop 'grep jdbc /home/darrend/tomcat/for#{targetslot}/conf/server.xml'" | |
when "eui" | |
dothis "ssh old-darrend-desktop 'grep pobsconnect /etc/hosts'" | |
end | |
end | |
def tcold_check arguments | |
port = case targetslot | |
when "eui": 8081 | |
when "pobs": 8080 | |
end | |
dothis "ssh old-darrend-desktop 'lsof -i tcp:#{port}'" | |
end | |
def tcold_down arguments | |
puts "shutting down #{targetslot}" | |
dothis "ssh old-darrend-desktop 'cd /home/darrend/tomcat/for#{targetslot}; bin/shutdown.sh'" | |
end | |
def tcold_up arguments | |
puts "starting up #{targetslot}" | |
dothis "ssh old-darrend-desktop 'cd /home/darrend/tomcat/for#{targetslot}; bin/startup.sh'" | |
end | |
private | |
def dothis command | |
puts "> #{command}" | |
puts %x_#{command}_ | |
end | |
end | |
targetslot, action, *arguments = *ARGV | |
action = targetslot if action.nil? | |
tcold = TomcatOldEnvironment.new targetslot | |
if tcold.respond_to? "tcold_#{action}" | |
tcold.send "tcold_#{action}", arguments | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment