#!/bin/bash

if [[ -n $(docker ps -qa -f "name=api_iris") ]]; then
  cd /data/web/myweb
  docker-compose down
fi
cd /data/web
if [[ -d "myweb_$(date +%Y%m%d)" ]]; then
  rm -rf myweb_$(date +%Y%m%d)
fi
if [[ -d "myweb" ]]; then
  mv myweb myweb_$(date +%Y%m%d)
fi
mkdir myweb
cp /mnt/build/build.zip myweb
cd myweb
unzip build.zip
chmod 755 -R /data/web/myweb
cd /data/web/myweb
bash update.sh $@
