Skip to content

Instantly share code, notes, and snippets.

@zk-1
Last active January 7, 2022 21:45
Show Gist options
  • Save zk-1/8e64094b999aab90a044e89c5f944c4b to your computer and use it in GitHub Desktop.
Save zk-1/8e64094b999aab90a044e89c5f944c4b to your computer and use it in GitHub Desktop.
Install GAMADV-XTD3 alongside GAM
#!/usr/bin/env bash
# Name: Install GAMADV-XTD3 alongside GAM
# Usage: ./install_GAMADV-XTD3_alongside_GAM.sh
# Description: Installs latest version of GAMADV-XTD3 alongside GAM, and creates 'gam3' alias for it
# Author: Zoë Kelly (zoe@starshade.ca)
# License: MIT
# Created: 2021-12
# Updated:
## Note: For macOS only, and assumes original GAM was installed in the regular way
is_macos() { uname -s | grep -qs "Darwin"; }
shh() { "$@" > /dev/null 2>&1; }
bin_exists() { shh type "$@"; }
bold_and_blue() { tput setaf 4; tput bold; }
bold_and_yellow() { tput setaf 3; tput bold; }
bold_and_red() { tput setaf 1; tput bold; }
reset_font() { tput sgr0; }
bold_and_blue
if ! is_macos; then echo "This script currently only supports macOS"; exit; fi
if ! bin_exists jq; then echo "'jq' binary not found. Please install using 'brew install jq'"; exit; fi
echo "Welcome!"
reset_font
if [[ ! -d "$HOME/gam3_config" ]]; then
mkdir "$HOME/gam3_config"
else
bold_and_red
read -rp "The gam3_config folder already exists. Do you need to erase and reinstall GAMADV-XTD3 and associated configs? (y/n): " reinstall_choice
reset_font
if [[ "$reinstall_choice" == "y" ]]; then
rm -rf "$HOME/bin/gamadv-xtd3"
rm -rf "$HOME/gam3_config"
mkdir "$HOME/gam3_config"
echo "Reset complete"
else
echo "Script aborted."
exit
fi
fi
if [[ ! -d "$HOME/GAMWork" ]]; then mkdir "$HOME/GAMWork"; fi
echo "Installing GAMADV-XTD3..."
if [[ ! -f "$HOME/bin/gamadv-xtd3/gam" ]]; then
curl -L "$(curl -s https://api.github.com/repos/taers232c/GAMADV-XTD3/releases | jq -r '.[0].assets[] | select(.name | contains("macos")) | .browser_download_url')" -o "/tmp/gam3_latest.tar"
tar -x -f /tmp/gam3_latest.tar -C "$HOME/bin/"
rm -f /tmp/gam3_latest.tar
fi
export OLDGAMPATH="$HOME/bin/gam"
export GAMCFGDIR="$HOME/gam3_config"
echo "export GAMCFGDIR=\"$HOME/gam3_config\"" >> "$HOME/.zshrc"
alias gam3="$HOME/bin/gamadv-xtd3/gam"
echo "alias gam3=\"$HOME/bin/gamadv-xtd3/gam\"" >> "$HOME/.zshrc"
cd "$HOME/bin/gamadv-xtd3"
echo "Verifying GAMADV-XTD3 conf"
./gam config verify
echo
bold_and_blue; echo "Enter your work email below and follow the remaining prompts."; reset_font
./gam update project
rm -f "$HOME/gam3_config/oauth2.txt"
echo
sleep 1
bold_and_blue; echo "In the next section, enter 'c', press return, then follow the remaining prompts."; reset_font
./gam oauth create
echo
bold_and_yellow; echo "You must close and re-open your Terminal (or run 'source $HOME/.zshrc') before using GAMADV-XTD3"
bold_and_blue; echo "'gam3' should be used instead of 'gam' when following any scripts or steps designed for GAMADV-XTD3"
echo "GAMADV-XTD3 install script complete!"
reset_font
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment