-
-
Save tenken/b1dcf1da05e8ed3a6a20f22e9ce35cc4 to your computer and use it in GitHub Desktop.
Example project bash file I source after CDing to project direcotry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Shell Project Environment Setup toosl. | |
# | |
# Where does this project live. | |
gitroot=`git rev-parse --show-toplevel` | |
help() { # List bash functions defined in environment config. | |
projectsh_path=$(readlink -f "${BASH_SOURCE[0]}") | |
dep_script1="$( dirname "${BASH_SOURCE[0]}" )/src/scripts/build_drupal_site_library.sh" | |
dep_script2="$( dirname "${BASH_SOURCE[0]}" )/src/scripts/005_upgrade_via_d2d_migrate/005.sh" | |
echo "-- Bash Project Functions Available --" | |
echo "$(grep -T "^function" $projectsh_path)" | sed -e 's/function//g' | |
echo "$(grep -T "^function" $dep_script1)" | sed -e 's/function//g' | |
echo "$(grep -T "^function" $dep_script2)" | sed -e 's/function//g' | |
} | |
# Be able to source relative files. | |
# usage: source_relative dir1/foo.sh | |
source_relative() { # Include project relative bash files | |
filepath="$( dirname "${BASH_SOURCE[0]}" )/$1" | |
[[ -e "$filepath" ]] && source $filepath | |
} | |
function remove_apple_files() { # remove apple files from project. | |
find . -iname "._*" -delete | |
} | |
restore_emergency_backup() { | |
set -x | |
drush arr ./E-bkup.tar.gz --destination=$PWD/stage/web --overwrite | |
set +x | |
} | |
# | |
# Project specific functions using Drush, Symfony, Node, whatever. | |
# | |
source_relative src/scripts/build_drupal_site_library.sh | |
source_relative src/scripts/005_upgrade_via_d2d_migrate/005.sh | |
# Point Drush to include this projects configuration file. | |
alias drush="drush --config=$gitroot/drushrc.php --local --strict=0" | |
# list any drush shell-aliases defined within drushrc. | |
echo | |
help | |
echo | |
echo "-- Drush Shell Aliases --" | |
drush sha | |
echo "-- Drush Site Aliases --" | |
drush sa | |
echo | |
add_sitesphp_to_drupal_install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment