Skip to content

Instantly share code, notes, and snippets.

@ghego
Last active April 6, 2018 00:30
Show Gist options
  • Save ghego/811cc93e3fc1e8ed14ef7526201eccf4 to your computer and use it in GitHub Desktop.
Save ghego/811cc93e3fc1e8ed14ef7526201eccf4 to your computer and use it in GitHub Desktop.
## Some global parameters that you can change
VERSION=2.3.0
SPARK=spark-$VERSION-bin-hadoop2.7
INSTALL_PATH=$HOME/spark
URL=http://mirrors.ocf.berkeley.edu/apache/spark/spark-$VERSION/$SPARK.tgz
BASH_PROFILE=$HOME/.bash_profile
SPARK_PATH=$INSTALL_PATH/$SPARK
BIN_PATH=$SPARK_PATH/bin
read -p "This script is going to install Spark in $INSTALL_PATH. Proceed (y/n)? " answer
case ${answer:0:1} in
y|Y )
mkdir -p $INSTALL_PATH
cd $INSTALL_PATH
if ! [ -d $SPARK ]; then
if ! [ -f $SPARK.tgz ]; then
curl -o $SPARK.tgz $URL
fi
tar -zxvf $SPARK.tgz
rm $SPARK.tgz
fi
echo "MASTER=local[2] PYSPARK_DRIVER_PYTHON=jupyter PYSPARK_DRIVER_PYTHON_OPTS=notebook pyspark" >> $BIN_PATH/jupyterspark
chmod u+x $BIN_PATH/jupyterspark
read -p "Add Spark to your Path (y/n)? " answer2
case ${answer2:0:1} in
y|Y )
echo "" >> $BASH_PROFILE
echo "# added by $SPARK installer" >> $BASH_PROFILE
echo "export PATH=\"$INSTALL_PATH/$SPARK/bin:\$PATH\"" >> $BASH_PROFILE
;;
* )
;;
esac
echo "Spark successfully installed on your system! Now close this shell and open a new one"
;;
* )
echo "This program is exiting!"
exit;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment