Update scripts and docs to support ubunto 20.04
This commit is contained in:
@@ -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 <<EOF > /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 <<EOF > /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
|
||||
|
||||
Reference in New Issue
Block a user