Browse Source

07env-install-centos.sh

master
lizw 3 years ago
parent
commit
1a8c9dfb8c
  1. 92
      00base/07env-install-centos.sh

92
00base/07env-install-centos.sh

@ -15,8 +15,6 @@ ADD_USER_PASSWORD="MoXF2Zi6u7f7lqZu"
BASE_DIR="/opt" BASE_DIR="/opt"
# 软件 # 软件
#--- nodejs
#--- jdk #--- jdk
JDK_URL="https://d6.injdk.cn/oraclejdk/11/jdk-11.0.16.1_linux-x64_bin.tar.gz" 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" JDK_FILE_NAME="jdk-11.0.16.1_linux-x64_bin.tar.gz"
@ -46,6 +44,7 @@ ADD_USER_TAG="1"
GIT_TAG="1" GIT_TAG="1"
DSTAT_TAG="1" DSTAT_TAG="1"
HTOP_TAG="1" HTOP_TAG="1"
NGINX_TAG="1"
NODEJS_TAG="1" NODEJS_TAG="1"
JAVA_TAG="1" JAVA_TAG="1"
GRADLE_TAG="1" GRADLE_TAG="1"
@ -253,47 +252,113 @@ function init:add_user() {
# 安装git环境 # 安装git环境
function init:git() { function init:git() {
log::info "[git]" "安装git环境..." log::info "[git]" "安装git环境..."
local host="127.0.0.1"
command::exec "${host}" " command::exec "${host}" "
yum install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
yum install git yum -y install git
git --version
git config --global credential.helper store
" "
check::exit_code "$?" "git" "$host 安装git环境" "exit" check::exit_code "$?" "git" "$host 安装git环境" "exit"
log::info "[git]" "git环境安装成功!" 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 # 安装dstat
function init: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 # 安装htop
function init: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环境 # 安装nodejs环境
function init: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环境 # 安装java环境
function init:java() { function init:java() {
log::info "[java]" "安装java环境" log::info "[java]" "安装java环境..."
local host="127.0.0.1"
} }
# 安装gradle环境 # 安装gradle环境
function init:gradle() { function init:gradle() {
log::info "[gradle]" "安装gradle环境" log::info "[gradle]" "安装gradle环境..."
local host="127.0.0.1"
} }
# 安装maven环境 # 安装maven环境
function init:maven() { function init:maven() {
log::info "[maven]" "安装maven环境" log::info "[maven]" "安装maven环境..."
local host="127.0.0.1"
} }
# 安装jenkins环境 # 安装jenkins环境
function init: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' -git 是否安装git环境, 默认: '1'
-dstat 是否安装dstat, 默认: '1' -dstat 是否安装dstat, 默认: '1'
-htop 是否安装htop, 默认: '1' -htop 是否安装htop, 默认: '1'
-nginx 是否安装nginx, 默认: '1'
-nodejs 是否安装nodejs环境, 默认: '1' -nodejs 是否安装nodejs环境, 默认: '1'
-java 是否安装java环境, 默认: '1' -java 是否安装java环境, 默认: '1'
-gradle 是否安装gradle环境, 默认: '1' -gradle 是否安装gradle环境, 默认: '1'
@ -360,6 +426,9 @@ while [ "${1:-}" != "" ]; do
-htop ) shift -htop ) shift
HTOP_TAG=${1:-HTOP_TAG} HTOP_TAG=${1:-HTOP_TAG}
;; ;;
-nginx ) shift
NGINX_TAG=${1:-NGINX_TAG}
;;
-nodejs ) shift -nodejs ) shift
NODEJS_TAG=${1:-NODEJS_TAG} NODEJS_TAG=${1:-NODEJS_TAG}
;; ;;
@ -389,6 +458,7 @@ if [[ "${INIT_TAG:-}" == "1" ]]; then
[[ "${GIT_TAG:-}" == "1" ]] && { init:git; } [[ "${GIT_TAG:-}" == "1" ]] && { init:git; }
[[ "${DSTAT_TAG:-}" == "1" ]] && { init:dstat; } [[ "${DSTAT_TAG:-}" == "1" ]] && { init:dstat; }
[[ "${HTOP_TAG:-}" == "1" ]] && { init:htop; } [[ "${HTOP_TAG:-}" == "1" ]] && { init:htop; }
[[ "${NGINX_TAG:-}" == "1" ]] && { init:nginx; }
[[ "${NODEJS_TAG:-}" == "1" ]] && { init:nodejs; } [[ "${NODEJS_TAG:-}" == "1" ]] && { init:nodejs; }
[[ "${JAVA_TAG:-}" == "1" ]] && { init:java; } [[ "${JAVA_TAG:-}" == "1" ]] && { init:java; }
[[ "${GRADLE_TAG:-}" == "1" ]] && { init:gradle; } [[ "${GRADLE_TAG:-}" == "1" ]] && { init:gradle; }

Loading…
Cancel
Save