no message
parent
3e944c8e4d
commit
2277f20719
@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/expect -f
|
||||
if [ $# -lt 1]
|
||||
then
|
||||
echo "I Hope your input. [FILE_NAME]"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $# -lt 2]
|
||||
then
|
||||
echo "I Hope your input. [WAS_DIR]"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $# -lt 3]
|
||||
then
|
||||
echo "I Hope your input. [WEB_DIR]"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $# -lt 4]
|
||||
then
|
||||
echo "I Hope your input. [FILE_ID]"
|
||||
exit
|
||||
fi
|
||||
|
||||
FILE_NAME=$1
|
||||
WAS_DIR=$2
|
||||
WEB_DIR=$3
|
||||
FILE_ID=$4
|
||||
|
||||
java -jar /gpta/source-app/cfs/relay_jar/customSender.jar $FILE_NAME $WAS_DIR $WEB_DIR $FILE_ID &
|
||||
@ -1,138 +0,0 @@
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class CustomSender {
|
||||
|
||||
public static final Logger logger = Logger.getLogger(CustomSender.class);
|
||||
|
||||
private static String[] g_strDB = new String[4];
|
||||
private static String ofileName = "";
|
||||
private static String wasWorkDir = "";
|
||||
private static String webWorkDir = "";
|
||||
private static String fileId = "";
|
||||
|
||||
public static void main(String[] args) {
|
||||
if(args.length != 4) {
|
||||
System.err.println("총 4개의 args를 입력하지 않았습니다.");
|
||||
System.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
ofileName = args[0];
|
||||
wasWorkDir = args[1];
|
||||
webWorkDir = args[2];
|
||||
fileId = args[3];
|
||||
|
||||
// 프로퍼티 파일 위치
|
||||
String propFile = "/gpta/source-app/cfs/relay_jar/config.properties";
|
||||
// 프로퍼티 파일 로딩
|
||||
try {
|
||||
// 프로퍼티 객체 생성
|
||||
Properties props = new Properties();
|
||||
|
||||
// 프로퍼티 파일 스트림에 담기
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
|
||||
|
||||
props.load(new java.io.BufferedInputStream(fis));
|
||||
|
||||
|
||||
// 항목 읽기
|
||||
g_strDB[0] = props.getProperty("db_driver");
|
||||
g_strDB[1] = props.getProperty("db_connect");
|
||||
g_strDB[2] = props.getProperty("db_id");
|
||||
g_strDB[3] = props.getProperty("db_pw");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
CustomSender self = new CustomSender();
|
||||
|
||||
try {
|
||||
self.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void run() throws Exception {
|
||||
File file = new File(wasWorkDir + "/" + ofileName);
|
||||
|
||||
int ftpResult = this.setFtpData(file, ofileName);
|
||||
|
||||
if(ftpResult == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
PreparedStatement ps = null;
|
||||
|
||||
try {
|
||||
|
||||
|
||||
conn = getOrclConn();
|
||||
|
||||
String sql = "UPDATE TB_CUSTOM_COMMAND "
|
||||
+ " SET STAT_CD = '1' "
|
||||
+ " WHERE FILE_ID = '"+fileId+"' ";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
|
||||
if(ps != null) {
|
||||
ps.close();
|
||||
}
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int setFtpData(File file, String fileNm) {
|
||||
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
|
||||
logger.debug("======== 업로드 시작 : " + fileNm);
|
||||
|
||||
sftp.init("175.193.201.56", "tmax","tmax1234");
|
||||
|
||||
Map<String, String> resultMap = new HashMap<String, String>();
|
||||
resultMap.put("return", "0");
|
||||
|
||||
try {
|
||||
sftp.upload3(webWorkDir+"/", file, resultMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
logger.debug("======== : " + resultMap.get("return"));
|
||||
|
||||
int nReturn = Integer.parseInt(resultMap.get("return"));
|
||||
|
||||
sftp.disconnect();
|
||||
|
||||
logger.debug("======== 업로드 끝 : " + nReturn);
|
||||
|
||||
return nReturn;
|
||||
}
|
||||
|
||||
private Connection getOrclConn( ) throws Exception{
|
||||
Class.forName(g_strDB[0]);
|
||||
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SshSshTouch {
|
||||
|
||||
public static final Logger logger = Logger.getLogger(SshSshTouch.class);
|
||||
|
||||
|
||||
private static String targetSys = "";
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
if(args.length != 1) {
|
||||
System.err.println("총 1개의 args를 입력하지 않았습니다.");
|
||||
System.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
targetSys = args[0];
|
||||
|
||||
SshSshTouch self = new SshSshTouch();
|
||||
|
||||
try {
|
||||
self.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void run() throws Exception {
|
||||
|
||||
FTPUtil ssh = new FTPUtil();
|
||||
ssh.initExec("175.193.201.56", "tmax","tmax1234");
|
||||
|
||||
try {
|
||||
String cmd = "";
|
||||
|
||||
if(targetSys.equals("monitoring")) {
|
||||
cmd = "sshpass -p tcs ssh -o StrictHostKeyChecking=no tcs@192.168.201.120 touch /home/tcs/touch/monitoring";
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
if(!cmd.equals("")) {
|
||||
ssh.setCommand(cmd);
|
||||
}
|
||||
|
||||
ssh.disconnectExec();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/expect -f
|
||||
if [ $# -lt 1]
|
||||
then
|
||||
echo "I Hope your input. [TARGET_SYS]"
|
||||
exit
|
||||
fi
|
||||
|
||||
TARGET_SYS=$1
|
||||
|
||||
java -jar /gpta/source-app/cfs/relay_jar/SshSshTouch.jar $TARGET_SYS &
|
||||
Loading…
Reference in New Issue