Files
LEMPer/scripts/install_dependencies.sh
2023-04-09 17:42:20 +07:00

108 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Dependencies Installer
# Min. Requirement : GNU/Linux Ubuntu 18.04
# Last Build : 12/02/2022
# Author : MasEDI.Net (me@masedi.net)
# Since Version : 1.0.0
# Include helper functions.
if [[ "$(type -t run)" != "function" ]]; then
BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
# shellcheck disable=SC1091
. "${BASE_DIR}/utils.sh"
# Make sure only root can run this installer script.
requires_root "$@"
# Make sure only supported distribution can run this installer script.
preflight_system_check
fi
echo "Installing required dependencies..."
DISTRIB_NAME=${DISTRIB_NAME:-$(get_distrib_name)}
RELEASE_NAME=${RELEASE_NAME:-$(get_release_name)}
# Fix broken install, first?
if [[ "${FIX_BROKEN_INSTALL}" == true ]]; then
run dpkg --configure -a
run apt-get install -q -y --fix-broken
fi
# Update repositories.
echo "Updating repository, please wait..."
run apt-get update -q -y && \
run apt-get upgrade -q -y
# Install dependencies.
echo "Installing packages, be patient..."
run apt-get install -q -y \
apt-transport-https apt-utils autoconf automake bash build-essential ca-certificates \
cmake cron curl dmidecode dnsutils gcc git gnupg2 htop iptables libc-bin libc6-dev \
libcurl4-openssl-dev libgpgme11-dev libssl-dev libpcre3-dev libxml2-dev libxslt1-dev \
libtool locales logrotate lsb-release make net-tools openssh-server openssl pkg-config \
re2c rsync software-properties-common sasl2-bin snmp sudo sysstat tar tzdata unzip wget \
whois xz-utils zlib1g-dev geoip-bin geoip-database gettext libgeoip-dev libpthread-stubs0-dev uuid-dev
# Install Python 3
echo "Installing Python..."
case "${DISTRIB_NAME}" in
debian)
case "${RELEASE_NAME}" in
stretch | buster | bullseye)
run add-apt-repository ppa:deadsnakes/ppa -y && \
run apt-get update -q -y && \
run apt-get install -q -y python3.7 python3.7-dev python3.7-venv \
python3.9 python3.9-dev python3.9-venv python3-pip && \
run update-alternatives --install /usr/bin/python python "$(command -v python3.7)" 37 && \
run update-alternatives --install /usr/bin/python python "$(command -v python3.9)" 39 && \
run update-alternatives --set python /usr/bin/python3.7
;;
esac
;;
ubuntu)
# Install Python
run add-apt-repository ppa:deadsnakes/ppa -y && \
run apt-get update -q -y && \
run apt-get install -q -y python3.7 python3.7-dev python3.7-venv \
python3.9 python3.9-dev python3.9-venv python3-pip && \
run update-alternatives --install /usr/bin/python python "$(command -v python3.7)" 37 && \
run update-alternatives --install /usr/bin/python python "$(command -v python3.9)" 39 && \
run update-alternatives --set python /usr/bin/python3.7
;;
centos | rocky*)
run dnf install -y python3 python3-libs python3-pip-wheel python3-setuptools-wheel \
python39 python39-libs python39-pip-wheel python39-setuptools-wheel && \
run update-alternatives --install /usr/bin/unversioned-python python "$(command -v python3)" 3 && \
run update-alternatives --install /usr/bin/unversioned-python python "$(command -v python3.9)" 39 && \
run update-alternatives --set python /usr/bin/python3
;;
esac
# Update locale
echo "Reconfigure locale..."
run locale-gen --purge en_US.UTF-8 id_ID.UTF-8
# Attended locales reconfiguration causing Terraform provisioning stuck.
if [[ "${AUTO_INSTALL}" != true ]]; then
run dpkg-reconfigure locales
fi
# Configure server clock.
echo "Reconfigure server clock..."
# Reconfigure timezone.
if [[ -n ${TIMEZONE} && ${TIMEZONE} != "none" ]]; then
run bash -c "echo '${TIMEZONE}' > /etc/timezone"
run rm -f /etc/localtime
run dpkg-reconfigure -f noninteractive tzdata
# Save config.
save_config "TIMEZONE=${TIMEZONE}"
fi
success "Required packages installation completed..."