Commit 78676c1f authored by Aral Balkan's avatar Aral Balkan

Updating the install script to handle installations from forks.

parent af949bf0
......@@ -23,6 +23,45 @@ set -e
#
################################################################################
optionInstallEverything=false
optionForkFirst=false
ask() {
# Modified slightly from https://gist.github.com/davejamesmiller/1965569
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
# Ask the question (not using "read -p" as it uses stderr not stdout)
echo "$1 ($prompt) \n"
# Read the answer (use /dev/tty in case stdin is redirected from somewhere else)
# read REPLY </dev/tty
read -e -p "▶ " REPLY
# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi
# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
menu(){
echo ""
echo " ____ _ _ ";
......@@ -32,6 +71,7 @@ menu(){
echo " | |_) | __/ |_| || __/ | ";
echo " |____/ \___|\__|\__\___|_| ";
# Question 1
title="\n\nHej hej! What would you like to install?\n"
prompt="▶ "
options=("Everything (iOS App, Safari Extension, Inspector)" "Just the Inspector")
......@@ -41,17 +81,88 @@ PS3="
$prompt "
select opt in "${options[@]}" "Nothing, get me out of here!"; do
case "$REPLY" in
case "$REPLY" in
1 ) optionInstallEverything=true; break;;
2 ) optionInstallEverything=false; break;;
$(( ${#options[@]}+1 )) ) echo "\nSee you later! :)\n"; exit;;
*) echo "\nOops, I only understand numbers between 1 and 3.";continue;;
esac
done
# Question 2
title="\nShould I fork the repositories before cloning?\n\n• Fork if you want to hack on the code\n and submit merge requests easily.\n\n• Don’t fork if you just want to run Better\n or if you have commit access to the main repositories.\n\n• If you have no idea what any of this means, pick option 2\n (or purchase & install Better from the App Store with a tap) ;)\n"
prompt="▶ "
options=("Fork." "Don’t fork.")
echo "$title"
PS3="
$prompt "
select opt in "${options[@]}" "I have second thoughts about all this, get me out of here!"; do
case "$REPLY" in
1 ) installEverything; break;;
2 ) installInspector; break;;
1 ) optionForkFirst=true; break;;
2 ) optionForkFirst=false; break;;
$(( ${#options[@]}+1 )) ) echo "\nSee you later! :)\n"; break;;
*) echo "\nOops, I only understand numbers between 1 and 3.";continue;;
$(( ${#options[@]}+1 )) ) echo "\nNo worries, we all get cold feet sometimes. Bye! :)\n"; exit;;
*) echo "\nOops, I only understand numbers between 1 and 3.";continue;;
esac
esac
done
#
# If person wants to fork, we need their private token so we can
# automatically fork the repositories via the GitLab API.
#
if [ $optionForkFirst = true ]; then
echo """
Fork, it is!
If you don’t have a GitLab account on Ind.ie yet, please
sign up for one now at:
https://source.ind.ie
To continue,
1. Visit https://source.ind.ie/profile/account
2. Copy your Private Token"""
read -e -p "3. Paste it here: " privateToken
fi
#
# Summarise
#
echo "\nThank you! :)\n\nI’m going to: \n"
if [ $optionInstallEverything = true ]; then
echo "• Install everything (iOS App, Safari Extension, Inspector)\n"
else
echo "• Only install Inspector\n"
fi
if [ $optionForkFirst = true ]; then
echo "• Fork the Better repositories into your own GitLab account\n on source.ind.ie using the private key ${privateToken}"
else
echo "• Without forking (read-only unless you have commit access)"
fi
#
# Confirm.
#
if ask "\nMay I proceed?" Y; then
echo "\n TODO: Proceed.\n"
exit
else
echo "\nSure, no problem, maybe some other time. Bye! :)\n"
exit
fi
}
# Runs command in requested directory and restores the working directory at the end.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment