|
|
|
@ -2,63 +2,157 @@ |
|
|
|
|
|
|
|
|
|
# 配置nexus 客户端 |
|
|
|
|
|
|
|
|
|
local_repo=${repo:=10.36.181.67} |
|
|
|
|
repo_type=1 # 1 阿里云 0 本地 |
|
|
|
|
|
|
|
|
|
bar=" |
|
|
|
|
==================================\n |
|
|
|
|
Nexus 客户端配置 \n |
|
|
|
|
1. 配置yum源 \n |
|
|
|
|
2. 配置docker镜像仓库 \n |
|
|
|
|
3. 配置pip源 \n |
|
|
|
|
4. 【未启用】配置npm源 \n |
|
|
|
|
5. 【未启用】配置maven源 \n |
|
|
|
|
6. 配置阿里云源 \n |
|
|
|
|
q. 退出 \n |
|
|
|
|
=================================" |
|
|
|
|
echo -e $bar |
|
|
|
|
read -p "请选择配置项: " num |
|
|
|
|
|
|
|
|
|
if [[ $num -eq 1 ]];then |
|
|
|
|
check_resolv(){ |
|
|
|
|
grep "$1" /etc/hosts &>/dev/null || return 0 |
|
|
|
|
} |
|
|
|
|
check_local(){ |
|
|
|
|
ping -w 2 -c 1 $local_repo &>/dev/null |
|
|
|
|
if [ $? -eq 0 ];then |
|
|
|
|
read -p "已检测到本地仓库,是否继续配置?[yes/no]" yn |
|
|
|
|
if [ $yn = "y" ] || [ $yn = "yes" ] || [ $yn = "YES" ];then |
|
|
|
|
repo_type=0 |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
yum_repo(){ |
|
|
|
|
cd /etc/yum.repos.d/ && \ |
|
|
|
|
dirname=$(mktemp -d repo-XXXXX) |
|
|
|
|
mv *.repo $dirname 2>/dev/null |
|
|
|
|
if [ $repo_type -eq 0 ];then |
|
|
|
|
check_resolv yum.cloud.repo && echo "$local_repo yum.cloud.repo " >> /etc/hosts |
|
|
|
|
echo "开始下载资源,请等待" |
|
|
|
|
for i in nexus-Centos-Base.repo nexus-epel.repo nexus-mysql.repo nexus-docker-ce.repo nexus-kubernetes.repo |
|
|
|
|
do |
|
|
|
|
curl -s -o $i "https://gitea.beyourself.org.cn/newrain001/download/raw/branch/master/repo/$i" |
|
|
|
|
echo "yum 源 $i 配置完成" |
|
|
|
|
sleep 0.5 |
|
|
|
|
done |
|
|
|
|
elif [ $repo_type -eq 1 ];then |
|
|
|
|
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo |
|
|
|
|
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo |
|
|
|
|
echo "阿里云源配置完成" |
|
|
|
|
fi |
|
|
|
|
echo "开始创建缓存" |
|
|
|
|
yum clean all && \ |
|
|
|
|
yum makecache && \ |
|
|
|
|
echo "缓存创建完成" |
|
|
|
|
elif [[ $num -eq 2 ]];then |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
docker_repo(){ |
|
|
|
|
if [ ! -d "/etc/docker/" ]; then |
|
|
|
|
mkdir /etc/docker |
|
|
|
|
fi |
|
|
|
|
if [ $repo_type -eq 0 ];then |
|
|
|
|
check_resolv docker.cloud.repo && echo "$local_repo docker.cloud.repo " >> /etc/hosts |
|
|
|
|
curl -o /etc/docker/daemon.json https://gitea.beyourself.org.cn/newrain001/download/raw/branch/master/repo/nexus-daemon.json |
|
|
|
|
echo "daemon.json 配置完成" |
|
|
|
|
elif [[ $num -eq 3 ]];then |
|
|
|
|
elif [ $repo_type -eq 1 ];then |
|
|
|
|
cat > /etc/docker/daemon.json <<EOF |
|
|
|
|
{ |
|
|
|
|
"registry-mirrors": ["https://pilvpemn.mirror.aliyuncs.com"], |
|
|
|
|
"exec-opts": ["native.cgroupdriver=systemd"], |
|
|
|
|
"log-driver": "json-file", |
|
|
|
|
"log-opts": { |
|
|
|
|
"max-size": "100m" |
|
|
|
|
}, |
|
|
|
|
"storage-driver": "overlay2", |
|
|
|
|
} |
|
|
|
|
EOF |
|
|
|
|
fi |
|
|
|
|
echo "daemon.json 配置完成,请重启docker" |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pip_repo(){ |
|
|
|
|
if [ ! -d $HOME/.pip ]; then |
|
|
|
|
mkdir $HOME/.pip |
|
|
|
|
fi |
|
|
|
|
curl -o $HOME/.pip/pip.conf https://gitea.beyourself.org.cn/newrain001/download/raw/branch/master/repo/pip.conf |
|
|
|
|
if [ $repo_type -eq 0 ];then |
|
|
|
|
check_resolv pip.cloud.repo && echo "$local_repo pip.cloud.repo " >> /etc/hosts |
|
|
|
|
curl -o $HOME/.pip/pip.conf https://gitea.beyourself.org.cn/newrain001/download/raw/branch/master/repo/nexus-pip.conf |
|
|
|
|
elif [ $repo_type -eq 1 ];then |
|
|
|
|
cat > $HOME/.pip/pip.conf <<EOF |
|
|
|
|
[global] |
|
|
|
|
index-url = http://mirrors.aliyun.com/pypi/simple/ |
|
|
|
|
[install] |
|
|
|
|
trusted-host=mirrors.aliyun.com |
|
|
|
|
EOF |
|
|
|
|
fi |
|
|
|
|
echo "pip.conf 配置完成" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
npm_repo(){ |
|
|
|
|
if [ $repo_type -eq 0 ];then |
|
|
|
|
check_resolv npm.cloud.repo && echo "$local_repo npm.cloud.repo " >> /etc/hosts |
|
|
|
|
curl -o $HOME/.npmrc https://gitea.beyourself.org.cn/newrain001/download/raw/branch/master/repo/.npmrc |
|
|
|
|
elif [ $repo_type -eq 1 ];then |
|
|
|
|
cat > $HOME/.npmrc <<EOF |
|
|
|
|
registry=http://registry.npmmirror.com |
|
|
|
|
EOF |
|
|
|
|
fi |
|
|
|
|
echo "npm源 配置完成" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
maven_repo(){ |
|
|
|
|
echo "请替换下列内容到你的maven目录中的settings.xml文件中,注意查看替换内容" |
|
|
|
|
if [ $repo_type -eq 0 ];then |
|
|
|
|
check_resolv maven.cloud.repo && echo "$local_repo maven.cloud.repo " >> /etc/hosts |
|
|
|
|
curl https://gitea.beyourself.org.cn/newrain001/download/raw/branch/master/repo/settings.xml |
|
|
|
|
elif [ $repo_type -eq 1 ];then |
|
|
|
|
cat <<EOF |
|
|
|
|
<mirror> |
|
|
|
|
<id>aliyunmaven</id> |
|
|
|
|
<mirrorOf>*</mirrorOf> |
|
|
|
|
<name>阿里云公共仓库</name> |
|
|
|
|
<url>https://maven.aliyun.com/repository/public</url> |
|
|
|
|
</mirror> |
|
|
|
|
EOF |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_local |
|
|
|
|
if [ $repo_type -eq 1 ];then |
|
|
|
|
bar=" |
|
|
|
|
代码地址:https://gitea.beyourself.org.cn/newrain001/shell-project/src/branch/master/os/get-repo.sh |
|
|
|
|
==================================\n |
|
|
|
|
阿里云源配置 \n |
|
|
|
|
1. 配置阿里云yum源 \n |
|
|
|
|
2. 配置阿里云镜像加速器 \n |
|
|
|
|
3. 配置阿里云pip源 \n |
|
|
|
|
4. 配置阿里云npm源 \n |
|
|
|
|
5. 配置阿里云maven源 \n |
|
|
|
|
q. 退出 \n |
|
|
|
|
==================================\n" |
|
|
|
|
else |
|
|
|
|
bar=" |
|
|
|
|
代码地址:https://gitea.beyourself.org.cn/newrain001/shell-project/src/branch/master/os/get-repo.sh |
|
|
|
|
==================================\n |
|
|
|
|
本地源配置 \n |
|
|
|
|
1. 配置本地yum源 \n |
|
|
|
|
2. 配置本地镜像加速器 \n |
|
|
|
|
3. 配置本地pip源 \n |
|
|
|
|
4. 配置本地npm源 \n |
|
|
|
|
5. 配置本地maven源 \n |
|
|
|
|
q. 退出 \n |
|
|
|
|
==================================\n" |
|
|
|
|
fi |
|
|
|
|
echo -e $bar |
|
|
|
|
read -p "请选择配置项: " num |
|
|
|
|
if [[ $num -eq 1 ]];then |
|
|
|
|
yum_repo |
|
|
|
|
elif [[ $num -eq 2 ]];then |
|
|
|
|
docker_repo |
|
|
|
|
elif [[ $num -eq 3 ]];then |
|
|
|
|
pip_repo |
|
|
|
|
elif [[ $num -eq 4 ]];then |
|
|
|
|
echo "暂不支持" |
|
|
|
|
npm_repo |
|
|
|
|
elif [[ $num -eq 5 ]];then |
|
|
|
|
echo "暂不支持" |
|
|
|
|
elif [[ $num -eq 6 ]];then |
|
|
|
|
cd /etc/yum.repos.d/ && \ |
|
|
|
|
dirname=$(mktemp -d repo-XXXXX) |
|
|
|
|
mv *.repo $dirname 2>/dev/null |
|
|
|
|
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo |
|
|
|
|
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo |
|
|
|
|
echo "阿里云源配置完成" |
|
|
|
|
echo "开始创建缓存" |
|
|
|
|
yum clean all && \ |
|
|
|
|
yum makecache && \ |
|
|
|
|
echo "缓存创建完成" |
|
|
|
|
maven_repo |
|
|
|
|
elif [[ $num == "q" ]];then |
|
|
|
|
exit 0 |
|
|
|
|
else |
|
|
|
|