Skip to content
Snippets Groups Projects
create-instance.sh 2.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • Vincent Sellier's avatar
    Vincent Sellier committed
    #!/usr/bin/env bash
    
    Vincent Sellier's avatar
    Vincent Sellier committed
    
    
    i-vall's avatar
    i-vall committed
    # creates an instance with the default apps and grand lyon apps installed
    
    
    if [ $# -lt 1 ]; then
    	echo "Usage: $0 <instance url> <oidc if instance should be oidc authenticated>"
    
    Vincent Sellier's avatar
    Vincent Sellier committed
    	exit 1
    fi
    INSTANCE_ID=$1
    
    
    if [ "$2" = "oidc" ]; then
    	OIDC_CONTEXT="--context-name open-id-connect"
    
    else 
      #Use for service Pilote app / No impact for other instance
      OIDC_CONTEXT="--context-name pilotedemo"
      echo "Context pilotedemo added"
    
    Vincent Sellier's avatar
    Vincent Sellier committed
    source .env
    
    TMPFILE=$(mktemp /tmp/cozyXXX)
    
    
    Vincent Sellier's avatar
    Vincent Sellier committed
    echo "Creating instance ${INSTANCE_ID}.${COZY_TLD} ..."
    
    Vincent Sellier's avatar
    Vincent Sellier committed
    
    
    docker-compose exec cozy ./cozy instances add $OIDC_CONTEXT --host 0.0.0.0 --apps drive,collect,settings,home "${INSTANCE_ID}.${COZY_TLD}" | tee "${TMPFILE}"
    
    
    # Install grand lyon apps
    
    docker-compose exec cozy ./cozy konnectors install enedisgrandlyon --domain "${INSTANCE_ID}.${COZY_TLD}" git://forge.grandlyon.com/web-et-numerique/llle_project/enedis-konnector.git#build-dev
    docker-compose exec cozy ./cozy konnectors install grdfgrandlyon --domain "${INSTANCE_ID}.${COZY_TLD}" git://forge.grandlyon.com/web-et-numerique/llle_project/grdf-konnector.git#build-dev
    docker-compose exec cozy ./cozy konnectors install eglgrandlyon --domain "${INSTANCE_ID}.${COZY_TLD}" git://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git#build-dev
    docker-compose exec cozy ./cozy apps install ecolyo --domain "${INSTANCE_ID}.${COZY_TLD}" git://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo.git#build-dev
    docker-compose exec cozy ./cozy apps install pilote --domain "${INSTANCE_ID}.${COZY_TLD}" git://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager.git#build-dev
    
    
    ## To replace by registry://store/something after next cozy-stack release
    
    docker-compose exec cozy ./cozy apps install --domain "${INSTANCE_ID}.${COZY_TLD}" store registry://store/stable | tee -a "${TMPFILE}"
    
    Vincent Sellier's avatar
    Vincent Sellier committed
    
    # TODO find a better way to detect if there was an error
    TOKEN=""
    if [ $(grep -ic ERROR ${TMPFILE}) -eq 0 ]; then
    
    	TOKEN=$(grep token "${TMPFILE}" | cut -f2 -d":" | tr -d '" ')
    
    Vincent Sellier's avatar
    Vincent Sellier committed
    fi
    
    rm "${TMPFILE}"
    
    if [ -z "${TOKEN}" ]; then
    	echo No token found.
    	exit 1
    fi
    
    echo "Open this url on a browser to configure your instance https://$INSTANCE_ID.${COZY_TLD}?registerToken=${TOKEN}"