2020-09-18 04:16:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DIR=$(readlink -f $(dirname $0))
|
|
|
|
. $DIR/../env.sh
|
|
|
|
|
|
|
|
|
|
|
|
# install docker
|
|
|
|
case "$PM" in
|
|
|
|
apt)
|
|
|
|
sudo apt install -y docker.io docker-compose
|
|
|
|
! which pip3 && $ROOT/python/install.sh
|
|
|
|
sudo pip3 install docker-compose
|
2020-09-22 04:16:06 +00:00
|
|
|
sudo snap install kubectl --classic
|
2020-09-18 04:16:15 +00:00
|
|
|
;;
|
|
|
|
pacman)
|
2020-09-18 18:01:58 +00:00
|
|
|
sudo pacman -S --needed docker docker-compose
|
2020-09-18 04:16:15 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
sudo systemctl enable docker
|
|
|
|
sudo systemctl start docker
|
|
|
|
|
2020-09-19 01:23:38 +00:00
|
|
|
|
|
|
|
|
2020-09-18 04:16:15 +00:00
|
|
|
# configuration
|
|
|
|
sudo usermod -aG docker $USER
|
2020-09-19 01:23:38 +00:00
|
|
|
|
2020-09-22 04:16:06 +00:00
|
|
|
# set mirror
|
|
|
|
if in-china && [[ -d /etc/docker ]]; then
|
2020-09-19 01:23:38 +00:00
|
|
|
if [ -f /etc/docker/daemon.json ]; then
|
|
|
|
# backup
|
|
|
|
[ ! -f /etc/docker/daemon.bak.json ] && \
|
|
|
|
sudo cp /etc/docker/daemon.json /etc/docker/daemon.bak.json
|
|
|
|
# read
|
|
|
|
dj=$(cat /etc/docker/daemon.json)
|
|
|
|
fi
|
2020-09-22 04:16:06 +00:00
|
|
|
[[ -z $dj ]] && dj='{}'
|
|
|
|
echo $dj | jq '. + {"registry-mirrors": ["https://izuhlbap.mirror.aliyuncs.com"]}' | \
|
|
|
|
sudo tee /etc/docker/daemon.json
|
2020-09-19 01:23:38 +00:00
|
|
|
sudo systemctl restart docker
|
|
|
|
fi
|