-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
43 lines (36 loc) · 1.31 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Check for Java 11 installation
if [[ -z $(java -version 2>&1 | grep "version \"11") ]]; then
echo "Java 11 not found. Installing..."
sudo apt-get update
sudo apt-get install openjdk-11-jdk -y
fi
# Check for Python 3.7 installation
if [[ -z $(python3.7 -V 2>&1 | grep "Python 3.7") ]]; then
echo "Python 3.7 not found. Installing..."
sudo apt-get update
sudo apt-get install python3.7 -y
fi
# Check for Conda installation
conda create -n pyflink python=3.8 -y
conda activate pyflink
python -m pip install apache-flink pyflink
# Download and extract PyFlink
echo "Downloading PyFlink..."
wget https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=flink/flink-1.16.1/flink-1.16.1-bin-scala_2.12.tgz -O flink.tgz
echo "Extracting PyFlink..."
tar -xzf flink.tgz
rm flink.tgz
mv flink-* pyflink
# Set environment variables
echo "Setting environment variables..."
export FLINK_CONDA_HOME=$(pwd)/pyflink
export PATH=$FLINK_CONDA_HOME/bin:$PATH
export PYTHONPATH=$FLINK_CONDA_HOME/python:$PYTHONPATH
# Set aliases for zsh
echo "Setting aliases for zsh..."
echo 'alias flink="flink run -p 1 -c"' >> ~/.zshrc
echo 'alias flink-submit="flink run -p 1 -m yarn-cluster -ynm PyFlink"' >> ~/.zshrc
echo 'alias flink-stop="flink cancel PyFlink"' >> ~/.zshrc
# Done!
echo "PyFlink setup complete."