#! /bin/bash DIR=$HOME/.arc; while getopts d: opt; do case $opt in d) DIR=$OPTARG ;; esac done LIBPHUTIL_DIR=$DIR/libphutil; ARCANIST_DIR=$DIR/arcanist; command -v git >/dev/null 2>&1 || { echo "Git is not installed. Installing git..." >&2; sudo apt-get install git; } command -v php5 >/dev/null 2>&1 || { echo "php5 is not installed. Installing php5..." >&2; sudo apt-get install php5 php5-curl; } # curl check curl_check_command="php5 -r \"echo function_exists('curl_version');\""; CURL_CHECK=$(eval "$curl_check_command"); if [[ "$CURL_CHECK" -ne 1 ]]; then echo "php5-curl is not installed. Installing php5-curl..."; sudo apt-get install php5-curl; CURL_CHECK=$(eval "$curl_check_command"); if [[ "$CURL_CHECK" -ne 1 ]]; then echo "Unable to install php5-curl. Aborting!"; exit 1; fi; fi; echo "All dependencies installed!"; echo "Installing arcanist in $DIR"; mkdir -p "$DIR"; if [ -d "$LIBPHUTIL_DIR" ]; then echo "Found $LIBPHUTIL_DIR already present. Skipping libphutil cloning."; else echo "Cloning libphutil..."; git clone https://github.com/phacility/libphutil.git "$LIBPHUTIL_DIR"; fi; printf "\n"; if [ -d "$ARCANIST_DIR" ]; then echo "Found $ARCANIST_DIR already present. Skipping arcanist cloning."; else echo "Cloning arcanist..."; git clone https://github.com/phacility/arcanist.git "$ARCANIST_DIR"; fi; printf "\n"; BASH_RC=$HOME/.bashrc; BASH_PROFILE=$HOME/.bash_profile; PROFILE_FILE=""; PATH_STR="export PATH=\"$ARCANIST_DIR/bin/:\$PATH\""; BASH_COMPLETION_STR="source $ARCANIST_DIR/resources/shell/bash-completion" if [ -f "$BASH_RC" ]; then echo "Adding PATH in $BASH_RC"; PROFILE_FILE="$BASH_RC"; elif [ -f "$BASH_PROFILE" ]; then echo "Unable to find $BASH_RC. Found $BASH_PROFILE. Adding PATH in $BASH_RC"; PROFILE_FILE="$BASH_PROFILE"; else echo "Unable to find $BASH_RC or $BASH_PROFILE. Aborting!"; echo "Add \"$PATH_STR\" in your profile file."; echo "Add \"$BASH_COMPLETION_STR\" in your profile file to enable tab-completion for arc"; exit 1; fi; if [[ :$PATH: == *:"$PROFILE_FILE":* ]] ; then echo "$PROFILE_FILE is already present in \$PATH. Skipping." else echo "$PATH_STR" >> "$PROFILE_FILE"; echo "$BASH_COMPLETION_STR" >> "$PROFILE_FILE"; fi printf "\033[0;32m"; cat <