Commit 6e9965b7 authored by Watchtek's avatar Watchtek
Browse files

First commit

parents
Loading
Loading
Loading
Loading

DB-PMA.sh

0 → 100644
+94 −0
Original line number Diff line number Diff line
#!/bin/bash
set -eo pipefail

# 공통 설정 및 로그 함수 로드
source ./.watchall.env
source ./common_utils.sh

FILE_CHECK=$(ls "$PATH_PACKAGE_DB"/PMA*.zip 2>/dev/null | head -n 1 || true)

if [[ -z "$FILE_CHECK" ]]; then
        log_error "========== [ERROR] PMA설치 파일이 없습니다. =========="
        log_error "경로: $PATH_PACKAGE_DB/*PMA*.zip"
        exit 0
fi

PATH_CURRENT=`pwd`
PATCH_DATE=`date '+%y%m%d'`

# 사용법 안내
if [[ ${1} != "INSTALL" && ${1} != "PATCH" ]] ; then
    echo "#########################################################"
    echo "#######    Usage for ./DB-PMA.sh                   ######"
    echo "#######    ./DB-PMA.sh [INSTALL|PATCH] ##################"
    echo "#########################################################"
    exit 0;
fi

# ---------------------------------------------------------
# INSTALL 모드
# ---------------------------------------------------------
if [[ ${1} == "INSTALL" ]] ; then
    log_step "========== PMA DB 삽입 작업을 시작합니다. =========="

    # SQL 스크립트 병합 및 적용
    log_info "DB 스키마 및 기준 정보 삽입을 준비합니다."
    cd $PATH_PACKAGE/DB
    log_info "PMA DB 압축 파일 해제 중..."
    unzip -q -d PMA -o *PMA*.zip
    sleep 3

    cd $PATH_PACKAGE/DB/PMA/DDL
    log_info "PMA DDL 스크립트 병합 수행 중..."
    chmod 755 merge_DDL.sh
    ./merge_DDL.sh
    sleep 3
    cp PMA.sql $PATH_MODULE/mysql/bin

    # LMS 모드에 따른 DML 처리
    cd $PATH_PACKAGE/DB/PMA/DML/
    chmod 755 *.sh

    log_info "PMA DML 병합을 수행합니다."
    ./merge_DML.sh
    sleep 3
    cp INSERT_DML_PMA.sql $PATH_MODULE/mysql/bin

    # 데이터베이스 생성 및 SQL 적용
    # log_info "watchall_2x 데이터베이스를 생성합니다."
    # ${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} -AN -e"create database watchall_2x character set utf8 collate utf8_general_ci;"
    
    cd ${PATH_MODULE}/mysql/bin
    log_info "PMA.sql 스키마를 적용합니다."
    ./mysql -u$DB_USER -p${DB_PW_A} watchall_2x <"PMA.sql"

    log_info "INSERT_DML_PMA.sql 스키마를 적용합니다."
    ./mysql -u$DB_USER -p${DB_PW_A} watchall_2x <"INSERT_DML_PMA.sql"


# 기준정보 업데이트 - 와치올 DB 접속 정보
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update basicinfo_set set basicinfo_subvalue_string='$DB_HOST' where basicinfo_id='PMA_WATCHALL_DB' and basicinfo_subid='DB_HOST'"
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update basicinfo_set set basicinfo_subvalue_string='$DB_PORT' where basicinfo_id='PMA_WATCHALL_DB' and basicinfo_subid='DB_PORT'"
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update basicinfo_set set basicinfo_subvalue_string='$DB_USER' where basicinfo_id='PMA_WATCHALL_DB' and basicinfo_subid='DB_USER'"
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update basicinfo_set set basicinfo_subvalue_string='$DB_PW_A' where basicinfo_id='PMA_WATCHALL_DB' and basicinfo_subid='DB_PASSWORD'"
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update basicinfo_set set basicinfo_subvalue_string='watchall_2x' where basicinfo_id='PMA_WATCHALL_DB' and basicinfo_subid='DB_HOST'"

###
# 세마포어 동기화 작업 >영역
# update basicinfo_set set basicinfo_subvalue_string='/foo/bar' where basicinfo_id='PMA_SYNC_PROPS' and basicinfo_subid='PMA_SYNC_WORKSPACE'

# 보고서 파일 디렉토리
# update basicinfo_set set basicinfo_subvalue_string='/foo/bar' where basicinfo_id='PMA_USER_REPORT' and basicinfo_subid='REPORT_FILE_DIRECTORY'

# CM Menu
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update menu_info set use_flag='Y' managetype_id='PMA'"
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update menu_info set use_flag='Y' managetype_id='PMA_SETTING'"

# CM 공통설정
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update managetype set active_flag='Y' where managetype_id='PMA'"

# DM
${PATH_MODULE}/mysql/bin/mysql -u$DB_USER -p${DB_PW_A} watchall_2x -AN -e "update module_config_attr set module_config_data='TRUE' where module_config_id='PMA' AND module_type_id='DM'"

log_step "==========PMA DB 삽입 및 초기 구성이 완료되었습니다. =========="
fi

download_pma_build.sh

0 → 100644
+120 −0
Original line number Diff line number Diff line
#!/bin/bash

PATH_BASE=/watchtek/Install_Files/PACKAGE

echo 'PMA Build Module Download'
date +"NOW - %Y-%m-%d %H:%M:%S"

cd $PATH_BASE || exit

## BigData & ML
mkdir -p BigData && cd BigData || exit
echo 'Download BigData'
curl -s -O 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Docs/BigData/*zip*/BigData.zip'

echo 'Download ML'
curl -s -O 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Dist/agent/*zip*/agent.zip'
unzip -q agent.zip && mv agent/* . && rm -rf agent/ agent.zip

## DDL & DML
cd $PATH_BASE || exit
mkdir DB && cd DB || exit


echo 'Download DDL'
curl -s 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Docs/DDL/MySQL/*zip*/MySQL.zip' -o Applemango_DDL.zip
# unzip -q MySQL.zip && mv MySQL/* . && rm -rf MySQL/ MySQL.zip

echo 'Download DML'
curl -s 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Docs/DML/1.%20INSERT/1.%20KOR/*zip*/1.%20KOR.zip' -o Applemango_DML.zip
# unzip -q 1.\ KOR.zip && mv 1.\ KOR/* . && rm -rf 1.\ KOR/ 1.\ KOR.zip

echo 'Download PMA'
curl -s -O 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Docs/PMA/*zip*/PMA.zip'
unzip -q -O cp949 PMA.zip
cd PMA || exit
rm -rf .svn/
mkdir DDL DML
mv ERD/61-4.\ PMA.sql DDL/
rm -r ERD/

cd DDL/ || exit
cat >> merge_DDL.sh <<'EOF'
#!/bin/bash

#Remove previous DDL merge file
rm -rf PMA.sql

#remove all whitespace characters in every file name
for f in *\ *; do mv "$f" "${f// /_}" > /dev/null 2>&1; done

for file in `ls -al | grep sql | grep -v grep | grep -v oracle | awk '{print $9}'` ; do
  cat "$file" >> PMA.sql
  echo " " >> PMA.sql
done
EOF


cd ..
mv 기준정보/script/* DML/
rm -r 기준정보/

cd DML || exit
cat >> merge_DML.sh <<'EOF'
#!/bin/bash

#Remove previous DML merge file
rm -rf INSERT_DML_PMA.sql

#remove all whitespace characters in every file name
for f in *\ *; do mv "$f" "${f// /_}" > /dev/null 2>&1; done

for file in `ls -al | grep sql | grep -v grep | grep -v oracle | awk '{print $9}'` ; do
  cat "$file" >> INSERT_DML_PMA.sql
  echo " " >> INSERT_DML_PMA.sql
done
EOF

# cd ../ && tree
cd ../
zip -qr PMA.zip DDL/ DML/
cd ../
mv PMA/PMA.zip .
rm -r PMA

## AM, CM, DM
cd $PATH_BASE || exit
mkdir Module && cd Module || exit

echo 'Download AM'
curl -s -O 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Dist/WatchAll_AgentManager/*zip*/WatchAll_AgentManager.zip'
unzip -q WatchAll_AgentManager.zip && mv WatchAll_AgentManager/* . && rm -rf WatchAll_AgentManager/ WatchAll_AgentManager.zip

echo 'Download CM'
curl -s -O 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Dist/WatchAll_Applemango/*zip*/WatchAll_Applemango.zip'
unzip -q WatchAll_Applemango.zip && mv WatchAll_Applemango/* . && rm -rf WatchAll_Applemango/ WatchAll_Applemango.zip

echo 'Download DM'
curl -s -O 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/Dist/WatchAll_DataManager/*zip*/WatchAll_DataManager.zip'
unzip -q WatchAll_DataManager.zip && mv WatchAll_DataManager/* . && rm -rf WatchAll_DataManager/ WatchAll_DataManager.zip


## OZ
cd $PATH_BASE || exit
mkdir OZ && cd OZ || exit
echo 'Download OZ'
curl -s -O 'http://192.168.1.3:8080/view/applemango/job/Applemango%20(Opensearch%20-%20PMA%20v2)/ws/oz90/repository_files/*zip*/repository_files.zip'

echo '========================================'
echo 'compress ALL file, plz take some time'
echo

tar --exclude='download_pma_build.sh' \
    -zcvf "PMA_$(date '+%y%m%d_%H%M%S').tgz" ./BigData ./DB ./Module ./OZ

echo
echo 'ALL Download complete, plz check the file'
ls -al

exit 0
 No newline at end of file