diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index e85810d..1c8b542 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -15,8 +15,6 @@ ADD_USER_PASSWORD="MoXF2Zi6u7f7lqZu" BASE_DIR="/opt" # 软件 -#--- nodejs - #--- jdk JDK_URL="https://d6.injdk.cn/oraclejdk/11/jdk-11.0.16.1_linux-x64_bin.tar.gz" JDK_FILE_NAME="jdk-11.0.16.1_linux-x64_bin.tar.gz" @@ -46,6 +44,7 @@ ADD_USER_TAG="1" GIT_TAG="1" DSTAT_TAG="1" HTOP_TAG="1" +NGINX_TAG="1" NODEJS_TAG="1" JAVA_TAG="1" GRADLE_TAG="1" @@ -253,47 +252,113 @@ function init:add_user() { # 安装git环境 function init:git() { log::info "[git]" "安装git环境..." + local host="127.0.0.1" command::exec "${host}" " - yum install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm - yum install git + yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm + yum -y install git + git --version + git config --global credential.helper store " check::exit_code "$?" "git" "$host 安装git环境" "exit" log::info "[git]" "git环境安装成功!" + if [[ "${ADD_USER_TAG:-}" == "1" ]]; then + command::exec "${host}" " + su - ${ADD_USER_NAME} + git config --global credential.helper store + " + check::exit_code "$?" "git" "$host git配置" "exit" + log::info "[git]" "git配置成功!" + fi } # 安装dstat function init:dstat() { - log::info "[dstat]" "安装dstat" + log::info "[dstat]" "安装dstat..." + local host="127.0.0.1" + command::exec "${host}" " + yum -y install dstat + dstat -V + " + check::exit_code "$?" "dstat" "$host 安装dstat" "exit" + log::info "[dstat]" "dstat安装成功!" } # 安装htop function init:htop() { - log::info "[htop]" "安装htop" + log::info "[htop]" "安装htop..." + local host="127.0.0.1" + command::exec "${host}" " + yum -y install htop + htop -v + " + check::exit_code "$?" "htop" "$host 安装htop" "exit" + log::info "[htop]" "htop安装成功!" +} + +# 安装nginx +function init:nginx() { + log::info "[nginx]" "安装nginx..." + local host="127.0.0.1" + command::exec "${host}" " + yum -y install nginx + nginx -v + # sudo systemctl enable nginx + " + check::exit_code "$?" "nginx" "$host 安装nginx" "exit" + log::info "[nginx]" "nginx安装成功!" } # 安装nodejs环境 function init:nodejs() { - log::info "[nodejs]" "安装nodejs环境" + log::info "[nodejs]" "安装nodejs环境..." + local host="127.0.0.1" + command::exec "${host}" " + curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash - + yum -y install nodejs + npm install --global yarn + # 配置npm源 + npm config set registry https://registry.npm.taobao.org + npm config set disturl https://npm.taobao.org/dist + npm config set electron_mirror https://npm.taobao.org/mirrors/electron/ + npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ + npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/ + # 配置yarn源 + yarn config set registry https://registry.npm.taobao.org -g + yarn config set disturl https://npm.taobao.org/dist -g + yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ -g + yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g + yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/ -g + yarn config set chromedriver_cdnurl https://cdn.npm.taobao.org/dist/chromedriver -g + yarn config set operadriver_cdnurl https://cdn.npm.taobao.org/dist/operadriver -g + yarn config set fse_binary_host_mirror https://npm.taobao.org/mirrors/fsevents -g + " + # sudo chown -R $(id -u):$(id -g) /data/jenkins-agent + check::exit_code "$?" "nodejs" "$host 安装nodejs环境" "exit" + log::info "[nodejs]" "安装nodejs环境成功!" } # 安装java环境 function init:java() { - log::info "[java]" "安装java环境" + log::info "[java]" "安装java环境..." + local host="127.0.0.1" } # 安装gradle环境 function init:gradle() { - log::info "[gradle]" "安装gradle环境" + log::info "[gradle]" "安装gradle环境..." + local host="127.0.0.1" } # 安装maven环境 function init:maven() { - log::info "[maven]" "安装maven环境" + log::info "[maven]" "安装maven环境..." + local host="127.0.0.1" } # 安装jenkins环境 function init:jenkins() { - log::info "[jenkins]" "安装jenkins环境" + log::info "[jenkins]" "安装jenkins环境..." + local host="127.0.0.1" } ###################################################################################################### @@ -316,6 +381,7 @@ Flag: -git 是否安装git环境, 默认: '1' -dstat 是否安装dstat, 默认: '1' -htop 是否安装htop, 默认: '1' + -nginx 是否安装nginx, 默认: '1' -nodejs 是否安装nodejs环境, 默认: '1' -java 是否安装java环境, 默认: '1' -gradle 是否安装gradle环境, 默认: '1' @@ -360,6 +426,9 @@ while [ "${1:-}" != "" ]; do -htop ) shift HTOP_TAG=${1:-HTOP_TAG} ;; + -nginx ) shift + NGINX_TAG=${1:-NGINX_TAG} + ;; -nodejs ) shift NODEJS_TAG=${1:-NODEJS_TAG} ;; @@ -389,6 +458,7 @@ if [[ "${INIT_TAG:-}" == "1" ]]; then [[ "${GIT_TAG:-}" == "1" ]] && { init:git; } [[ "${DSTAT_TAG:-}" == "1" ]] && { init:dstat; } [[ "${HTOP_TAG:-}" == "1" ]] && { init:htop; } + [[ "${NGINX_TAG:-}" == "1" ]] && { init:nginx; } [[ "${NODEJS_TAG:-}" == "1" ]] && { init:nodejs; } [[ "${JAVA_TAG:-}" == "1" ]] && { init:java; } [[ "${GRADLE_TAG:-}" == "1" ]] && { init:gradle; }