From fa08736b4f8b256f35f205334064f079de99453b Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 13 Jan 2025 00:32:43 +0100 Subject: [PATCH] Update scripts and docs to support ubunto 20.04 --- README.accounts => README.accounts.18.04 | 0 README.install | 65 --- README.install-20.04 | 127 ++++++ README.install-docker | 59 +++ ...nstall.sh => bbb-greenlight-install.sh.00} | 0 .../bbb-greenlight-install.sh.01 | 0 ...b-pre-install.sh => bbb-pre-install.sh.00} | 0 archive/bbb-pre-install.sh.01 | 370 +++++++++++++++++ bbb-pre-install.sh | 380 ++++++++++++++---- 9 files changed, 862 insertions(+), 139 deletions(-) rename README.accounts => README.accounts.18.04 (100%) delete mode 100644 README.install create mode 100644 README.install-20.04 create mode 100644 README.install-docker rename archive/{bbb-greenlight-install.sh => bbb-greenlight-install.sh.00} (100%) rename bbb-greenlight-install.sh => archive/bbb-greenlight-install.sh.01 (100%) rename archive/{bbb-pre-install.sh => bbb-pre-install.sh.00} (100%) create mode 100755 archive/bbb-pre-install.sh.01 diff --git a/README.accounts b/README.accounts.18.04 similarity index 100% rename from README.accounts rename to README.accounts.18.04 diff --git a/README.install b/README.install deleted file mode 100644 index e31b331..0000000 --- a/README.install +++ /dev/null @@ -1,65 +0,0 @@ -# =================== -# -# see: -# - https://docs.bigbluebutton.org/2.3/install.html -# -# =================== - -FQDN_HOSTNAME="bbb.oopen.de" -ADMIN_EMAIL="ckubu-adm@oopen.de" - -# --- -# 1.) Run script bbb-pre-install.sh -# --- - -/usr/local/src/bigbluebutton/bbb-pre-install.sh - - -# --- -# 2.) Install BigBlueButton -# --- - -wget -qO- https://ubuntu.bigbluebutton.org/bbb-install.sh | bash -s -- -v bionic-230 -s $FQDN_HOSTNAME -e $ADMIN_EMAIL -a -w - - -# You can test your BigBlueButton installation. Open -# -# https://$FQDN_HOSTNAME -# -# enter your name, and click 'Join' to join 'Demo Meeting'. The BigBlueButton client should -# launch in 'Demo Meeting'. - - -# --- -# 3.) Deinstall bbb-demo -# --- - -# Warning: The API demos are installed and accessible from: -# -# https://bbb.oopen.de -# -# and -# -# https://bbb.oopen.de/demo/demo1.jsp -# -# These API demos allow anyone to access your server without authentication -# to create/manage meetings and recordings. They are for testing purposes only. -# If you are running a production system, remove them by running: -# -# apt-get purge bbb-demo -# -apt purge bbb-demo - - -# --- -# 4.) Install Greenlight - Run script bbb-greenlight-install.sh -# --- - -/usr/local/src/bigbluebutton/bbb-greenlight-install.sh - - -# -- -# Installation finished -# -- - -# ===================================================================================== diff --git a/README.install-20.04 b/README.install-20.04 new file mode 100644 index 0000000..1aa8041 --- /dev/null +++ b/README.install-20.04 @@ -0,0 +1,127 @@ +# =================== +# +# see: +# - https://docs.bigbluebutton.org/administration/install/ +# +# =================== + +FQDN_HOSTNAME="bbb.oopen.de" +ADMIN_EMAIL="ckubu-adm@oopen.de" + +FQDN_HOSTNAME="agr-bbb.erpe.org" +ADMIN_EMAIL="agr@vvn-bda.de" + +# === +# 1 Pre-installation checks +# === + + +# --- +# 1.) Run script bbb-pre-install.sh +# --- + +# check that the locale of the server is en_US.UTF-8. +# +cat /etc/default/locale + + +# If you don't see LANG="en_US.UTF-8", enter the following commands to set the local to en_US.UTF-8. +# +apt-get install -y language-pack-en +update-locale LANG=en_US.UTF-8 + + +# --- +# More checks see: https://docs.bigbluebutton.org/administration/install/#pre-installation-checks +# --- + + +# === +# 2. Install +# === + +# --- +# Install BigBlueButton (incl. Greenligth) by running script 'bbb-install.sh' lacally +# --- + +mkdir -p /usr/local/src/bbb + +git clone https://github.com/bigbluebutton/bbb-install.git /usr/local/src/bbb/ + +# run commnad 'bbb-install.sh' +# +# -w Install UFW firewall (recommended) +# -v Install given version of BigBlueButton (e.g. 'focal-270') (required) +# -s Configure server with +# -e Email for Let's Encrypt certbot +# -g Install Greenlight version 3 +# +/usr/local/src/bbb/bbb-install.sh -w -v focal-270 -s ${FQDN_HOSTNAME} -e ${ADMIN_EMAIL} -g + + +# --- +# Install BigBlueButton (incl. Greenligth) directly +# --- + +# Download and pipe downlaoded stream directly through 'bash -s' +# +# -w Install UFW firewall (recommended) +# -v Install given version of BigBlueButton (e.g. 'focal-270') (required) +# -s Configure server with +# -e Email for Let's Encrypt certbot +# -g Install Greenlight version 3 +# +wget -qO- https://raw.githubusercontent.com/bigbluebutton/bbb-install/v2.7.x-release/bbb-install.sh \ + | bash -s -- -w -v focal-270 -s ${FQDN_HOSTNAME} -e ${ADMIN_EMAIL} -g + +/usr/local/src/bigbluebutton/bbb-pre-install.sh + + +# --- +# 2.) Install BigBlueButton +# --- + +wget -qO- https://ubuntu.bigbluebutton.org/bbb-install.sh | bash -s -- -v bionic-230 -s $FQDN_HOSTNAME -e $ADMIN_EMAIL -a -w + + +# You can test your BigBlueButton installation. Open +# +# https://$FQDN_HOSTNAME +# +# enter your name, and click 'Join' to join 'Demo Meeting'. The BigBlueButton client should +# launch in 'Demo Meeting'. + + +# --- +# 3.) Deinstall bbb-demo +# --- + +# Warning: The API demos are installed and accessible from: +# +# https://bbb.oopen.de +# +# and +# +# https://bbb.oopen.de/demo/demo1.jsp +# +# These API demos allow anyone to access your server without authentication +# to create/manage meetings and recordings. They are for testing purposes only. +# If you are running a production system, remove them by running: +# +# apt-get purge bbb-demo +# +apt purge bbb-demo + + +# --- +# 4.) Install Greenlight - Run script bbb-greenlight-install.sh +# --- + +/usr/local/src/bigbluebutton/bbb-greenlight-install.sh + + +# -- +# Installation finished +# -- + +# ===================================================================================== diff --git a/README.install-docker b/README.install-docker new file mode 100644 index 0000000..5eb7ace --- /dev/null +++ b/README.install-docker @@ -0,0 +1,59 @@ +# ---------- +# Eine aktuelle version von docker installieren +# ---------- + + + +# see also: +# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04-de + + +# Schritt 1 - Installieren von Docker +# +apt update + +# einige vorausgesetzte Pakete, damit apt Pakete über HTTPS nutzen kann: +# +apt install apt-transport-https ca-certificates curl software-properties-common + +# GPG-Schlüssel für das offizielle Docker-Repository hinzufügen: +# +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + +# Docker-Repository zu APT-Quellen hinzufügen: +add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" + + +# Paketdatenbank mit den Docker-Paketen aus dem neu hinzugefügten Repo aktiaöisieren: +# +apt update + + +# Note! +# +# Sicherstellen, dass Docker aus dem Docker Repo und nicht aus dem Standard-Ubuntu-Repo +# installiert wird. +# +# dazu ausführen: +# +# apt-cache policy docker-ce +# +# Ausgaber von 'apt-cache policy docker-ce'etwa : +# +# agr-bbb:~ # apt-cache policy docker-ce +# docker-ce: +# Installed: (none) +# Candidate: 5:27.4.1-1~ubuntu.20.04~focal +# Version table: +# 5:27.4.1-1~ubuntu.20.04~focal 500 +# 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages +# .... +# + + +# Docker installieren: +# +apt install docker-ce + + +# !! Docker sollte nun installiert sein und auch nach dem booten automatisch starten. !! diff --git a/archive/bbb-greenlight-install.sh b/archive/bbb-greenlight-install.sh.00 similarity index 100% rename from archive/bbb-greenlight-install.sh rename to archive/bbb-greenlight-install.sh.00 diff --git a/bbb-greenlight-install.sh b/archive/bbb-greenlight-install.sh.01 similarity index 100% rename from bbb-greenlight-install.sh rename to archive/bbb-greenlight-install.sh.01 diff --git a/archive/bbb-pre-install.sh b/archive/bbb-pre-install.sh.00 similarity index 100% rename from archive/bbb-pre-install.sh rename to archive/bbb-pre-install.sh.00 diff --git a/archive/bbb-pre-install.sh.01 b/archive/bbb-pre-install.sh.01 new file mode 100755 index 0000000..ab14a9a --- /dev/null +++ b/archive/bbb-pre-install.sh.01 @@ -0,0 +1,370 @@ +#!/usr/bin/env bash + +script_name="$(basename $(realpath $0))" +working_dir="$(dirname $(realpath $0))" + +#conf_file="${working_dir}/conf/${script_name%%.*}.conf" +conf_file="${working_dir}/conf/bbb.conf" + +LOCK_DIR="/tmp/$(basename $0).$$.LOCK" +log_file="${LOCK_DIR}/${script_name%%.*}.log" + + +# ---------- +# Base Function(s) +# ---------- + +clean_up() { + + # Perform program exit housekeeping + rm -rf "$LOCK_DIR" + blank_line + exit $1 +} + +echononl(){ + if $terminal ; then + echo X\\c > /tmp/shprompt$$ + if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then + echo -e -n " $*\\c" 1>&2 + else + echo -e -n " $*" 1>&2 + fi + rm /tmp/shprompt$$ + fi +} +fatal(){ + echo "" + if $terminal ; then + echo -e " [ \033[31m\033[1mFatal\033[m ] $*" + else + echo -e " [ Fatal ] $*" + fi + echo "" + if $terminal ; then + echo -e " \033[1mScript terminated\033[m.." + else + echo -e " Script terminated.." + fi + echo "" + rm -rf $LOCK_DIR + exit 1 +} +error (){ + echo "" + if $terminal ; then + echo -e " [ \033[31m\033[1mError\033[m ] $*" + else + echo " [ Error ] $*" + fi + echo "" +} + +echo_ok() { + if $terminal ; then + echo -e "\033[85G[ \033[32mok\033[m ]" + fi +} +echo_failed(){ + if $terminal ; then + echo -e "\033[85G[ \033[1;31mfailed\033[m ]" + fi +} +echo_skipped() { + if $terminal ; then + echo -e "\033[85G[ \033[33m\033[1mskipped\033[m ]" + fi +} +echo_wait(){ + if $terminal ; then + echo -en "\033[85G[ \033[5m\033[1m..\033[m ]" + fi +} + +trim() { + local var="$*" + var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters + var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters + echo -n "$var" +} + +blank_line() { + if $terminal ; then + echo "" + fi +} + +detect_os () { + + if $(which lsb_release > /dev/null 2>&1) ; then + + DIST="$(lsb_release -i | awk '{print tolower($3)}')" + DIST_VERSION="$(lsb_release -r | awk '{print tolower($2)}')" + DIST_CODENAME="$(lsb_release -c | awk '{print tolower($2)}')" + + if [[ "$DIST" = "debian" ]]; then + if $(echo "$DIST_VERSION" | grep -q '\.') ; then + DIST_VERSION=$(echo "$DIST_VERSION" | cut --delimiter='.' -f1) + fi + fi + + elif [[ -e "/etc/os-release" ]]; then + + . /etc/os-release + + DIST=$ID + DIST_VERSION=${VERSION_ID} + + fi + + # remove whitespace from DIST and DIST_VERSION + DIST="${DIST// /}" + DIST_VERSION="${DIST_VERSION// /}" + +} + + + +# ---------- +# - Jobhandling +# ---------- + +# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM +# - +trap clean_up SIGHUP SIGINT SIGTERM + +# - Create lock directory '$LOCK_DIR" +# +mkdir "$LOCK_DIR" + + +# ---------- +# - Some checks .. +# ---------- + +# - Running in a terminal? +# - +if [[ -t 1 ]] ; then + terminal=true +else + fatal "Script must run in a terminal." +fi + + +# ========== +# - Begin Main Script +# ========== + +# ---------- +# - Headline +# ---------- + +if $terminal ; then + echo "" + echo -e "\033[1m----------\033[m" + echo -e "\033[32m\033[1mRunning script \033[m\033[1m$script_name\033[32m .. \033[m" + echo -e "\033[1m----------\033[m" +fi + + +# ---------- +# Read Configurations from $conf_file +# ---------- + + +# - Give your default values here +# - +DEFAULT_FQDN_HOSTNAME="$(hostname -f)" + +if [[ -f "$conf_file" ]]; then + source "$conf_file" +else + warn "No configuration file '$conf_file' present.\n + Loading default values.." +fi + +[[ -n "$FQDN_HOSTNAME" ]] && DEFAULT_FQDN_HOSTNAME="$FQDN_HOSTNAME" + + +blank_line +echononl "Detect distribution/release of running OS.." +detect_os > "$log_file" 2>&1 +if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" +else + echo_ok +fi + + +FQDN_HOSTNAME= +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert full qualified hostname for BigBlueButton Service" +echo "" +if [[ -n "$DEFAULT_FQDN_HOSTNAME" ]]; then + while [[ "X${FQDN_HOSTNAME}" = "X" ]]; do + echononl "Full qualified hostname [${DEFAULT_FQDN_HOSTNAME}]: " + read FQDN_HOSTNAME + if [[ "X${FQDN_HOSTNAME}" = "X" ]]; then + FQDN_HOSTNAME=$DEFAULT_FQDN_HOSTNAME + fi + if [[ ! $FQDN_HOSTNAME =~ \. ]]; then + echo -e "\n\tGiven Host \033[33m\033[1m$FQDN_HOSTNAME\033[m seems not to be a full qualified hostname.\n" + FQDN_HOSTNAME="" + fi + done +else + while [[ "X${FQDN_HOSTNAME}" = "X" ]]; do + echononl "Full qualified hostname: " + read FQDN_HOSTNAME + if [[ "X${FQDN_HOSTNAME}" = "X" ]]; then + echo -e "\n\t\033[33m\033[1mFull qualified hostname is reqired\033[m\n" + fi + if [[ ! $FQDN_HOSTNAME =~ \. ]]; then + echo -e "\n\tGiven Host \033[33m\033[1m$FQDN_HOSTNAME\033[m seems not to be a full qualified hostname.\n" + FQDN_HOSTNAME="" + fi + done +fi +HOSTNAME="${FQDN_HOSTNAME%%.*}" + +echo "" +echo "" +echo -e "\t\033[32mStart pre-install script for BigBlueButton Service with the following parameters\033[m" +echo "" +echo -e "\tFull qualified Hostname..: $FQDN_HOSTNAME" +echo -e "\tHostname.................: $HOSTNAME" +echo "" +echo -e "\tOS Distribution..........: $DIST" +echo -e "\tDistribution's codename..: $DIST_CODENAME" +echo "" +echononl "einverstanden (yes/no): " +read OK +OK=${OK,,} +while [ "X$OK" != "Xyes" -a "X$OK" != "Xno" ]; do + echononl "Wrong entry! [yes/no]: " + read OK + OK=${OK,,} +done +[ $OK = "yes" ] || fatal Repeat with other settings.. + +echo "" +echo "" + + +echononl "Set FQDN hostname (IPv4).." +perl -i -n -p -e "s/^127\.0\.1\.1.*/127.0.1.1 $FQDN_HOSTNAME $HOSTNAME/" /etc/hosts > "$log_file" 2>&1 +if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" +else + echo_ok +fi + +blank_line + +echononl "Create sources.list for '$DIST $DIST_CODENAME'.." +cat < /etc/apt/sources.list 2> "$log_file" +deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME} main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME}-updates main restricted universe multiverse + +deb http://security.ubuntu.com/ubuntu ${DIST_CODENAME}-security main restricted universe multiverse + +deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME}-backports main restricted universe multiverse +EOF +if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" +else + echo_ok +fi + +echononl "Update repositories.." +apt-get update > "$log_file" 2>&1 +if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" +else + echo_ok +fi + +echononl "Upgrade System.." +apt-get --yes dist-upgrade > "$log_file" 2>&1 +if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" +else + echo_ok +fi + +blank_line + + +# Set the locale of the server to 'en_US.UTF-8'. + +echononl "Install 'language-pack-en'.." +if $(dpkg -s language-pack-en > /dev/null 2>&1 ) ; then + echo_skipped +else + apt-get install --yes language-pack-en > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + else + echo_ok + fi +fi + +echononl "Set the locale of the server to 'en_US.UTF-8'.." +update-locale LANG=en_US.UTF-8 > "$log_file" 2>&1 +if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" +else + echo_ok +fi + +echononl "Set system environment to 'en_US.UTF-8'.." +systemctl set-environment LANG=en_US.UTF-8 > "$log_file" 2>&1 +if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" +else + echo_ok +fi + +blank_line + + +# BigBlueButton’s components, such as Tomcat, need a source of entropy when starting up. +# +echononl "Install 'haveged'.." +if $(dpkg -s haveged > /dev/null 2>&1 ) ; then + echo_skipped +else + apt-get install --yes haveged > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + else + echo_ok + fi +fi + +echononl "Install 'apt-utils'.." +if $(dpkg -s apt-utils > /dev/null 2>&1 ) ; then + echo_skipped +else + apt-get install --yes apt-utils > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + else + echo_ok + fi +fi + + +clean_up 0 diff --git a/bbb-pre-install.sh b/bbb-pre-install.sh index ab14a9a..0f5512c 100755 --- a/bbb-pre-install.sh +++ b/bbb-pre-install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash - + script_name="$(basename $(realpath $0))" working_dir="$(dirname $(realpath $0))" @@ -60,6 +60,15 @@ error (){ echo "" } +info (){ + if $terminal ; then + echo "" + echo -e " [ \033[32m\033[1mInfo\033[m ] $*" + echo "" + fi +} + + echo_ok() { if $terminal ; then echo -e "\033[85G[ \033[32mok\033[m ]" @@ -176,6 +185,16 @@ fi # - DEFAULT_FQDN_HOSTNAME="$(hostname -f)" +declare -a needed_debian_package_arr=() +NEEDED_DEBIAN_PACKAGES=" + haveged + apt-utils + apt-transport-https + ca-certificates + curl + software-properties-common +" + if [[ -f "$conf_file" ]]; then source "$conf_file" else @@ -239,6 +258,7 @@ echo -e "\tHostname.................: $HOSTNAME" echo "" echo -e "\tOS Distribution..........: $DIST" echo -e "\tDistribution's codename..: $DIST_CODENAME" +echo -e "\tDistribution's version...: $DIST_VERSION" echo "" echononl "einverstanden (yes/no): " read OK @@ -259,112 +279,324 @@ perl -i -n -p -e "s/^127\.0\.1\.1.*/127.0.1.1 $FQDN_HOSTNAME $HOSTNAME/" /etc/ho if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + else echo_ok fi blank_line -echononl "Create sources.list for '$DIST $DIST_CODENAME'.." -cat < /etc/apt/sources.list 2> "$log_file" -deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME} main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME}-updates main restricted universe multiverse - -deb http://security.ubuntu.com/ubuntu ${DIST_CODENAME}-security main restricted universe multiverse - -deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME}-backports main restricted universe multiverse -EOF -if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" -else - echo_ok -fi - -echononl "Update repositories.." -apt-get update > "$log_file" 2>&1 -if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" -else - echo_ok -fi - -echononl "Upgrade System.." -apt-get --yes dist-upgrade > "$log_file" 2>&1 -if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" -else - echo_ok -fi +#echononl "Create sources.list for '$DIST $DIST_CODENAME'.." +#cat < /etc/apt/sources.list 2> "$log_file" +#deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME} main restricted universe multiverse +#deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME}-updates main restricted universe multiverse +# +#deb http://security.ubuntu.com/ubuntu ${DIST_CODENAME}-security main restricted universe multiverse +# +#deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME}-backports main restricted universe multiverse +#EOF +#if [[ $? -ne 0 ]]; then +# echo_failed +# error "$(cat "$log_file")" +#else +# echo_ok +#fi blank_line +# --- +# Install missing Debian packages +# --- + +echo "" +echo -e " \033[1m---\033[m" +echo -e " \033[32mInstall missing Debian packages\033[m" +echo -e " \033[1m---\033[m" +echo "" + + +_error=false +: > $log_file +blank_line +echononl "Check if needed packages are installed.." +for _pkg in $NEEDED_DEBIAN_PACKAGES ; do + if aptitude search "$_pkg" | grep " $_pkg " | grep -e "^i" >> "$log_file" 2>&1 ; then + continue + else + needed_debian_package_arr+=("$_pkg") + fi + [[ $? -gt 0 ]] && _error=true +done +if $_error ; then + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + +else + echo_ok +fi + +if [[ ${#needed_debian_package_arr[@]} -gt 0 ]]; then + + echononl "Update repositories.." + apt-get update > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + + echononl "Upgrade System.." + DEBIAN_FRONTEND=noninteractive apt-get full-upgrade --assume-yes > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + + for _debian_pkg in ${needed_debian_package_arr[@]} ; do + + echononl "Installing $_debian_pkg .." + + DEBIAN_FRONTEND=noninteractive apt-get -y install $_debian_pkg > "$log_file" 2>&1 + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + fi + done + +else + echo_ok +fi +else + info "All needed debian packages already installed." +fi + + +# --- # Set the locale of the server to 'en_US.UTF-8'. - -echononl "Install 'language-pack-en'.." -if $(dpkg -s language-pack-en > /dev/null 2>&1 ) ; then - echo_skipped -else - apt-get install --yes language-pack-en > "$log_file" 2>&1 +# --- + +echo "" +echo -e " \033[1m---\033[m" +echo -e " \033[32mCheck locale settings - should be \033[1men_US.UTF-8\033[m" +echo -e " \033[1m---\033[m" +echo "" + +if $(grep -Eq "LANG=\"?en_US.UTF-8\"?" /etc/default/locale) ; then + + echononl "Take care \033[1mLANG=en_US.UTF-8\033[m is only the single line of /etc/default/locale" + echo "LANG=en_US.UTF-8" > /etc/default/locale 2> /dev/null if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi +else + + echononl "Install 'language-pack-en'.." + if $(dpkg -s language-pack-en > /dev/null 2>&1 ) ; then + echo_skipped + else + DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes language-pack-en > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + fi + + echononl "Set the locale of the server to 'en_US.UTF-8'.." + update-locale LANG=en_US.UTF-8 > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + fi -echononl "Set the locale of the server to 'en_US.UTF-8'.." -update-locale LANG=en_US.UTF-8 > "$log_file" 2>&1 -if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" -else - echo_ok -fi +info "The settings in the \033[1etc/default/locale\033[m file are correct." + echononl "Set system environment to 'en_US.UTF-8'.." -systemctl set-environment LANG=en_US.UTF-8 > "$log_file" 2>&1 -if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" +if $(systemctl show-environment | grep -Eq "LANG=\"?en_US.UTF-8\"?") ; then + echo_skipped else - echo_ok + systemctl set-environment LANG=en_US.UTF-8 > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi fi blank_line -# BigBlueButton’s components, such as Tomcat, need a source of entropy when starting up. -# -echononl "Install 'haveged'.." -if $(dpkg -s haveged > /dev/null 2>&1 ) ; then - echo_skipped -else - apt-get install --yes haveged > "$log_file" 2>&1 + +# --- +# Install latest version of docker +# --- + +echo "" +echo -e " \033[1m---\033[m" +echo -e " \033[32m\Install latest version of docker033[m" +echo -e " \033[1m---\033[m" +echo "" + +:> "$log_file" +if ! $(grep -Eq "^\s*deb\s+.*https://download.docker.com/linux/ubuntu\s+$DIST_CODENAME\s+stable" /etc/apt/sources.list) \ + && ! $(grep -r -Eq "^\s*deb\s+.*https://download.docker.com/linux/ubuntu\s+$DIST_CODENAME\s+stable" /etc/apt/sources.list.d/*) +then + echononl "Add GPG key for official Docker repository.." + curl -fsSL https://download.docker.com/linux/ubuntu/gpg 2> "$log_file" | apt-key add - >> "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + + echononl "Update repositories.." + apt-get update > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + +else + info "Docker repository already present." +fi + +echononl "Install docker-ce .." + +if $(dpkg -s docker-ce> /dev/null 2>&1 ) ; then + echo_skipped +else + DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes language-pack-en > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + else echo_ok fi fi -echononl "Install 'apt-utils'.." -if $(dpkg -s apt-utils > /dev/null 2>&1 ) ; then - echo_skipped -else - apt-get install --yes apt-utils > "$log_file" 2>&1 - if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" - else - echo_ok - fi -fi - - clean_up 0