Skip to content

Instantly share code, notes, and snippets.

@tenken
Created June 7, 2019 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenken/b1dcf1da05e8ed3a6a20f22e9ce35cc4 to your computer and use it in GitHub Desktop.
Save tenken/b1dcf1da05e8ed3a6a20f22e9ce35cc4 to your computer and use it in GitHub Desktop.
Example project bash file I source after CDing to project direcotry
#!/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