add -p argument to disable profile update

This commit is contained in:
Jay Lee
2016-11-02 09:33:46 -04:00
parent 6961a0e1b3
commit 3c50f464cc

View File

@@ -10,6 +10,7 @@ OPTIONS:
-d Directory where gam folder will be installed. Default is \$HOME/bin/ -d Directory where gam folder will be installed. Default is \$HOME/bin/
-a Architecture to install (i386, x86_64, arm). Default is to detect your arch with "uname -m". -a Architecture to install (i386, x86_64, arm). Default is to detect your arch with "uname -m".
-o OS we are running (linux, macos). Default is to detect your OS with "uname -s". -o OS we are running (linux, macos). Default is to detect your OS with "uname -s".
-p Profile update (true, false). Should script add gam command to environment. Default is true.
-v Version to install (latest, prerelease, draft, 3.8, etc). Default is latest. -v Version to install (latest, prerelease, draft, 3.8, etc). Default is latest.
EOF EOF
} }
@@ -17,14 +18,16 @@ EOF
target_dir="$HOME/bin" target_dir="$HOME/bin"
gamarch=$(uname -m) gamarch=$(uname -m)
gamos=$(uname -s) gamos=$(uname -s)
update_profile=true
gamversion="latest" gamversion="latest"
while getopts "hd:a:o:v:" OPTION while getopts "hd:a:o:p:v:" OPTION
do do
case $OPTION in case $OPTION in
h) usage; exit;; h) usage; exit;;
d) target_dir=$OPTARG;; d) target_dir=$OPTARG;;
a) gamarch=$OPTARG;; a) gamarch=$OPTARG;;
o) gamos=$OPTARG;; o) gamos=$OPTARG;;
p) update_profile=$OPTARG;;
v) gamversion=$OPTARG;; v) gamversion=$OPTARG;;
?) usage; exit;; ?) usage; exit;;
esac esac
@@ -35,7 +38,10 @@ update_profile() {
grep -F "$alias_line" "$1" > /dev/null 2>&1 grep -F "$alias_line" "$1" > /dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo_yellow "Adding gam alias to profile file $1."
echo -e "\n$alias_line" >> "$1" echo -e "\n$alias_line" >> "$1"
else
echo_yellow "gam alias already exists in profile file $1. Skipping add."
fi fi
} }
@@ -140,14 +146,17 @@ else
fi fi
# Update profile to add gam command # Update profile to add gam command
alias_line="alias gam=$target_dir/gam/gam" if [ "$update_profile" = true ]; then
if [ "$gamos" == "linux" ]; then alias_line="alias gam=$target_dir/gam/gam"
if [ "$gamos" == "linux" ]; then
update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile" update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile"
elif [ "$gamos" == "macos" ]; then elif [ "$gamos" == "macos" ]; then
update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile" update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile"
fi
else
echo_yellow "skipping profile update."
fi fi
echo -e "\n"
while true; do while true; do
read -p "Can you run a full browser on this machine? (usually Y for MacOS, N for Linux if you SSH into this machine) " yn read -p "Can you run a full browser on this machine? (usually Y for MacOS, N for Linux if you SSH into this machine) " yn
case $yn in case $yn in