码迷,mamicode.com
首页 > 其他好文 > 详细

contos7 一键安装docker harbor脚本

时间:2020-06-22 10:56:20      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:rbo   $?   root   packet   linu   地址   repo   pac   url   

脚本使用说明:

因为网络问题,请先下载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

contos7 一键安装docker harbor脚本

标签:rbo   $?   root   packet   linu   地址   repo   pac   url   

原文地址:https://blog.51cto.com/13667909/2506305

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!