Added environment configuration for scripts

Necessary to ensure machines are properly configured for running these
scripts on either Apple Silicon or Intel based machines.
This commit is contained in:
Brooke Kuhlmann
2021-02-22 19:49:58 -07:00
parent e4ef33a5f6
commit ec441aefef
2 changed files with 17 additions and 0 deletions

View File

@@ -23,6 +23,8 @@ else
exit 1
fi
configure_environment
while true; do
if [[ $# == 0 ]]; then
printf "\nUsage: run OPTION\n"

View File

@@ -101,3 +101,18 @@ get_install_root() {
esac
}
export -f get_install_root
# Configures shell for new machines and ensures PATH is properly configured for running scripts.
# Parameters: None.
configure_environment() {
if [[ ! -s "$HOME/.bash_profile" ]]; then
printf "%s\n" "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" > "$HOME/.bash_profile"
fi
if [[ ! -s "$HOME/.bashrc" ]]; then
printf "%s\n" 'export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"' > "$HOME/.bashrc"
fi
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/sbin:/usr/local/sbin:/usr/sbin:/sbin:$PATH"
}
export -f configure_environment