Skip to content
Open
Changes from 1 commit
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
130 changes: 101 additions & 29 deletions installer/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,114 @@
#!/bin/bash

#SetupTool version to be installed
Comment thread
amanr032 marked this conversation as resolved.
Outdated
SETUPTOOL_VERSION="65.0.0"
PY_VERSION_RE='^3(\.[0-9]+)(\.[0-9])?$'

# Install dependencies
echo Installing dependencies
sudo apt-get install -y make curl wget libltdl7 libseccomp2 libffi-dev gawk apt-transport-https ca-certificates curl gnupg gnupg-agent lsb-release software-properties-common sshpass pv

echo Enabling docker repository
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Update local repositories
echo Updating local repositories
sudo apt-get update

# Install python dependencies
echo Installing Python dependencies
sudo apt-get install -y python3-distutils
sudo apt-get install -y python3-pip
python3 -m pip install -U pip setuptools

# Install ansible if not present
if [ "`which ansible`" != "" ]; then
function install_common_dependencies() {
Comment thread
amanr032 marked this conversation as resolved.
Outdated
echo Installing common dependencies
sudo apt-get install -y make curl wget libltdl7 libseccomp2 libffi-dev gawk apt-transport-https ca-certificates \
curl gnupg gnupg-agent lsb-release software-properties-common sshpass pv

echo Enabling docker repository
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Update local repositories
echo Updating local repositories
sudo apt-get update
Comment thread
amanr032 marked this conversation as resolved.
Outdated
}

# Install Pyenv
function install_pyenv() {
if command -v pyenv 1; then
echo pyenv available
Comment thread
amanr032 marked this conversation as resolved.
Outdated
else
echo Installing Pyenv Dependencies
Comment thread
amanr032 marked this conversation as resolved.
Outdated
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
echo Downloading pyenv
curl https://pyenv.run | bash
export PATH="$HOME/.pyenv/bin:$PATH" && eval "$(pyenv init --path)" \
&& echo -e 'export PATH="$HOME/.pyenv/bin:$PATH"\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
echo Restarting shell
Comment thread
amanr032 marked this conversation as resolved.
Outdated
fi
}

# Install Python
function install_python() {
echo Start Python $PYTHON_VERSION Installtion
Comment thread
amanr032 marked this conversation as resolved.
Outdated
pyenv install $PYTHON_VERSION
pyenv global $PYTHON_VERSION
echo Finish Python Installtion
}

#Upgrade Python if version is below than $PYTHON_VERSION
Comment thread
amanr032 marked this conversation as resolved.
Outdated
function upgrade_python {
PYTHON_VERSION=${1}
if [ -z $PYTHON_VERSION ] || ! [[ $PYTHON_VERSION =~ $re ]]; then
return
fi
if $(dpkg --compare-versions $(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:3])))') "lt" $PYTHON_VERSION); then
install_pyenv
install_python
fi
}

# Install setuptools
function install_setuptools {
IFS=' '
v=`python3 -m pip list | grep -i setuptools | { read _ v; echo $v; }`
if $(dpkg --compare-versions $v "gt" $SETUPTOOL_VERSION); then
python3 -m pip install setuptools==65.0.0
fi
unset IFS v
}


# Install Python Dependencies
function install_python_dependencies() {
echo Installing Python dependencies
sudo apt-get install -y python3-distutils
sudo apt-get install -y python3-pip
python3 -m pip install -U pip
install_setuptools
# Install ansible if not present
Comment thread
amanr032 marked this conversation as resolved.
Outdated
if [ "`which ansible`" != "" ]; then
echo ansible already installed, skipping.
Comment thread
amanr032 marked this conversation as resolved.
Outdated
else
else
echo Installing ansible
python3 -m pip install --user ansible
fi
fi
}


# Install docker if not present
if [ "`which docker`" != "" ]; then
function install_docker() {
if [ "`which docker`" != "" ]; then
echo Docker already installed, skipping.
else
else
echo Installing docker
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
fi
Comment thread
amanr032 marked this conversation as resolved.
Outdated
}


function main() {
install_common_dependencies
upgrade_python ${1}
install_python_dependencies
install_docker
Ensure /usr/local/bin is in path
Comment thread
amanr032 marked this conversation as resolved.
Outdated
export PATH=$PATH:/usr/local/bin
}


# Ensure /usr/local/bin is in path
export PATH=$PATH:/usr/local/bin
# Entry point. START
main ${1}
exec $SHELL