Skip to content

Instantly share code, notes, and snippets.

@brianwebb01
Last active December 3, 2016 18:48
Show Gist options
  • Save brianwebb01/3757a485ce7b8bef60e7e75567caaeea to your computer and use it in GitHub Desktop.
Save brianwebb01/3757a485ce7b8bef60e7e75567caaeea to your computer and use it in GitHub Desktop.
Ottomatik dependencies configuration

Run the dependency installation script on your server with the following command:

curl -sSL https://gist.githubusercontent.com/brianwebb01/3757a485ce7b8bef60e7e75567caaeea/raw/b0755cbbb2d9543802f819ebdd435d86a27e4975/ottomatik_deps.sh | sudo bash
#!/bin/bash
print_msg () {
echo -en "$1\n\n";
}
#########[ Install Software dependencies ]#########
function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
INSTPY=0
PYREQ="2.6.5"
PY=$(which python)
if [ -z "$PY" ]; then
PY3=$(which python3)
if [ -z "$PY3" ]; then
INSTPY=1
print_msg "Valid version of python not found";
else
print_msg "Python3 found, setting up symlink for 'python' to 'python3'";
if [ ! -f /usr/bin/python ]; then
sudo ln -s $PY3 /usr/bin/python
fi
fi
fi
if [ $INSTPY -eq 0 ]; then
PYVER=`python --version 2>&1 | awk '{print $2}'`
if version_gt $PYREQ $PYVER; then
INSTPY=1
print_msg "Insufficient python version, >= $PYREQ required, $PYVER was found";
else
print_msg "Valid version of python found at $PYVER (>= $PYREQ required)";
fi
fi
if [ $INSTPY -eq 1 ]; then
APT=$(which apt)
if [ -z "$APT" ]; then
print_msg "APT package manager not found";
print_msg "!!! MANUAL INSTALL OF Python >= $PYREQ REQUIRED !!!";
exit 1;
fi
sudo apt-get update
sudo apt-get install python -y
fi
PIP=$(which pip)
if [ -z "$PIP" ]; then
print_msg "Python PIP not found, installing...";
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo -H python
fi
print_msg "Checking Python PIP dependencies...";
PIPS=( awscli certifi colorama python-dateutil futures )
for pkg in "${PIPS[@]}"
do
pipF=$(sudo -H pip list --format=legacy | grep $pkg)
if [ -z "$pipF" ]; then
print_msg "PIP package $pkg not found, installing...";
sudo -H pip install $pkg
else
print_msg "Found $pipF, moving on ...";
fi
done
print_msg "\n\nInstallation complete. Now you just need to setup a backup job!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment