Add support of configuration file for installation scripts.

This commit is contained in:
Christoph 2020-04-29 15:12:23 +02:00
parent 42e52f1cb1
commit 23fcca1527
6 changed files with 406 additions and 35 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.swp
*/conf/*.conf

View File

@ -3,19 +3,12 @@
cript_name="$(basename $(realpath $0))"
working_dir="$(dirname $(realpath $0))"
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
#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"
DIST="ubuntu"
DIST_RELEASE="xenial"
GREENLIGTH_DIR="/usr/local/greenlight"
FQDN_HOSTNAME="bbb.oopen.de"
HOSTNAME=" ${FQDN_HOSTNAME%%.*}"
# ----------
# Base Function(s)
@ -115,6 +108,35 @@ blank_line() {
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// /}"
}
# ----------
@ -158,6 +180,130 @@ if $terminal ; then
echo -e "\033[1m----------\033[m"
fi
# ----------
# Read Configurations from $conf_file
# ----------
# - Give your default values here
# -
DEFAULT_FQDN_HOSTNAME="$(hostname -f)"
DEFAULT_GREENLIGTH_DIR="/usr/local/greenlight"
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"
[[ -n "$GREENLIGTH_DIR" ]] && DEFAULT_GREENLIGTH_DIR="$GREENLIGTH_DIR"
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%%.*}"
GREENLIGTH_DIR=
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Give the path into install 'greelight':"
echo ""
if [[ -n "$DEFAULT_GREENLIGTH_DIR" ]]; then
while [[ "X${GREENLIGTH_DIR}" = "X" ]]; do
echononl "Full qualified hostname [${DEFAULT_GREENLIGTH_DIR}]: "
read GREENLIGTH_DIR
if [[ "X${GREENLIGTH_DIR}" = "X" ]]; then
GREENLIGTH_DIR=$DEFAULT_GREENLIGTH_DIR
fi
if [[ ! -d "$(dirname "$GREENLIGTH_DIR")" ]]; then
echo -e "\n\tBase directory \033[33m\033[1m$(dirname "$GREENLIGTH_DIR")\033[m not found.\n"
GREENLIGTH_DIR=""
fi
done
else
while [[ "X${GREENLIGTH_DIR}" = "X" ]]; do
echononl "Full qualified hostname: "
read GREENLIGTH_DIR
if [[ "X${GREENLIGTH_DIR}" = "X" ]]; then
echo -e "\n\t\033[33m\033[1mInstall directory is reqired\033[m\n"
fi
if [[ ! -d "$(dirname "$GREENLIGTH_DIR")" ]]; then
echo -e "\n\tBase directory \033[33m\033[1m$(dirname "$GREENLIGTH_DIR")\033[m not found.\n"
GREENLIGTH_DIR=""
fi
done
fi
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 ""
echo -e "\tInstallation directory greenlight..: $GREENLIGTH_DIR"
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 ""
blank_line
# Stop Service if started

View File

@ -1,19 +1,14 @@
#!/usr/bin/env bash
cript_name="$(basename $(realpath $0))"
script_name="$(basename $(realpath $0))"
working_dir="$(dirname $(realpath $0))"
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
#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"
DIST="ubuntu"
DIST_RELEASE="xenial"
FQDN_HOSTNAME="bbb.oopen.de"
HOSTNAME=" ${FQDN_HOSTNAME%%.*}"
# ----------
# Base Function(s)
@ -107,6 +102,35 @@ blank_line() {
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// /}"
}
# ----------
@ -151,6 +175,94 @@ if $terminal ; then
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 ""
# Make the HTML5 client default
#
if $terminal ; then

View File

@ -3,14 +3,12 @@
script_name="$(basename $(realpath $0))"
working_dir="$(dirname $(realpath $0))"
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
#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"
DIST="ubuntu"
DIST_RELEASE="xenial"
# ----------
# Base Function(s)
@ -96,6 +94,35 @@ blank_line() {
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// /}"
}
# ----------
@ -139,18 +166,55 @@ if $terminal ; then
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 "$_FQDN_HOSTNAME" ]]; then
echononl "Full qualified hostname [${_FQDN_HOSTNAME}]: "
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=$_FQDN_HOSTNAME
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: "
@ -158,9 +222,12 @@ else
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 ""
@ -170,6 +237,9 @@ 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,,}
@ -231,14 +301,14 @@ fi
blank_line
echononl "Create sources.list for '$DIST $DIST_RELEASE'.."
echononl "Create sources.list for '$DIST $DIST_CODENAME'.."
cat <<EOF > /etc/apt/sources.list 2> "$log_file"
deb http://archive.ubuntu.com/ubuntu ${DIST_RELEASE} main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu ${DIST_RELEASE}-updates main restricted universe multiverse
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_RELEASE}-security main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu ${DIST_CODENAME}-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu ${DIST_RELEASE}-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu ${DIST_CODENAME}-backports main restricted universe multiverse
EOF
if [[ $? -ne 0 ]]; then
echo_failed
@ -380,7 +450,7 @@ fi
echononl "Add repository for 'mongodb'.."
cat <<EOF > /etc/apt/sources.list.d/mongodb-org-3.4.list 2> "$log_file"
deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu ${DIST_RELEASE}/mongodb-org/3.4 multiverse
deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu ${DIST_CODENAME}/mongodb-org/3.4 multiverse
EOF
if [[ $? -ne 0 ]]; then
echo_failed
@ -447,7 +517,7 @@ fi
#
echononl "Add repository for BigBlueButton 2.2 packages.."
cat <<EOF > /etc/apt/sources.list.d/bigbluebutton.list 2> "$log_file"
deb https://ubuntu.bigbluebutton.org/${DIST_RELEASE}-220/ bigbluebutton-${DIST_RELEASE} main
deb https://ubuntu.bigbluebutton.org/${DIST_CODENAME}-220/ bigbluebutton-${DIST_CODENAME} main
EOF
if [[ $? -ne 0 ]]; then
echo_failed

21
conf/bbb.conf Normal file
View File

@ -0,0 +1,21 @@
#-------------------------------------------
# Settings for BigBlueButoon Install scripts
#-------------------------------------------
# FQDN_HOSTNAME
#
# The full qualified histname under which bbb service
# is available
#
# Defaults to full qualified hostname of the system
#
FQDN_HOSTNAME="mx-bbb.oopen.de"
# GREENLIGTH_DIR
#
# Installation directory of 'greenlight'
#
# Defaults to: GREENLIGTH_DIR="/usr/local/greenlight"
#
#GREENLIGTH_DIR=""

21
conf/bbb.conf.sample Normal file
View File

@ -0,0 +1,21 @@
#-------------------------------------------
# Settings for BigBlueButoon Install scripts
#-------------------------------------------
# FQDN_HOSTNAME
#
# The full qualified histname under which bbb service
# is available
#
# Defaults to full qualified hostname of the system
#
FQDN_HOSTNAME=""
# GREENLIGTH_DIR
#
# Installation directory of 'greenlight'
#
# Defaults to: GREENLIGTH_DIR="/usr/local/greenlight"
#
#GREENLIGTH_DIR=""