Commit 946a1519 authored by root's avatar root

123

parent 24ec0cdf
...@@ -4,6 +4,7 @@ target=$2 ...@@ -4,6 +4,7 @@ target=$2
source ~/.hcrc 2>/dev/null || echo "" source ~/.hcrc 2>/dev/null || echo ""
app_sc_dir=${app_sc_dir:-/ops_project/Health-cloud-server/search-center} app_sc_dir=${app_sc_dir:-/ops_project/Health-cloud-server/search-center}
echo "${app_sc_dir}"
source ${app_sc_dir}/install.ini source ${app_sc_dir}/install.ini
#DB-compose文件DB_DEPLOY_DIR #DB-compose文件DB_DEPLOY_DIR
...@@ -53,6 +54,7 @@ function usage() { ...@@ -53,6 +54,7 @@ function usage() {
install_compose-files(){ install_compose-files(){
select INSTALL_MODE in "all" "server" "controller" select INSTALL_MODE in "all" "server" "controller"
do do
echo "${DB_DEPLOY_DIR},${APP_NAME}"
compose_files="-f ${DB_DEPLOY_DIR}/docker-compose-base.yaml" compose_files="-f ${DB_DEPLOY_DIR}/docker-compose-base.yaml"
case ${INSTALL_MODE} in case ${INSTALL_MODE} in
all) all)
...@@ -86,7 +88,7 @@ install_compose-files(){ ...@@ -86,7 +88,7 @@ install_compose-files(){
#是否使用外部组件 #是否使用外部组件
if [ ${INSTALL_MODE} == "all" ];then if [ ${INSTALL_MODE} == "all" ];then
echo -e "正在创建数据目录" echo -e "正在创建数据目录"
mkdir -p ${app_sc_dir}/data/{es_data,mq_data} mkdir -p ${db_sc_dir}/data/{es_data,mq_data}
echo -e "正在创建日志目录" echo -e "正在创建日志目录"
mkdir -p ${app_sc_dir}/log mkdir -p ${app_sc_dir}/log
elif [ ${INSTALL_MODE} == "server" ];then elif [ ${INSTALL_MODE} == "server" ];then
...@@ -98,7 +100,8 @@ install_compose-files(){ ...@@ -98,7 +100,8 @@ install_compose-files(){
#判断es #判断es
if [ ${ES_ISUSE_STATUS} == 'false' ];then if [ ${ES_ISUSE_STATUS} == 'false' ];then
echo -e "正在创建Elasticsearch数据目录" echo -e "正在创建Elasticsearch数据目录"
mkdir -p ${app_sc_dir}/data/es_data mkdir -p ${db_sc_dir}/data/es_data
chown -R 1000:0 ${db_sc_dir}/data/es_data
compose_files="${compose_files} -f ${DB_DEPLOY_DIR}/docker-compose-es.yaml -f ${app_sc_dir}/docker-compose-searchcenter.yaml" compose_files="${compose_files} -f ${DB_DEPLOY_DIR}/docker-compose-es.yaml -f ${app_sc_dir}/docker-compose-searchcenter.yaml"
elif [ ${ES_ISUSE_STATUS} == 'true' ];then elif [ ${ES_ISUSE_STATUS} == 'true' ];then
edit_es_info edit_es_info
...@@ -108,8 +111,8 @@ install_compose-files(){ ...@@ -108,8 +111,8 @@ install_compose-files(){
fi fi
#判断mq #判断mq
if [ ${MQ_ISUSE_STATUS} == 'false' ];then if [ ${MQ_ISUSE_STATUS} == 'false' ];then
echo -e "正在创建Elasticsearch数据目录" echo -e "正在创建MQ数据目录"
mkdir -p ${app_sc_dir}/data/es_data mkdir -p ${db_sc_dir}/data/es_data
compose_files="${compose_files} -f ${DB_DEPLOY_DIR}/docker-compose-mq.yaml -f ${app_sc_dir}/docker-compose-searchcenter.yaml" compose_files="${compose_files} -f ${DB_DEPLOY_DIR}/docker-compose-mq.yaml -f ${app_sc_dir}/docker-compose-searchcenter.yaml"
elif [ ${MQ_ISUSE_STATUS} == 'true' ];then elif [ ${MQ_ISUSE_STATUS} == 'true' ];then
edit_mq_info edit_mq_info
...@@ -123,6 +126,8 @@ install_compose-files(){ ...@@ -123,6 +126,8 @@ install_compose-files(){
#将所需要部署的组件ymal输出到文件 #将所需要部署的组件ymal输出到文件
echo "${compose_files} ">${app_sc_dir}/compose_files echo "${compose_files} ">${app_sc_dir}/compose_files
COMPOSE_FILE=$(cat ${app_sc_dir}/compose_files) COMPOSE_FILE=$(cat ${app_sc_dir}/compose_files)
echo "即将启动docker-compose部署"
pwd
sudo docker-compose ${COMPOSE_FILE} up -d sudo docker-compose ${COMPOSE_FILE} up -d
} }
...@@ -177,6 +182,8 @@ function main(){ ...@@ -177,6 +182,8 @@ function main(){
usage usage
;; ;;
install_compose-files) install_compose-files)
pwd
echo "即将执行方法install-compose"
install_compose-files install_compose-files
;; ;;
*) *)
......
#!/bin/bash #!/bin/bash
#set -e #set -e
#加载配置信息 #加载配置信息
function if_err(){
if [ $? -ne 0 ];then
exit 127
fi
}
source ./install.ini source ./install.ini
#定义安装程序的app路径 #定义安装程序的app路径
DEPLOY_FILE=$(dirname $0)/Health-Cloud-server/app_server DEPLOY_FILE=$(dirname $0)/Health-cloud-server/app_server
#定义安装程序的db路径 #定义安装程序的db路径
DB_DEPLOY_FILE=$(dirname $0)/Health-Cloud-server/db_server DB_DEPLOY_FILE=$(dirname $0)/Health-cloud-server/db_server
if [ ! -d ${DEPLOY_DIR} ];then mkdir -p ${DEPLOY_DIR};fi if [ ! -d ${DEPLOY_DIR} ];then mkdir -p ${DEPLOY_DIR};fi
#定义部署目标路径(app,db) #定义部署目标路径(app,db)
...@@ -15,20 +21,29 @@ db_sc_dir=${DB_DEPLOY_DIR} ...@@ -15,20 +21,29 @@ db_sc_dir=${DB_DEPLOY_DIR}
if [[ ! -d ${app_sc_dir} && ! -f ~/.hcrc ]];then if [[ ! -d ${app_sc_dir} && ! -f ~/.hcrc ]];then
cp -rf ${DEPLOY_FILE}/${APP_NAME} ${app_sc_dir} cp -rf ${DEPLOY_FILE}/${APP_NAME} ${app_sc_dir}
cp -rf ${DB_DEPLOY_FILE} ${db_sc_dir} cp -rf ${DB_DEPLOY_FILE} ${db_sc_dir}
if_err
else else
echo "目标目录已安装${APP_NAME},请检查${app_sc_dir} .hcrc是否存在" echo "目标目录已安装${APP_NAME},请检查${app_sc_dir} .hcrc是否存在"
exit 127 exit 127
fi fi
#将配置文件存入环境变量文件,使其全局生效 #将配置文件存入环境变量文件,使其全局生效(app和db目录各存一份)
cp ./install.ini ${app_sc_dir}/install.ini.example cp ./install.ini ${app_sc_dir}/install.ini.example
cp ./install.ini ${db_sc_dir}/install.ini.example
env_context=$(cat ${app_sc_dir}/install.ini.example |grep -v "^#"|grep -v "^$") env_context=$(cat ${app_sc_dir}/install.ini.example |grep -v "^#"|grep -v "^$")
echo "${env_context}">${app_sc_dir}/.env echo "${env_context}">${app_sc_dir}/.env
echo "${env_context}">${db_sc_dir}/.env
source ${app_sc_dir}/.env source ${app_sc_dir}/.env
source ${db_sc_dir}/.env
ln -s ${app_sc_dir}/.env ${app_sc_dir}/install.ini 2>/dev/null ln -s ${app_sc_dir}/.env ${app_sc_dir}/install.ini 2>/dev/null
ln -s ${db_sc_dir}/.env ${db_sc_dir}/install.ini 2>/dev/null
#安装hcrc版本文件 #安装hcrc版本文件
echo -e "app_sc_dir=${app_sc_dir}\n ${APP_NANME}版本${SC_IMAGE_VERSION}">~/.hcrc 2>/dev/null || echo "" echo -e "app_sc_dir=${app_sc_dir}\n db_sc_dir=${db_sc_dir}\n ${APP_NANME}版本${SC_IMAGE_VERSION}">~/.hcrc 2>/dev/null || echo ""
#安装hcctl管理命令 #安装hcctl管理命令
sudo cp hcctl /usr/local/bin && sudo chmod +x /usr/local/bin/hcctl sudo cp hcctl /usr/local/bin && sudo chmod +x /usr/local/bin/hcctl
...@@ -48,7 +63,7 @@ if [ $? -ne 0 ];then ...@@ -48,7 +63,7 @@ if [ $? -ne 0 ];then
echo "安装过程出现错误,请查看相关配置..." echo "安装过程出现错误,请查看相关配置..."
exit 127 exit 127
fi fi
echo "${APP_NAME}服务已安装成功..." echo "${APP_NAME}服务已安装成功...."
sleep 2 sleep 2
echo -e "服务启动状态: " echo -e "服务启动状态: "
sleep 2 sleep 2
......
#!/bin/bash
source ./install.ini
if [ -d ${DEPLOY_DIR} ];then
echo "Uninstalling APP Server Files..."
rm -rf ${DEPLOY_DIR}
else
echo "You are Not Install The APP Server"
exit 127
fi
if [ -d ${DB_DEPLOY_DIR} ];then
echo "Uninstalling DB Server Files..."
rm -rf ${DB_DEPLOY_DIR}
else
echo "You are Not Install The DB Server"
exit 127
fi
if [ -f ~/.hcrc ];then
echo "Deleting hcrc File..."
rm -rf ~/.hcrc
else
echo "You are Not Install The hcrc File"
exit 127
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment