|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eu -o pipefail |
| 4 | + |
| 5 | +new_cfg=/usr/local/etc/ncp-recommended.cfg |
| 6 | +[[ -f "${new_cfg}" ]] || { echo "Already on the lastest recommended distribution. Abort." >&2; exit 1; } |
| 7 | + |
| 8 | +echo " |
| 9 | +>>> ATTENTION <<< |
| 10 | +This is a dangerous process that is only guaranteed to work properly if you |
| 11 | +have not made manual changes in the system. Backup the SD card first and |
| 12 | +proceed at your own risk. |
| 13 | +
|
| 14 | +Note that this is not a requirement for NCP to continue working properly. |
| 15 | +The current distribution will keep receiving updates for some time. |
| 16 | +
|
| 17 | +Do you want to continue? [y/N]" |
| 18 | + |
| 19 | +if [[ "${DEBIAN_FRONTEND:-}" == "noninteractive" ]] || ! [[ -t 0 ]] |
| 20 | +then |
| 21 | + echo "Noninteractive environment detected. Automatically proceeding in 30 seconds..." |
| 22 | + sleep 30 |
| 23 | +else |
| 24 | + read -n1 -r key |
| 25 | + [[ "${key,,}" == y ]] || exit 0 |
| 26 | +fi |
| 27 | + |
| 28 | +export DEBIAN_FRONTEND=noninteractive |
| 29 | + |
| 30 | +source /usr/local/etc/library.sh |
| 31 | +is_more_recent_than "${PHPVER}.0" "8.2.0" || { |
| 32 | + echo "You still have PHP version ${PHPVER} installed. Please update to the latest supported version of nextcloud (which will also update your PHP version) before proceeding with the distribution upgrade." |
| 33 | + echo "Exiting." |
| 34 | + exit 1 |
| 35 | +} |
| 36 | +save_maintenance_mode |
| 37 | +set -x |
| 38 | + |
| 39 | +# Perform dist-upgrade |
| 40 | + |
| 41 | + |
| 42 | +apt-get update |
| 43 | +apt-get upgrade -y |
| 44 | +for aptlist in /etc/apt/sources.list /etc/apt/sources.list.d/{php.list,armbian.list,raspi.list} |
| 45 | +do |
| 46 | + [ -f "$aptlist" ] && sed -i -e "s/bookworm/trixie/g" "$aptlist" |
| 47 | +done |
| 48 | + |
| 49 | +for aptlist in /etc/apt/sources.list.d/*.list |
| 50 | +do |
| 51 | + [[ "$aptlist" =~ "/etc/apt/sources.list.d/"(php|armbian|raspi)".list" ]] || { |
| 52 | + echo "Disabling repositories from \"$aptlist\"" |
| 53 | + sed -i -e "s/deb/#deb/g" "$aptlist" |
| 54 | + } |
| 55 | +done |
| 56 | +apt-get update |
| 57 | +apt-get upgrade -y dpkg |
| 58 | +apt-get upgrade -y --without-new-pkgs |
| 59 | +apt-get full-upgrade -y |
| 60 | +sudo apt-get --purge autoremove -y |
| 61 | +restore_maintenance_mode |
| 62 | +cfg="$(jq "." "$NCPCFG")" |
| 63 | +cfg="$(jq ".release = \"bookworm\"" <<<"$cfg")" |
| 64 | +echo "$cfg" > "$NCPCFG" |
| 65 | +rm -f /etc/update-motd.d/30ncp-dist-upgrade |
| 66 | +rm -f /usr/local/etc/ncp-recommended.cfg |
| 67 | +echo "Update to Debian 13 (trixie) successful." |
| 68 | + |
| 69 | +is_active_app unattended-upgrades && { |
| 70 | + echo "Setting up unattended upgrades..." |
| 71 | + run_app unattended-upgrades || true |
| 72 | + echo "done." |
| 73 | +} |
0 commit comments