From 7141e0a72bb254f1809ef3eb96bdbc01db6e5473 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 25 Mar 2021 14:52:56 +0100 Subject: [SSUS] Debian 11 compat --- satellit_upgrader/updater.template.sh | 61 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 20 deletions(-) (limited to 'satellit_upgrader/updater.template.sh') diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh index 483da0f..420b1bc 100644 --- a/satellit_upgrader/updater.template.sh +++ b/satellit_upgrader/updater.template.sh @@ -14,16 +14,29 @@ if [ "$(lsb_release -si)" != "Debian" ]; then exit 1 fi -MAJOR=$(lsb_release -sr) -MAJOR=${MAJOR%%.*} -readonly MAJOR -if [ "${MAJOR}" -lt 9 ]; then +CODENAME="$( lsb_release -sc )" +MAJOR="$( lsb_release -sr )" +MAJOR="${MAJOR%%.*}" +if ! (( MAJOR > 0 )); then + case "$CODENAME" in + bullseye) MAJOR=11 ;; + bookworm) MAJOR=12 ;; + trixie) MAJOR=13 ;; + esac +fi +if ! (( MAJOR > 0 )); then + echo "Could not determine Debian version" + exit 1 +fi + +readonly MAJOR CODENAME +if (( MAJOR < 9 )); then echo "This Version of the bwLehrpool Satellite Server is too old!" echo "Back up your existing configuration via slx-admin and import it into a" echo "fresh install, or manually dist-upgrade this server." exit 1 fi -if [ "${MAJOR}" -gt 10 ]; then +if (( MAJOR > 11 )); then echo "This Version of the bwLehrpool Satellite Server is too new!" exit 1 fi @@ -138,12 +151,8 @@ aptinst () { rm -f -- "/etc/apt/sources.list.d/10-added_repos.list" # No more updates for pre-point release updates on jessie # But re-enable (in case it was dist-upgraded) - if [ "$MAJOR" -eq 9 ]; then - sed -r -i '/^\s*#.*jessie-updates/s/^\s*#//;s/jessie-updates/stretch-updates/' "/etc/apt/sources.list" - elif [ "$MAJOR" -eq 10 ]; then - sed -r -i '/^\s*#.*jessie-updates/s/^\s*#//;s/jessie-updates/buster-updates/' "/etc/apt/sources.list" - fi - failprint apt-get update || perror "Cannot run apt-get update" + sed -r -i '/^\s*#.*jessie-updates/s/^\s*#//;s/jessie-updates/'"$CODENAME"'-updates/' "/etc/apt/sources.list" + failprint apt-get update || pwarning "Cannot run apt-get update" aptupdate=true fi echo "Installing $pkg" @@ -251,17 +260,25 @@ if [ -f "/etc/cron.daily/tmpdelete.sh" ]; then rm -f -- "/etc/cron.daily/tmpdelete.sh" fi -if [ "$MAJOR" -eq 9 ]; then +if (( MAJOR == 9 )); then java="7" # highest UNWANTED version php="-1" # highest UNWANTED version - mysql="10.1" -elif [ "$MAJOR" -eq 10 ]; then + mysql="10.1" # WANTED version +elif (( MAJOR == 10 )); then java="10" # highest UNWANTED version php="2" # highest UNWANTED version - mysql="10.3" + mysql="10.3" # WANTED version +elif (( MAJOR == 11 )); then + java="10" # highest UNWANTED version + php="3" # highest UNWANTED version + mysql="10.5" # WANTED version else perror "Abort" fi + +echo "Cleaning up old packages..." +failprint apt autoremove -y + # Make sure current java is installed for ver in $(seq 6 "$java"); do dpkg -l "openjdk-${ver}-*" 2> /dev/null | grep -q '^ii' && apt remove -y "openjdk-${ver}-*" @@ -288,6 +305,9 @@ for ver in $( dpkg-query -W -f='${Package}\n' "mysql-server-*" "mariadb-server-* dpkg -l "$ver" 2> /dev/null | grep -q '^ii' && apt remove -y "$ver" done aptinst default-mysql-server + +failprint apt autoremove -y + ## Enable unix socket passwordless local connection (commented out since default in Debian 9+ anyways) #mysql -e "UPDATE user SET plugin = 'unix_socket' WHERE Host = 'localhost' AND User = 'root'" @@ -552,7 +572,7 @@ fi echo "* Configuring lighttpd" -if [ "$MAJOR" -lt 10 ]; then +if (( MAJOR < 10 )); then # Filename changed on Debian 10, patch back for 9 sed -i 's/create-mime\.conf\.pl/create-mime.assign.pl/' "$FILEDIR/lighttpd/etc/lighttpd/lighttpd.conf" fi @@ -702,11 +722,12 @@ if [ -n "$TGZ_DNBD3" ]; then [ -z "$cver" ] && pwarning "BUG BUG! Cannot query dnbd3 version information from currently installed binary!" [ -z "$nver" ] && pwarning "BUG BUG! Updater package contains no dnbd3 version information!" mkdir -p "$PATH_DNBD3" + echo "Current: '${cver#v}' | Included: ${nver#v}" if [ "${cver#v}" != "${nver#v}" ]; then echo "Compiling new dnbd3-server binary..." cd "$tmpdir" aptinst libjansson-dev - if [ "$MAJOR" -le 9 ]; then + if (( MAJOR <= 9 )); then # cmake too old; try with makefile if ! cp "$FILEDIR/dnbd3-Makefile" Makefile; then pwarning "Could not get legacy dnbd3 make file" @@ -728,7 +749,7 @@ if [ -n "$TGZ_DNBD3" ]; then pwarning "Could not cmake new version $nver of dnbd3-server" elif ! failprint make -j2 dnbd3-server; then pwarning "Could not compile new version $nver of dnbd3-server" - elif ! cp -f dnbd3-server "$PATH_DNBD3/dnbd3-server"; then + elif ! cp -f src/server/dnbd3-server "$PATH_DNBD3/dnbd3-server"; then pwarning "Successfully built new dnbd3-server, but could not copy binary to $PATH_DNBD3/dnbd3-server" else # Clear this so we know not to print the "trying to keep going.." message cver= @@ -782,7 +803,7 @@ if [ -n "$TGZ_LDADP" ]; then fi # ************************** tmate ************************ -if ! which tmate &> /dev/null && [ "$MAJOR" -ge 9 ]; then +if ! which tmate &> /dev/null && (( MAJOR >= 9 )); then echo "* Installing tmate" if ! aptinst tmate; then pwarning "Could not install tmate. Easy remote assistance will not be available." @@ -849,7 +870,7 @@ fi # Debian 10's default SSL configuration changed to only use DEFAULT@SECLEVEL=2 # as ciphers. We need to patch that, since this can cause problems with ldadp. -if [ "${MAJOR}" -eq 10 ]; then +if (( MAJOR >= 10 )); then sed -r -i 's/^[#\s]*(CipherString =.*)/#\1/' /etc/ssl/openssl.cnf fi -- cgit v1.2.3-55-g7522