Page MenuHomePhabricator
Paste P1887

Arcanist Installation Shell Script for Linux
ActivePublic

Authored by DheerendraRathor on Nov 11 2015, 9:20 AM.
#! /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 <<EOM
Arcanist Installation Successful!
Run "source $PROFILE_FILE" to reload PATH variable.
Run "arc" to check if it has been installed.
Run "arc install-certificate" to intialize arcanist
EOM
printf '\033[0m'
exit 0;

Event Timeline

DheerendraRathor changed the title of this paste from untitled to Arcanist Installation Shell Script for Linux.Nov 11 2015, 9:20 AM
DheerendraRathor updated the paste's language from autodetect to bash.
DheerendraRathor edited the content of this paste. (Show Details)
DheerendraRathor shifted this object from the S1 Core space to the S3 Hyperspace space.
chad shifted this object from the S3 Hyperspace space to the S1 Core space.Sep 2 2017, 11:57 PM