Initial commit
This commit is contained in:
commit
7bc8abf043
443
bbb-pre-install.sh
Executable file
443
bbb-pre-install.sh
Executable file
@ -0,0 +1,443 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cript_name="$(basename $(realpath $0))"
|
||||
working_dir="$(dirname $(realpath $0))"
|
||||
|
||||
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
|
||||
|
||||
LOCK_DIR="/tmp/$(basename $0).$$.LOCK"
|
||||
log_file="${LOCK_DIR}/${script_name%%.*}.log"
|
||||
|
||||
DIST="ubuntu"
|
||||
DIST_RELEASE="xenial"
|
||||
|
||||
|
||||
# ----------
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ----------
|
||||
# - 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
|
||||
|
||||
|
||||
# /etc/resolf.conf
|
||||
#
|
||||
echononl "Remove symlink '/etc/resolv.conf'.."
|
||||
if [[ -h "/etc/resolv.conf" ]]; then
|
||||
rm /etc/resolv.conf > $log_file 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
echononl "Create new file '/etc/resolf.conf'.."
|
||||
cat <<EOF > /etc/resolv.conf 2> $log_file
|
||||
### Hetzner Online GmbH installimage
|
||||
# nameserver config
|
||||
nameserver 213.133.100.100
|
||||
nameserver 213.133.98.98
|
||||
nameserver 213.133.99.99
|
||||
nameserver 2a01:4f8:0:1::add:9898
|
||||
nameserver 2a01:4f8:0:1::add:1010
|
||||
nameserver 2a01:4f8:0:1::add:9999
|
||||
EOF
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
blank_line
|
||||
|
||||
echononl "Create sources.list for '$DIST $DIST_RELEASE'.."
|
||||
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://security.ubuntu.com/ubuntu ${DIST_RELEASE}-security main restricted universe multiverse
|
||||
|
||||
deb http://archive.ubuntu.com/ubuntu ${DIST_RELEASE}-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 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'.."
|
||||
apt-get install language-pack-en > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
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'.."
|
||||
apt-get install haveged > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
echononl "Install 'software-properties-common'.."
|
||||
apt-get install software-properties-common -y > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
blank_line
|
||||
|
||||
|
||||
# Add reposototies for 'ffmpeg' (create recordings) and 'yq' (update YAML files)
|
||||
#
|
||||
# Note:
|
||||
# The default version of ffmpeg in Ubuntu 16.04 is old and yq does not exist
|
||||
# in the default repositories
|
||||
#
|
||||
echononl "Add repository for 'ffmpeg' .."
|
||||
add-apt-repository ppa:bigbluebutton/support -y > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
echononl "Add repository for 'yq'.."
|
||||
add-apt-repository ppa:rmescandon/yq -y > "$log_file" 2>&1
|
||||
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 dist-upgrade > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
blank_line
|
||||
|
||||
# add repository for mongodb
|
||||
#
|
||||
echononl "Add apt key for 'mongodb' repository.."
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | sudo apt-key add - > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
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
|
||||
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 dist-upgrade > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
blank_line
|
||||
|
||||
|
||||
# install nodejs
|
||||
#
|
||||
echononl "Trigger script to install the NodeSource Node.js 8.x LTS Carbon repo.."
|
||||
echo_wait
|
||||
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
echononl "Install nodejs.."
|
||||
apt-get install -y nodejs > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
|
||||
# apt-get key for BigBlueButton repository
|
||||
#
|
||||
echononl "Add apt key for BigBlueButton repository.."
|
||||
wget https://ubuntu.bigbluebutton.org/repo/bigbluebutton.asc -O- 2> "$log_file" | sudo apt-key add - > "$log_file" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
# add the repository for BigBlueButton 2.2 packages
|
||||
#
|
||||
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
|
||||
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
|
||||
|
||||
blank_line
|
||||
|
||||
|
||||
# Create 'override'-directory for service 'redis-server'
|
||||
#
|
||||
echononl "Create 'override'-directory for service 'redis-server'.."
|
||||
if [[ -d "/etc/systemd/system/redis-server.service.d" ]] ; then
|
||||
echo_skipped
|
||||
else
|
||||
mkdir /etc/systemd/system/redis-server.service.d
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
fi
|
||||
|
||||
echononl "Create 'override'-file for service 'redis-server'.."
|
||||
cat <<EOF > /etc/systemd/system/redis-server.service.d/override.conf > "$log_file" 2>&1
|
||||
[Service]
|
||||
PrivateDevices=no
|
||||
EOF
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
clean_up 0
|
Loading…
Reference in New Issue
Block a user