Skip to content

Instantly share code, notes, and snippets.

@AllieRays
Last active July 11, 2016 15:55
Show Gist options
  • Save AllieRays/783659426b517245af4ac270c753bc79 to your computer and use it in GitHub Desktop.
Save AllieRays/783659426b517245af4ac270c753bc79 to your computer and use it in GitHub Desktop.
Bash Script for cleaning directories, useful for branch switching with Drupal 8's configuration system.
#!/usr/bin/env bash
SITENAME=sitename
DBPATH=/var/www/$SITENAME/dev.sql
echo ""
echo -n "You are about to destory all of" $SITENAME"'s files not saved in git, drop the database and load a backup. Are you sure you want to do this?[y/n]: "
read YESNO
if [ "$YESNO" == "y" ]
then
git clean -fd; drush sql-drop -y; drush sql-cli < $DBPATH;
# check to see if site with name already exists
echo -n "Do you want to load" $SITENAME"'s configuration? [y/n]:"
read YESNO
if [ "$YESNO" == "y" ]
then
drush config-import -y
else
echo ""
echo "Not loading the configuration. Bye."
echo ""
exit
fi
echo "One Time login"
drush uli
else
echo ""
echo "This is not the droid you are looking for."
echo ""
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment