ソースを参照

Improve deploy script

- Wait for NC instance to be ready to call Let's Encrypt script.
- Add parameter to build or not container images.
multi_domain
ßingen 8年前
コミット
51bbf524bc
1個のファイルの変更38行の追加8行の削除
  1. +38
    -8
      deploy.sh

+ 38
- 8
deploy.sh ファイルの表示

#!/bin/bash #!/bin/bash


STACK_NAME=$1 STACK_NAME=$1

BUILD=$2
if [ -z $BUILD ]; then
BUILD=1;
fi
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo "You must pass stack name as a parameter" echo "You must pass stack name as a parameter"
exit 1 exit 1
docker stack rm ${STACK_NAME} docker stack rm ${STACK_NAME}


# Build images # Build images
docker-compose build
docker push bingen/rpi-openldap
docker push bingen/rpi-mariadb
docker push bingen/rpi-haproxy
docker push bingen/rpi-mailserver
docker push bingen/rpi-nextcloud
docker push bingen/rpi-zoneminder
if [ $BUILD -eq 1 ]; then
docker-compose build
docker push bingen/rpi-openldap
docker push bingen/rpi-mariadb
docker push bingen/rpi-haproxy
docker push bingen/rpi-mailserver
docker push bingen/rpi-nextcloud
docker push bingen/rpi-zoneminder
fi


# Deploy Stack # Deploy Stack
# seen here: https://github.com/docker/docker/issues/29133#issuecomment-278198683 # seen here: https://github.com/docker/docker/issues/29133#issuecomment-278198683
# ##### Add users to LDAP ###### # # ##### Add users to LDAP ###### #


./add_users.sh ${STACK_NAME} ./add_users.sh ${STACK_NAME}

# Wait for Nextcloud
NC_UP=0
while [ $NC_UP -eq 0 ]; do
# TODO: Use docker inspect Go templates
#NC_IP=$(docker network inspect debuen_default | grep -A 3 nextcloud | grep IPv4Address | cut -d':' -f 2 | cut -d'"' -f 2 | cut -d'/' -f 1)
# Find Nextcloud container
SERVICE=nextcloud
host=$(docker stack ps ${STACK_NAME} | grep Running | grep ${SERVICE} | awk '{ print $4 }')
#echo Host=$host
if [ -z $host ]; then
echo "No host found!";
continue;
fi
container=$(ssh $host 'docker ps | grep '${SERVICE}' | cut -f1 -d" "')
#echo Container=$container
if [ -z $container ]; then
echo "Qué me estás container?!";
continue;
fi
NC_IP=$(ssh $host "docker exec ${container} sh -c 'ifconfig eth1' | grep 'inet ' | cut -d':' -f 2 | cut -d' ' -f 1")
curl http://${NC_IP}/index.nginx-debian.html 2>/dev/null | grep title | grep Welcome 1>/dev/null;
NC_UP=$((1 - $?));
done;

./letsencrypt.sh ${STACK_NAME} ./letsencrypt.sh ${STACK_NAME}

読み込み中…
キャンセル
保存