Skip to content
Snippets Groups Projects
Commit 42a28da5 authored by jurgenhaas's avatar jurgenhaas
Browse files

customer/bison/core#3 Improve automation such that L3D does all the initial...

customer/bison/core#3 Improve automation such that L3D does all the initial site setup if the required parameters are available
parent dc187295
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
function truncateCurrentDirectory { function readEnv {
if [[ -f ".env" ]]; then if [[ -f ".env" ]]; then
export $(cat .env | xargs) > /dev/null 2>&1 export $(cat .env | xargs) > /dev/null 2>&1
fi fi
}
function truncateCurrentDirectory {
readEnv
rm .* > /dev/null 2>&1 rm .* > /dev/null 2>&1
} }
...@@ -21,19 +25,54 @@ function restoreEnvFile { ...@@ -21,19 +25,54 @@ function restoreEnvFile {
function create { function create {
truncateCurrentDirectory truncateCurrentDirectory
composer create-project ${PROJECT} . --no-interaction if [[ -n ${REPOSITORY} ]]; then
composer create-project ${PROJECT} . --no-interaction --repository ${REPOSITORY}
else
composer create-project ${PROJECT} . --no-interaction
fi
restoreEnvFile restoreEnvFile
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
} }
EXISTING=$(ls -1) function clone {
if [[ ! -n "$EXISTING" ]]; then truncateCurrentDirectory
git clone ${REPOSITORY} .
composer update
restoreEnvFile
}
function initialSetup {
echo "Lets start a new project here ..." echo "Lets start a new project here ..."
echo "" echo ""
echo "Options to start:" echo "Options to start:"
echo " 0 none: start with an empty container" echo " 0 none: start with an empty container"
echo " 1 LakeDrops Drupal 8 project template" echo " 1 LakeDrops Drupal 8 project template"
echo " 2 Drupal's community project template" echo " 2 Drupal's community project template"
echo " 3 Existing git repository" echo " 3 Custom project template"
echo " 4 Existing git repository"
echo "" echo ""
echo "" echo ""
...@@ -41,6 +80,7 @@ if [[ ! -n "$EXISTING" ]]; then ...@@ -41,6 +80,7 @@ if [[ ! -n "$EXISTING" ]]; then
read -p "Choose an option: " OPTION read -p "Choose an option: " OPTION
case ${OPTION} in case ${OPTION} in
0 ) 0 )
restoreEnvFile
break break
;; ;;
...@@ -57,12 +97,16 @@ if [[ ! -n "$EXISTING" ]]; then ...@@ -57,12 +97,16 @@ if [[ ! -n "$EXISTING" ]]; then
;; ;;
3 ) 3 )
read -p "Custom project template: " PROJECT
read -p "Repository URL (optional): " REPOSITORY
create
break
;;
4 )
read -p "Repository URL: " REPOSITORY read -p "Repository URL: " REPOSITORY
if [[ -n "${REPOSITORY}" ]]; then if [[ -n "${REPOSITORY}" ]]; then
truncateCurrentDirectory clone
git clone ${REPOSITORY} .
composer update
restoreEnvFile
break break
fi fi
;; ;;
...@@ -72,9 +116,20 @@ if [[ ! -n "$EXISTING" ]]; then ...@@ -72,9 +116,20 @@ if [[ ! -n "$EXISTING" ]]; then
;; ;;
esac esac
done done
}
readEnv
EXISTING=$(ls -1)
if [[ ! -n "$EXISTING" ]]; then
if [[ -n ${PROJECT} ]]; then
create
elif [[ -n ${REPOSITORY} ]]; then
clone
else
initialSetup
fi
fi fi
restoreEnvFile
if [[ -x "${L3DSHELL}" ]]; then if [[ -x "${L3DSHELL}" ]]; then
${L3DSHELL} ${L3DSHELL}
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment