2020-11-02 04:08:18 +00:00
|
|
|
#!/bin/sh
|
2020-09-18 04:16:15 +00:00
|
|
|
|
2020-11-08 16:26:14 +00:00
|
|
|
DIR=$(dirname "$(readlink -f "$0")")
|
2020-11-02 04:08:18 +00:00
|
|
|
. "$DIR/../env.sh"
|
2020-09-18 04:16:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
# install docker
|
|
|
|
case "$PM" in
|
|
|
|
apt)
|
2020-09-28 04:07:52 +00:00
|
|
|
# snap docker will intefere native docker.io, must be dealt with
|
|
|
|
sudo snap remove --purge docker
|
2021-01-15 07:54:40 +00:00
|
|
|
pm_update
|
2020-11-21 18:07:26 +00:00
|
|
|
sudo apt install -y docker.io
|
2021-01-15 07:54:40 +00:00
|
|
|
"$PDIR/devel/python.sh"
|
2020-09-18 04:16:15 +00:00
|
|
|
sudo pip3 install docker-compose
|
|
|
|
;;
|
|
|
|
pacman)
|
2020-11-21 18:07:26 +00:00
|
|
|
sudo pacman -S --noconfirm --needed docker docker-compose
|
2020-09-18 04:16:15 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
sudo systemctl enable docker
|
|
|
|
sudo systemctl start docker
|
|
|
|
|
|
|
|
# configuration
|
2020-11-02 04:08:18 +00:00
|
|
|
sudo usermod -aG docker "$USER"
|
2020-09-19 01:23:38 +00:00
|
|
|
|
2020-11-09 09:56:32 +00:00
|
|
|
# set mirror for GREAT CHINA
|
|
|
|
if in_china; then
|
|
|
|
sudo mkdir -p /etc/docker
|
2020-09-19 01:23:38 +00:00
|
|
|
if [ -f /etc/docker/daemon.json ]; then
|
|
|
|
# backup
|
2020-11-23 02:00:49 +00:00
|
|
|
if [ ! -f /etc/docker/daemon.bak.json ]; then
|
2020-09-19 01:23:38 +00:00
|
|
|
sudo cp /etc/docker/daemon.json /etc/docker/daemon.bak.json
|
2020-11-23 02:00:49 +00:00
|
|
|
fi
|
2020-09-19 01:23:38 +00:00
|
|
|
# read
|
|
|
|
dj=$(cat /etc/docker/daemon.json)
|
|
|
|
fi
|
2020-11-23 02:00:49 +00:00
|
|
|
if [ -z "$dj" ]; then
|
|
|
|
dj='{}'
|
|
|
|
fi
|
2020-09-22 04:16:06 +00:00
|
|
|
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
|