init/centos7-system-install.sh

56 lines
2.0 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#!/bin/sh
tee $HOME/.cargo/config <<-'EOF'
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 如果所处的环境中不允许使用 git 协议,可以把上面的地址改为
#registry = "https://mirrors.ustc.edu.cn/crates.io-index"
[net]
git-fetch-with-cli = true
EOF
# docker加速
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://wbq2uwds.mirror.aliyuncs.com"]
}
EOF
echo "1. 更新系统..."
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
# // 清理源缓存
yum clean all && yum makecache
# // 更新源
yum -y update
yum -y install git openssl-devel
echo "2. 执行 Docker 安装脚本..."
# curl -fsSL https://get.docker.com/ | sh
# curl -sSL https://get.daocloud.io/docker | sh
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
sudo service docker start
systemctl enable docker
echo "3. 验证 docker 是否安装成功并在容器中执行一个测试的镜像..."
sudo docker run hello-world
echo "4. 执行 DockerCompose 安装脚本..."
curl -L https://git.quanzhan.store/open-source/init/raw/branch/master/docker/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose -v
echo "5. 安装Docker软件..."
echo "5.1 portainer..."
docker run -d -p 8888:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /data/portainer/data:/data portainer/portainer-ce:2.11.1-alpine