001 package org.kuali.common.deploy.spring;
002
003 import java.util.ArrayList;
004 import java.util.Arrays;
005 import java.util.List;
006
007 import org.kuali.common.deploy.SysAdminExecutable;
008 import org.kuali.common.deploy.channel.spring.DefaultSecureChannelConfig;
009 import org.kuali.common.util.UnixCmds;
010 import org.kuali.common.util.execute.Executable;
011 import org.kuali.common.util.secure.channel.SecureChannel;
012 import org.kuali.common.util.spring.env.EnvironmentService;
013 import org.kuali.common.util.spring.service.SpringServiceConfig;
014 import org.springframework.beans.factory.annotation.Autowired;
015 import org.springframework.context.annotation.Bean;
016 import org.springframework.context.annotation.Configuration;
017 import org.springframework.context.annotation.Import;
018
019 @Configuration
020 @Import({ DefaultSecureChannelConfig.class, SpringServiceConfig.class })
021 public class DefaultSysAdminConfig implements SysAdminConfig {
022
023 @Autowired
024 EnvironmentService env;
025
026 @Autowired
027 SecureChannel channel;
028
029 @Override
030 @Bean
031 public Executable sysAdminExecutable() {
032 boolean skip = env.getBoolean("sysadmin.skip", false);
033 String hostname = env.getString("dns.hostname");
034 UnixCmds cmds = new UnixCmds();
035 List<String> commands = new ArrayList<String>();
036 commands.add(cmds.hostname(hostname));
037 commands.addAll(getCopyToolsJarToJreLibExt());
038 return new SysAdminExecutable(channel, commands, skip);
039 }
040
041 /**
042 * Copy tools.jar to the jre/lib/ext directory. This enables advanced AppDynamics monitoring of the heap.
043 */
044 protected List<String> getCopyToolsJarToJreLibExt() {
045 UnixCmds cmds = new UnixCmds();
046
047 // copy the jdk6 tools.jar to the jdk6 jre/lib/ext area
048 String jdk6Src = env.getString("jdk6.tools.jar.src");
049 String jdk6Dst = env.getString("jdk6.tools.jar.dst");
050 String jdk6Cmd = cmds.cp(jdk6Src, jdk6Dst, true);
051
052 // copy the jdk7 tools.jar to the jdk7 jre/lib/ext area
053 String jdk7Src = env.getString("jdk7.tools.jar.src");
054 String jdk7Dst = env.getString("jdk7.tools.jar.dst");
055 String jdk7Cmd = cmds.cp(jdk7Src, jdk7Dst, true);
056
057 return Arrays.asList(jdk6Cmd, jdk7Cmd);
058
059 }
060
061 }