#/bin/sh
pushd /data
if ! command -v docker >/dev/null 2>&1 ; then
  wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-20.10.9.tgz
  tar -zxvf docker-20.10.9.tgz
  mv docker/* /usr/bin/
  groupadd  docker
  cat > /usr/lib/systemd/system/docker.service << EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
chmod +x /usr/lib/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
systemctl enable docker
fi

if ! command -v docker-compose >/dev/null 2>&1 ; then
  curl -L https://gh-proxy.com/https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64 -o  /usr/local/bin/docker-compose
  chmod +x /usr/local/bin/docker-compose
fi

if ! command -v git > /dev/null 2>&1 ; then
  echo '请安装Git'
  return 1;
fi

git clone https://opencode.jsaix.cn/chenc/aix-docker.git /data/aix-docker

cd /data/aix-docker
docker-compose up --build -d