Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DanLaufer/09ddf22b63c417de527d75528f471369 to your computer and use it in GitHub Desktop.
Save DanLaufer/09ddf22b63c417de527d75528f471369 to your computer and use it in GitHub Desktop.
Bash - Function to make a new drupal 8 site with lando
function drupalnew
{
if [ "$1" = "--help" ]; then
echo "The drupalnew command takes 2 arguments: drupalnew <sitename | ex: my_site> <version | ex: 8.6.x>"
return 1
fi
if [ "$1" = "--version" ]; then
echo "Drupalnew 0.0.1"
return 1
fi
if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" != "" ]; then
echo "Error: incorrect number of arguments."
echo "The drupalnew command takes 2 arguments: drupalnew <sitename | ex: my_site> <version | ex: 8.6.x>"
return 0
fi
echo 'downloading drupal '$2
echo 'downloading git clone --branch '$2' https://git.drupal.org/project/drupal.git '$1
git clone --branch $2 https://git.drupal.org/project/drupal.git $1
echo 'downloaded drupal '$2' SUCCESSFUL'
echo 'entering '$1
cd $1
echo "name: "$1"" > .lando.yml
echo "recipe: drupal8" >> .lando.yml
echo "config:" >> .lando.yml
echo " webroot: ." >> .lando.yml
echo " php: '7.1'" >> .lando.yml
echo " database: mysql:5.7" >> .lando.yml
echo 'Now you have to answer these lando questions'
sleep 1.5
docker stop $(docker ps -aq)
lando start && lando composer install || echo "error: lando didn't initialize." && return 0
echo '1. Now go to http://'$1'.lndo.site'
echo '2. Fill out the installation stuff.'
echo "3. Use db host: 'database' and db name, unsername, and pw: 'drupal8'"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment