contos7 一键安装docker harbor脚本

脚本使用说明:

因为网络问题,请先下载harbor安装包,然后上传到/root 目录下,再运行脚本
harbor 下载地址:https://github.com/goharbor/harbor/tags 脚本支持任意版本harbor安装

脚本如下:

#!/bin/bash
check_packet()
{ 
  a=`rpm -qa $1 | wc -l`
  [ a == 0 ] && yum install -y $1
}
#the funtion of installing docker
docker_install()
{
  for i in "yum-utils docker-ce docker-ce-cli containerd.io"
  do
        if [ $i = "yum-ntils" ]
        then
                check_packet $i
                yum-config-manager  --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
        else
                check_packet $i
        fi
  done
  systemctl enable docker
  systemctl start docker
}
#the funtion of installing docker-compose
compose_install()
{
  sudo curl -L "https://github.com/docker/compose/releases/download/1.25.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  chmod +x /usr/local/bin/docker-compose
}
#判断harbor安包是否存在
ls harbor-*  /root  > /dev/null  2>&1  
if [ ! $? == 0 ]
  then
        echo "please downlocal the packet of harbor from url https://github.com/goharbor/harbor/tags and copy it to /root"
        exit
  else
        harbor_packet=`ls harbor-*`
fi
#the funtion of installing harbor
harbor_install()
{
  ip = ifconfig ens33 |grep -w inet|awk '{print $2}'
  cd /root && tar  zxf   $harbor_packet
  sed -i "/^hostname =/c hostname = $ip " /root/harbor/harbor.cfg
  ./prepare
  ./install.sh
}

docker_install
compose_install
harbor_install

猜你喜欢

转载自blog.51cto.com/13667909/2506305