Skip to content
Snippets Groups Projects
start.sh 2.88 KiB
Newer Older
  • Learn to ignore specific revisions
  •   if [[ -f ".env" ]]; then
        export $(cat .env | xargs) > /dev/null 2>&1
      fi
    
      rm .* > /dev/null 2>&1
    }
    
    function restoreEnvFile {
      if [[ -n ${PHP_VERSION} ]]; then
        echo "PHP_VERSION=${PHP_VERSION}" >>.env
      fi
      if [[ -n ${COMPOSE_PROJECT_NAME} ]]; then
        echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env
      fi
      if [[ -f ".env" ]]; then
        env -i $(cat .env | xargs) >.env
      fi
    }
    
    function create {
      truncateCurrentDirectory
    
      if [[ -n ${REPOSITORY} ]]; then
        composer create-project ${PROJECT} . --no-interaction --repository ${REPOSITORY}
      else
        composer create-project ${PROJECT} . --no-interaction
      fi
    
    
      if [[ -f "docker-compose.yml" ]]; then
        if [[ -f "web/profiles/contrib/config_installer/config_installer.info.yml" ]]; then
          # Start container
          a d4d up
          drush --no-interaction si config_installer
    
          # Init site config values
          if [[ -f "drush/Commands/init_site/init_site.info.yml" ]]; then
            if [[ -f ".init_site.json" ]]; then
              drush init_site ../.init_site.json
            fi
          fi
    
          # Dump database
          if [[ -n ${L3D_DUMP_DB} ]]; then
            git ignore "/*.sql"
            drush sql:dump --result-file ../db.sql
          fi
        fi
      fi
      if [[ -n ${L3D_EXIT} ]]; then
        exit
      fi
    
    function clone {
      truncateCurrentDirectory
      git clone ${REPOSITORY} .
      composer update
      restoreEnvFile
    }
    
    function initialSetup {
    
      echo "Lets start a new project here ..."
      echo ""
      echo "Options to start:"
    
      echo "    0   none: start with an empty container"
    
      echo "    1   LakeDrops Drupal 8 project template"
      echo "    2   Drupal's community project template"
    
      echo "    3   Custom project template"
      echo "    4   Existing git repository"
    
      echo ""
      echo ""
    
      while true; do
          read -p "Choose an option: " OPTION
          case ${OPTION} in
    
    
              1 )
                PROJECT="lakedrops/d8-project"
                create
                break
                ;;
    
              2 )
                PROJECT="drupal-composer/drupal-project:8.x-dev"
                create
                break
                ;;
    
              3 )
    
                read -p "Custom project template: " PROJECT
                read -p "Repository URL (optional): " REPOSITORY
                create
                break
                ;;
    
              4 )
    
                read -p "Repository URL: " REPOSITORY
                if [[ -n "${REPOSITORY}" ]]; then
    
    }
    
    readEnv
    EXISTING=$(ls -1)
    if [[ ! -n "$EXISTING" ]]; then
      if [[ -n ${PROJECT} ]]; then
        create
      elif [[ -n ${REPOSITORY} ]]; then
        clone
      else
        initialSetup
      fi
    
    jurgenhaas's avatar
    jurgenhaas committed
    else
      /usr/bin/fish
    fi