#!/usr/bin/env bash
#########################################
#Copyright (c) 2023 ABLECLOUD Co. Ltd.
#
#ccvm 초기화(bootstrap)하는 스크립트
#
#최초작성자 : 배태주 책임
#최초작성일 : 2024-02-14
#########################################
set -x
LOGFILE="/var/log/mold_install_hypervisor_preparation.log"

dnf -y --nogpgcheck install /opt/install_hypervisor_prepare-4.0.15/rpms/* 2>&1 | tee -a $LOGFILE
dnf -y --nogpgcheck install /opt/install_hypervisor_prepare-4.0.15/hypervisor_rpms/* 2>&1 | tee -a $LOGFILE

# 방화벽 해제
firewall-cmd --permanent --zone=public --add-port=5900-6000/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=16509/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=16514/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=2224/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=3121/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=5403/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=9929/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=21064/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=2049/tcp 2>&1 | tee -a $LOGFILE
firewall-cmd --permanent --zone=public --add-port=49152-49215/tcp 2>&1 | tee -a $LOGFILE

firewall-cmd --reload 2>&1 | tee -a $LOGFILE

echo "Mold install hypervisor preparation ended!!"  | tee -a $LOGFILE