Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ os-install:

common-install:
./setup.sh

frontend-only:
./git_sync.sh
rm -f ~/.profile-generated.khan && touch ~/.profile-generated.khan
if [ `uname -s` = Darwin ]; then \
./mac-setup.sh --frontend-only; \
fi
./setup.sh --frontend-only
@echo "*** YOU MUST REBOOT **IF** this was ***"
@echo "*** the first time you've setup ***"
@echo "*** khan-dotfiles (i.e. if you are ***"
@echo "*** onboarding) ***"
@echo "*** (Reboot is required for browser ***"
@echo "*** to pickup CA for khanacademy.dev) ***"
Comment on lines +31 to +43
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonahgoldsaito this is okay for now. I think we'll want to figure out a way to dedupe the code a bit before landing this. I'll do some thinking on how to do that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I noticed the annoying duplication.
TBH I didn't push to hard shaming it with DRY principles 😆

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like, come on newb

15 changes: 11 additions & 4 deletions mac-setup-elevated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ SCRIPT=$(basename $0)
usage() {
cat << EOF
usage: $SCRIPT [options]
--root <dir> Use specified directory as root (instead of HOME).
--root <dir> Use specified directory as root (instead of HOME).
--frontend-only Only install tools needed for frontend development.
EOF
}

# Install in $HOME by default, but can set an alternate destination via $1.
ROOT="${ROOT:-$HOME}"
FRONTEND_ONLY=false

# Process command line arguments
while [[ "$1" != "" ]]; do
Expand All @@ -25,6 +27,9 @@ while [[ "$1" != "" ]]; do
shift
ROOT=$1
;;
--frontend-only)
FRONTEND_ONLY=true
;;
-h | --help)
usage
exit 0
Expand Down Expand Up @@ -72,6 +77,8 @@ fi
# It used to be we needed to install xcode-tools, now homebrew does this for us
#"$DEVTOOLS_DIR"/khan-dotfiles/bin/install-mac-gcc.sh

# We use java for our google cloud dataflow jobs that live in webapp
# (as well as in khan-linter for linting those jobs)
install_mac_java
if [ "$FRONTEND_ONLY" != "true" ]; then
# We use java for our google cloud dataflow jobs that live in webapp
# (as well as in khan-linter for linting those jobs)
install_mac_java
fi
32 changes: 27 additions & 5 deletions mac-setup-normal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,26 @@ tty_bold=`tput bold`
tty_normal=`tput sgr0`

# The directory to which all repositories will be cloned.
ROOT=${1-$HOME}
ROOT="${HOME}"
FRONTEND_ONLY=false

# Process command line arguments
while [[ "$1" != "" ]]; do
case $1 in
-r | --root)
shift
ROOT=$1
;;
--frontend-only)
FRONTEND_ONLY=true
;;
*)
echo "Unknown argument: $1"
exit 1
esac
shift
done

REPOS_DIR="$ROOT/khan"

# Derived path location constants
Expand Down Expand Up @@ -328,11 +347,14 @@ uninstall_node_mac
# The actual installation of these tools is done in `setup_mise` in setup.sh.
install_mise_mac

"$DEVTOOLS_DIR"/khan-dotfiles/bin/mac-setup-postgres.py
if [ "$FRONTEND_ONLY" != "true" ]; then
"$DEVTOOLS_DIR"/khan-dotfiles/bin/mac-setup-postgres.py

install_redis
install_image_utils
install_helpful_tools
fi

install_redis
install_image_utils
install_helpful_tools
install_watchman
install_python_tools
install_fastly
Expand Down
18 changes: 10 additions & 8 deletions mac-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ SCRIPT=$(basename $0)
usage() {
cat << EOF
usage: $SCRIPT [options]
--root <dir> Use specified directory as root (instead of HOME).
--all Install all user apps.
--none Install no user apps.
--root <dir> Use specified directory as root (instead of HOME).
--all Install all user apps.
--none Install no user apps.
--frontend-only Only install tools needed for frontend development.
EOF
}

# Install in $HOME by default, but can set an alternate destination via $1.
ROOT="${ROOT:-$HOME}"
FRONTEND_ONLY_FLAG=""

# Process command line arguments
while [[ "$1" != "" ]]; do
Expand All @@ -30,6 +32,9 @@ while [[ "$1" != "" ]]; do
-n | --none)
APPS="-n"
;;
--frontend-only)
FRONTEND_ONLY_FLAG="--frontend-only"
;;
-h | --help)
usage
exit 0
Expand Down Expand Up @@ -73,11 +78,8 @@ fi

read -p "Press enter to continue..."

# TODO(ericbrown): Pass command line arguments below
# Note that ensure parsing arguments (above) doesn't hide anything

# Run setup that requires sudo access
"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-elevated.sh "$APPS"
"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-elevated.sh $APPS $FRONTEND_ONLY_FLAG

# Run setup that does NOT require sudo access
"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-normal.sh
"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-normal.sh $FRONTEND_ONLY_FLAG
44 changes: 38 additions & 6 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,27 @@
# Bail on any errors
set -e

# Install in $HOME by default, but can set an alternate destination via $1.
ROOT=${1-$HOME}
# Install in $HOME by default, but can set an alternate destination via --root.
ROOT="${HOME}"
FRONTEND_ONLY=false

# Process command line arguments
while [[ "$1" != "" ]]; do
case $1 in
-r | --root)
shift
ROOT=$1
;;
--frontend-only)
FRONTEND_ONLY=true
;;
*)
echo "Unknown argument: $1"
exit 1
esac
shift
done

mkdir -p "$ROOT"

# the directory all repositories will be cloned to
Expand All @@ -36,6 +55,10 @@ DIR=$(dirname "$0")
IS_MAC=$(which sw_vers || echo "")
IS_MAC_ARM=$(test "$(uname -m)" = "arm64" && echo arm64 || echo "")

if [ "$FRONTEND_ONLY" = "true" ] && [ -z "$IS_MAC" ]; then
echo "WARNING: --frontend-only is intended for macOS only and may not work correctly on this system."
fi

# On a clean install of Mac OS X, /opt/homebrew/bin is not in the PATH.
# Thus, stuff installed with the arm64 version of homebrew is not visible.
# (This was not the case on intel macs where /usr/local/bin is in the path
Expand Down Expand Up @@ -175,7 +198,11 @@ clone_webapp() {
# By this point, we must have git and ka-clone working, so a failure likely
# means the user doesn't have access to webapp (it's the only private repo
# we clone here) -- we give a more useful error than just "not found".
kaclone_repo git@github.com:Khan/webapp "$REPOS_DIR/" -p --email="$gitmail" --pre-push-lint || add_fatal_error \
local depth_flag=""
if [ "$FRONTEND_ONLY" = "true" ]; then
depth_flag="--depth=1"
fi
kaclone_repo git@github.com:Khan/webapp "$REPOS_DIR/" -p --email="$gitmail" --pre-push-lint $depth_flag || add_fatal_error \
"Unable to clone Khan/webapp -- perhaps you don't have access? " \
"If you can't view https://github.com/Khan/webapp, ask #it in " \
"Slack to be added."
Expand Down Expand Up @@ -227,7 +254,9 @@ clone_repos() {
clone_kaclone
clone_devtools
clone_webapp
clone_mobile
if [ "$FRONTEND_ONLY" != "true" ]; then
clone_mobile
fi
clone_frontend
kaclone_repair_self
}
Expand Down Expand Up @@ -332,8 +361,11 @@ install_and_setup_gcloud # pre-req: setup_python
install_deps # pre-reqs: clone_repos, install_and_setup_gcloud
install_our_lovely_cli_deps # pre-req: clone_repos, install_deps
install_hooks # pre-req: clone_repos
download_db_dump # pre-req: install_deps
create_pg_databases # pre-req: install_deps

if [ "$FRONTEND_ONLY" != "true" ]; then
download_db_dump # pre-req: install_deps
create_pg_databases # pre-req: install_deps
fi

echo
echo "---------------------------------------------------------------------"
Expand Down