Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions bin/cleanAll.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# 경고 메시지 및 사용자 확인
# Warning message and user confirmation
cat <<EOF
[WARNING]
This shell script will delete ALL Docker images, containers, volumes, networks, and also remove all container-volume directories used for persistent data.
Expand All @@ -13,7 +13,7 @@ if [[ ! "$answer" =~ ^[Yy]$ ]]; then
exit 1
fi

# 모든 Docker 이미지 삭제
# Delete all Docker images
echo "All Docker images deleting..."
if [ -n "$(docker images -q)" ]; then
echo "docker rmi \$(docker images -q) -f"
Expand All @@ -24,7 +24,7 @@ else
fi

echo
# 모든 컨테이너 중지 및 삭제
# Stop and delete all containers
echo "Stopping and deleting all Docker containers..."
if [ -n "$(docker ps -aq)" ]; then
echo "docker stop \$(docker ps -aq)"
Expand All @@ -36,13 +36,13 @@ else
fi

echo
# 모든 사용되지 않는 Docker 시스템 리소스 정리 (이미지, 컨테이너, 네트워크, 빌드 캐시)
# Clean up all unused Docker system resources (images, containers, networks, build cache)
echo "Cleaning up all unused Docker system resources (images, containers, networks, build cache)..."
echo "docker system prune -a -f"
docker system prune -a -f

echo
# 모든 볼륨 삭제
# Delete all volumes
echo "Deleting all Docker volumes..."
if [ -n "$(docker volume ls -q)" ]; then
echo "docker volume rm \$(docker volume ls -q)"
Expand All @@ -52,12 +52,12 @@ else
fi

echo
# 모든 네트워크 삭제 (사용되지 않는 네트워크만)
# Delete all networks (unused networks only)
echo "docker network prune -f"
docker network prune -f

echo
# 모든 사용자 정의 네트워크 강제 삭제
# Force delete all custom networks
echo "Deleting all custom Docker networks..."
if [ -n "$(docker network ls --filter type=custom -q)" ]; then
echo "docker network rm \$(docker network ls --filter type=custom -q)"
Expand All @@ -68,7 +68,7 @@ fi


echo
# Docker Compose 정리 (만약 docker-compose.yaml이 있는 경우)
# Clean up Docker Compose resources (if docker-compose.yaml exists)
echo "Cleaning up Docker Compose resources..."
if [ -f "../conf/docker/docker-compose.yaml" ]; then
echo "cd ../conf/docker && docker-compose down -v --remove-orphans"
Expand All @@ -77,7 +77,7 @@ if [ -f "../conf/docker/docker-compose.yaml" ]; then
fi

echo
# container-volume 폴더 삭제 (호스트 마운트 포인트)
# Delete container-volume directories (host mount points)
echo "Deleting container-volume directories..."
if [ -d "../conf/docker/container-volume" ]; then
echo "sudo rm -rf ../conf/docker/container-volume"
Expand All @@ -88,7 +88,7 @@ else
fi

echo
# mc-iam-manager 설정 파일들 삭제
# Delete mc-iam-manager configuration files
echo "Deleting mc-iam-manager configuration files..."
files_to_delete=(
"../conf/docker/conf/mc-iam-manager/api.yaml"
Expand All @@ -107,18 +107,18 @@ for file in "${files_to_delete[@]}"; do
done

echo
# Docker 시스템 리소스 정보 표시
# Display Docker system resource information
echo "docker system df"
docker system df

echo
# Docker 데몬 재시작 (선택사항 - 주석 처리)
# Restart Docker daemon (optional - commented out)
# echo "Restarting Docker daemon..."
# sudo systemctl restart docker
# sleep 5

echo
# 정리 완료 후 상태 확인
# Check status after cleanup
echo "=== Cleanup Status ==="
echo "Remaining images: $(docker images -q | wc -l)"
echo "Remaining containers: $(docker ps -aq | wc -l)"
Expand Down
126 changes: 63 additions & 63 deletions bin/iam_manager_init.sh
Original file line number Diff line number Diff line change
@@ -1,131 +1,131 @@
#!/bin/bash

# MC-IAM-Manager 초기화 모드 설정 스크립트
# MC-IAM-Manager initialization mode selection script

# 스크립트 시작 시 현재 위치 저장
# Save current directory at script start
ORIGINAL_DIR="$(pwd)"

echo "=========================================="
echo "MC-IAM-Manager Initialization"
echo "=========================================="
echo ""

# 필수 컨테이너 상태 체크
# Required container health check
echo "----------------------------------------"
echo " Required Container Health Check"
echo "----------------------------------------"
echo "필수 컨테이너 상태를 확인하고 있습니다..."
echo "Checking required container status..."
echo ""

REQUIRED_CONTAINERS=("mc-iam-manager-db" "mc-iam-manager-kc")
ALL_HEALTHY=true

for container in "${REQUIRED_CONTAINERS[@]}"; do
echo -n "체크 중: $container ... "
# 컨테이너가 존재하는지 확인
echo -n "Checking: $container ... "

# Check if container exists
if ! docker ps --format "table {{.Names}}" | grep -q "^$container$"; then
echo "❌ 컨테이너가 실행되지 않았습니다."
echo "❌ Container is not running."
ALL_HEALTHY=false
continue
fi
# 컨테이너 상태 확인

# Check container status
container_status=$(docker inspect --format='{{.State.Health.Status}}' "$container" 2>/dev/null)

if [ "$container_status" = "healthy" ]; then
echo "✅ 정상"
echo "✅ Healthy"
elif [ "$container_status" = "starting" ]; then
echo "⏳ 시작 중..."
echo "⏳ Starting..."
ALL_HEALTHY=false
elif [ "$container_status" = "unhealthy" ]; then
echo "❌ 비정상"
echo "❌ Unhealthy"
ALL_HEALTHY=false
else
echo "❓ 상태 확인 불가 ($container_status)"
echo "❓ Status unknown ($container_status)"
ALL_HEALTHY=false
fi
done

echo ""

if [ "$ALL_HEALTHY" = false ]; then
echo "❌ 필수 컨테이너가 모두 정상 상태가 아닙니다."
echo "다음 컨테이너들이 정상적으로 구동된 후 다시 시도해주세요:"
echo "❌ Not all required containers are healthy."
echo "Please ensure the following containers are running and healthy, then try again:"
# echo " - mc-iam-manager"
echo " - mc-iam-manager-db"
echo " - mc-iam-manager-kc"
echo ""
echo "컨테이너 상태 확인: docker ps"
echo "컨테이너 로그 확인: docker logs [컨테이너명]"
echo "Check container status: docker ps"
echo "Check container logs: docker logs [container-name]"
exit 1
fi

echo "✅ 모든 필수 컨테이너가 정상 상태입니다."
echo "초기화를 진행할 수 있습니다..."
echo "✅ All required containers are healthy."
echo "Proceeding with initialization..."
echo ""

echo "------------------------------------------------"
echo " MC-IAM-Manager Initialization Mode Selection"
echo "------------------------------------------------"
echo "MC-IAM-Manager 초기화는 두 가지 모드로 진행할 수 있습니다:"
echo "MC-IAM-Manager initialization can be performed in two modes:"
echo ""
echo "[전체 초기화 - 자동 모드]"
echo " - 모든 초기화 작업이 자동으로 순차 진행"
echo " - 플랫폼 어드민 초기화"
echo " - 로그인 및 인증 토큰 발급"
echo " - 사전 정의된 역할 생성 (admin, operator, viewer)"
echo " - 메뉴 데이터 초기화"
echo " - API 리소스 데이터 초기화"
echo " - 프로젝트 동기화 및 워크스페이스 매핑"
echo " - 빠르고 편리한 일괄 설정"
echo "[Full Initialization - Auto Mode]"
echo " - All initialization tasks run automatically in sequence"
echo " - Platform admin initialization"
echo " - Login and authentication token issuance"
echo " - Predefined role creation (admin, operator, viewer, etc.)"
echo " - Menu data initialization"
echo " - API resource data initialization"
echo " - Project sync and workspace mapping"
echo " - Fast and convenient batch setup"
echo ""
echo "[부분 초기화 - 수동 모드]"
echo " - 초기화 가능한 작업 목록을 사용자가 선택"
echo " - 각 단계별로 개별 실행 가능"
echo " - 상세한 진행 상황 확인"
echo " - 특정 기능만 선택적으로 초기화"
echo " - 문제 발생 시 단계별 디버깅 가능"
echo "[Partial Initialization - Manual Mode]"
echo " - User selects tasks from the available initialization list"
echo " - Each step can be executed individually"
echo " - Detailed progress visibility"
echo " - Selectively initialize specific features only"
echo " - Step-by-step debugging when issues occur"
echo ""
echo "=============================================================="


# 사용자 선택 입력
# User mode selection input
while true; do
echo -n "어떤 초기화 모드를 선택하시겠습니까? (1: 전체 초기화, 2: 부분 초기화): "
echo -n "Which initialization mode would you like? (1: Full initialization, 2: Partial initialization): "
read -r choice

case $choice in
1)
echo ""
echo "전체 초기화-자동 모드를 선택하셨습니다."
echo "모든 초기화 작업이 자동으로 순차 진행됩니다..."
echo "Full initialization - Auto mode selected."
echo "All initialization tasks will run automatically in sequence..."
echo ""

cd "$ORIGINAL_DIR"
./mcc infra run -s mc-iam-manager-post-initial
# # 전체 초기화 스크립트 실행
# # Run full initialization script
# cd ../conf/docker/conf/mc-iam-manager/ || {
# echo "오류: mc-iam-manager 디렉토리를 찾을 수 없습니다."
# echo "Error: mc-iam-manager directory not found."
# cd "$ORIGINAL_DIR"
# exit 1
# }

# if [ -f "1_setup_auto.sh" ]; then
# chmod +x 1_setup_auto.sh
# ./1_setup_auto.sh
# if [ $? -eq 0 ]; then
# echo ""
# echo "✓ 전체 초기화가 완료되었습니다."
# echo "MC-IAM-Manager가 정상적으로 설정되었습니다."
# echo "✓ Full initialization completed."
# echo "MC-IAM-Manager has been configured successfully."
# else
# echo ""
# echo "❌ 전체 초기화 중 오류가 발생했습니다."
# echo "❌ An error occurred during full initialization."
# cd "$ORIGINAL_DIR"
# exit 1
# fi
# else
# echo "오류: 1_setup_auto.sh 파일을 찾을 수 없습니다."
# echo "Error: 1_setup_auto.sh file not found."
# cd "$ORIGINAL_DIR"
# exit 1
# fi
Expand All @@ -134,50 +134,50 @@ while true; do
;;
2)
echo ""
echo "부분 초기화-수동 모드를 선택하셨습니다."
echo "초기화 가능한 작업 목록에서 원하는 항목을 선택하세요..."
echo "Partial initialization - Manual mode selected."
echo "Select the desired tasks from the available initialization list..."
echo ""
# 부분 초기화 스크립트 실행

# Run partial initialization script
cd ../conf/docker/conf/mc-iam-manager/ || {
echo "오류: mc-iam-manager 디렉토리를 찾을 수 없습니다."
echo "Error: mc-iam-manager directory not found."
cd "$ORIGINAL_DIR"
exit 1
}

if [ -f "1_setup_manual.sh" ]; then
chmod +x 1_setup_manual.sh
./1_setup_manual.sh
if [ $? -eq 0 ]; then
echo ""
echo "✓ 부분 초기화가 완료되었습니다."
echo "선택한 초기화 작업이 정상적으로 수행되었습니다."
echo "✓ Partial initialization completed."
echo "The selected initialization tasks completed successfully."
else
echo ""
echo "❌ 부분 초기화 중 오류가 발생했습니다."
echo "❌ An error occurred during partial initialization."
cd "$ORIGINAL_DIR"
exit 1
fi
else
echo "오류: 1_setup_manual.sh 파일을 찾을 수 없습니다."
echo "Error: 1_setup_manual.sh file not found."
cd "$ORIGINAL_DIR"
exit 1
fi

break
;;
*)
echo "잘못된 선택입니다. 1 또는 2를 입력해주세요."
echo "Invalid choice. Please enter 1 or 2."
;;
esac
done

# 모든 초기화 작업 완료 후 원래 위치로 돌아가기
# Return to the original directory after all initialization tasks
cd "$ORIGINAL_DIR"

echo ""
echo "======================================================"
echo "초기화 작업이 완료되었습니다!"
echo "MC-IAM-Manager가 정상적으로 설정되었습니다."
echo "Initialization completed!"
echo "MC-IAM-Manager has been configured successfully."
echo "======================================================"

Loading