Skip to content

Instantly share code, notes, and snippets.

@curder
Last active June 3, 2020 09:17
Show Gist options
  • Save curder/59c53f85d281e4fb7293c0e3f0c7f9e8 to your computer and use it in GitHub Desktop.
Save curder/59c53f85d281e4fb7293c0e3f0c7f9e8 to your computer and use it in GitHub Desktop.
initialization CentOS Go Docker environment.
#!/bin/bash
# 更新yum
sudo yum update -y
# 更新依赖
sudo yum install -y git tree bash-completion telnet
# 安装Docker依赖环境
sudo dnf install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce
sudo systemctl start docker && sudo systemctl enable docker # 启动docker
sudo usermod -aG docker $USER
# 安装docker-compose
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
# 安装GO
sudo wget https://dl.google.com/go/go1.14.3.linux-amd64.tar.gz && mkdir -p /usr/local/go && tar xf go1.14.3.linux-amd64.tar.gz && mv go/* /usr/local/go/.
sudo rm -rf go*
sudo cat >> /etc/profile <<'EOL'
# go env config
export GO11MODULE=on
export GOROOT=/usr/local/go
export GOPATH=$HOME
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
EOL
# git别名
sudo cat >> /etc/profile <<'EOL'
# git alias
alias gst="git status"
alias gl="git pull"
alias gp='git push'
alias nah='git reset --hard;git clean -df'
EOL
source /etc/profile && sudo tail -n10 /etc/profile
#!/bin/bash
# 更新依赖
sudo yum install -y git tree bash-completion telnet
# 一键安装docker
sudo curl -sSL https://get.daocloud.io/docker | sh
sudo systemctl start docker && sudo systemctl enable docker # 启动docker
sudo usermod -aG docker $USER
# 安装docker-compose
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
# 安装GO
sudo wget https://dl.google.com/go/go1.14.3.linux-amd64.tar.gz && mkdir -p /usr/local/go && tar xf go1.14.3.linux-amd64.tar.gz && mv go/* /usr/local/go/.
sudo rm -rf go*
sudo cat >> /etc/profile <<'EOL'
# go env config
export GO11MODULE=on
export GOROOT=/usr/local/go
export GOPATH=$HOME
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
EOL
# git别名
sudo cat >> /etc/profile <<'EOL'
# git alias
alias gst="git status"
alias gl="git pull"
alias gp='git push'
alias nah='git reset --hard;git clean -df'
EOL
source /etc/profile && sudo tail -n10 /etc/profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment