do_anduinos_distupgrade.sh
· 9.1 KiB · Bash
原始檔案
#!/bin/bash
#=================================================
# AnduinOS Upgrade Script
#=================================================
# This script upgrades AnduinOS from 1.3.7 (plucky)
# to 1.4.1 (questing).
#
# Usage:
# ./do_anduinos_distupgrade.sh
# (Script will auto-elevate to root/sudo)
#=================================================
set -e
set -o pipefail
set -u
Green="\033[32m"
Red="\033[31m"
Yellow="\033[33m"
Blue="\033[36m"
Font="\033[0m"
OK="${Green}[ OK ]${Font}"
ERROR="${Red}[FAILED]${Font}"
WARNING="${Yellow}[ WARN ]${Font}"
# Backup Configuration
BACKUP_ROOT="/var/backups/anduinos-upgrade"
BACKUP_DIR="$BACKUP_ROOT/backup_$(date +%Y%m%d_%H%M%S)"
PPA_BACKUP_DIR="$BACKUP_DIR/ppa"
UBUNTU_SOURCE_BACKUP="$BACKUP_DIR/ubuntu_sources"
# --- Helper Functions ---
function print_ok() {
echo -e "${OK} ${Blue} $1 ${Font}"
}
function print_error() {
echo -e "${ERROR} ${Red} $1 ${Font}"
}
function print_warn() {
echo -e "${WARNING} ${Yellow} $1 ${Font}"
}
# --- Privilege Check ---
function ensure_root() {
if [ "$EUID" -ne 0 ]; then
print_warn "This script requires root privileges."
print_ok "Attempting to escalate privileges via sudo..."
if ! command -v sudo &> /dev/null; then
print_error "sudo is not installed. Please run this script as root."
exit 1
fi
exec sudo "$0" "$@"
exit 0
fi
}
# --- Core Logic ---
function configure_unattended() {
print_ok "Configuring system for unattended upgrades (avoiding prompts)..."
# 1. Install debconf-utils if missing (needed to pre-seed answers)
if ! command -v debconf-set-selections &> /dev/null; then
apt-get install -y debconf-utils
fi
# 2. Pre-answer "Yes" to "Restart services during package upgrades without asking?"
# This kills the specific dialog you saw (libc6/libpam)
echo '* libraries/restart-without-asking boolean true' | debconf-set-selections
# 3. Configure needrestart to be automatic (fixes the purple screen prompt on newer Ubuntu)
# 'a' = automatically restart services
export NEEDRESTART_MODE=a
export DEBIAN_FRONTEND=noninteractive
judge "Configure unattended mode"
}
function rollback_on_error() {
print_error "An error occurred during the upgrade process"
print_warn "Starting rollback procedure..."
if [ -f "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" ]; then
cp "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" /etc/apt/sources.list.d/
print_ok "Restored ubuntu.sources"
fi
if [ -f "$UBUNTU_SOURCE_BACKUP/sources.list" ]; then
cp "$UBUNTU_SOURCE_BACKUP/sources.list" /etc/apt/
print_ok "Restored sources.list"
fi
if [ -d "$PPA_BACKUP_DIR" ] && [ "$(ls -A $PPA_BACKUP_DIR)" ]; then
cp "$PPA_BACKUP_DIR"/* /etc/apt/sources.list.d/ || true
print_ok "Restored PPA sources"
fi
rm -f /etc/apt/apt.conf.d/99-local-versions
print_ok "Running apt update to restore repository state..."
apt update || true
print_warn "Rollback completed. Backup preserved in: $BACKUP_DIR"
exit 1
}
function judge() {
if [[ 0 -eq $? ]]; then
print_ok "$1 succeeded"
sleep 0.2
else
print_error "$1 failed"
rollback_on_error
fi
}
function check_disk_space() {
print_ok "Checking available disk space..."
mkdir -p "$BACKUP_DIR"
local root_space=$(df / | awk 'NR==2 {print $4}')
local root_space_mb=$((root_space / 1024))
local required_space=2048
print_ok "Available space in /: ${root_space_mb}MB"
if [ "$root_space_mb" -lt "$required_space" ]; then
print_error "Insufficient disk space in /. Required: ${required_space}MB"
exit 1
fi
print_ok "Disk space check passed"
}
function update_system() {
print_ok "Running apt update and upgrade..."
apt update
judge "apt update"
# Pass environment variables explicitly to be safe
DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt upgrade -y
judge "apt upgrade"
}
function backup_ubuntu_sources() {
print_ok "Backing up Ubuntu official sources..."
mkdir -p "$UBUNTU_SOURCE_BACKUP"
if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
cp /etc/apt/sources.list.d/ubuntu.sources "$UBUNTU_SOURCE_BACKUP/"
fi
if [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
cp /etc/apt/sources.list "$UBUNTU_SOURCE_BACKUP/"
fi
judge "Backup Ubuntu sources"
}
function backup_and_remove_ppa() {
print_ok "Backing up and temporarily removing PPA sources..."
mkdir -p "$PPA_BACKUP_DIR"
if [ -d "/etc/apt/sources.list.d" ]; then
for file in /etc/apt/sources.list.d/*; do
if [ -f "$file" ] && [ "$(basename "$file")" != "ubuntu.sources" ]; then
mv "$file" "$PPA_BACKUP_DIR/"
fi
done
fi
judge "Backup and remove PPA sources"
}
function detect_apt_format() {
if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
return 0
elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
return 1
else
print_error "Cannot detect APT source format"
rollback_on_error
fi
}
function convert_old_to_new_format() {
print_ok "Converting old format to new DEB822 format..."
cp /etc/apt/sources.list /etc/apt/sources.list.backup
MIRROR_URL=$(grep -E "^deb " /etc/apt/sources.list | grep -v "security" | head -1 | awk '{print $2}')
[ -z "$MIRROR_URL" ] && MIRROR_URL="http://archive.ubuntu.com/ubuntu/"
SECURITY_URL=$(grep -E "^deb " /etc/apt/sources.list | grep "security" | head -1 | awk '{print $2}')
[ -z "$SECURITY_URL" ] && SECURITY_URL="http://security.ubuntu.com/ubuntu/"
bash -c "cat > /etc/apt/sources.list.d/ubuntu.sources" <<EOF
Types: deb
URIs: ${MIRROR_URL}
Suites: plucky plucky-updates plucky-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: ${SECURITY_URL}
Suites: plucky-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
bash -c 'echo "# This file is deprecated. See /etc/apt/sources.list.d/ubuntu.sources" > /etc/apt/sources.list'
judge "Convert to new format"
}
function replace_plucky_with_questing() {
print_ok "Replacing plucky with questing..."
sed -i 's/plucky/questing/g' /etc/apt/sources.list.d/ubuntu.sources
judge "Replace plucky with questing"
print_ok "Updating package lists..."
apt update
judge "apt update with questing"
}
function install_coreutils_uutils() {
print_ok "Installing coreutils-from-uutils..."
DEBIAN_FRONTEND=noninteractive apt install -y coreutils-from-uutils
judge "Install coreutils-from-uutils"
}
function run_dist_upgrade() {
print_ok "Simulating upgrade..."
apt -s dist-upgrade > /dev/null
judge "apt simulation"
print_ok "Running full distribution upgrade..."
# Create local config to force defaults for config files
bash -c 'cat > /etc/apt/apt.conf.d/99-local-versions <<EOF
Dpkg::Options {
"--force-confdef";
"--force-confold";
}
EOF'
# The Big Command:
# DEBIAN_FRONTEND=noninteractive: Hides standard dialogs
# NEEDRESTART_MODE=a: Automatically restarts services without asking (Fixes your issue)
bash -c 'DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a APT_LISTCHANGES_FRONTEND=none \
apt-get -y dist-upgrade \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"'
judge "apt dist-upgrade"
rm -f /etc/apt/apt.conf.d/99-local-versions
}
function update_release_files() {
print_ok "Updating release info..."
if [ -f "/etc/os-release" ]; then
bash -c "cat > /etc/os-release" <<EOF
PRETTY_NAME="AnduinOS 1.4.1"
NAME="AnduinOS"
VERSION_ID="1.4.1"
VERSION="1.4.1 (questing)"
VERSION_CODENAME=questing
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.anduinos.com/"
SUPPORT_URL="https://github.com/Anduin2017/AnduinOS/discussions"
BUG_REPORT_URL="https://github.com/Anduin2017/AnduinOS/issues"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=questing
EOF
fi
if [ -f "/etc/lsb-release" ]; then
bash -c "cat > /etc/lsb-release" <<EOF
DISTRIB_ID=AnduinOS
DISTRIB_RELEASE=1.4.1
DISTRIB_CODENAME=questing
DISTRIB_DESCRIPTION="AnduinOS 1.4.1"
EOF
fi
judge "Update release files"
}
function restore_ppa_sources() {
print_ok "Restoring PPA sources..."
if [ -d "$PPA_BACKUP_DIR" ] && [ "$(ls -A $PPA_BACKUP_DIR)" ]; then
mv "$PPA_BACKUP_DIR"/* /etc/apt/sources.list.d/
apt update
fi
}
function main() {
ensure_root
print_ok "Starting AnduinOS upgrade process..."
# Interactive check for the human, but not for the machine
if [ -t 0 ]; then
read -p "Upgrade from plucky (1.3.7) to questing (1.4.1)? (y/N): " confirm
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
exit 1
fi
fi
# --- NEW STEP: Pre-configure silencing ---
configure_unattended
# -----------------------------------------
check_disk_space
update_system
backup_ubuntu_sources
backup_and_remove_ppa
if ! detect_apt_format; then
convert_old_to_new_format
fi
replace_plucky_with_questing
install_coreutils_uutils
run_dist_upgrade
update_release_files
restore_ppa_sources
print_ok "Upgrade completed successfully!"
print_warn "Please reboot your system."
}
main
| 1 | #!/bin/bash |
| 2 | |
| 3 | #================================================= |
| 4 | # AnduinOS Upgrade Script |
| 5 | #================================================= |
| 6 | # This script upgrades AnduinOS from 1.3.7 (plucky) |
| 7 | # to 1.4.1 (questing). |
| 8 | # |
| 9 | # Usage: |
| 10 | # ./do_anduinos_distupgrade.sh |
| 11 | # (Script will auto-elevate to root/sudo) |
| 12 | #================================================= |
| 13 | |
| 14 | set -e |
| 15 | set -o pipefail |
| 16 | set -u |
| 17 | |
| 18 | Green="\033[32m" |
| 19 | Red="\033[31m" |
| 20 | Yellow="\033[33m" |
| 21 | Blue="\033[36m" |
| 22 | Font="\033[0m" |
| 23 | OK="${Green}[ OK ]${Font}" |
| 24 | ERROR="${Red}[FAILED]${Font}" |
| 25 | WARNING="${Yellow}[ WARN ]${Font}" |
| 26 | |
| 27 | # Backup Configuration |
| 28 | BACKUP_ROOT="/var/backups/anduinos-upgrade" |
| 29 | BACKUP_DIR="$BACKUP_ROOT/backup_$(date +%Y%m%d_%H%M%S)" |
| 30 | PPA_BACKUP_DIR="$BACKUP_DIR/ppa" |
| 31 | UBUNTU_SOURCE_BACKUP="$BACKUP_DIR/ubuntu_sources" |
| 32 | |
| 33 | # --- Helper Functions --- |
| 34 | |
| 35 | function print_ok() { |
| 36 | echo -e "${OK} ${Blue} $1 ${Font}" |
| 37 | } |
| 38 | |
| 39 | function print_error() { |
| 40 | echo -e "${ERROR} ${Red} $1 ${Font}" |
| 41 | } |
| 42 | |
| 43 | function print_warn() { |
| 44 | echo -e "${WARNING} ${Yellow} $1 ${Font}" |
| 45 | } |
| 46 | |
| 47 | # --- Privilege Check --- |
| 48 | |
| 49 | function ensure_root() { |
| 50 | if [ "$EUID" -ne 0 ]; then |
| 51 | print_warn "This script requires root privileges." |
| 52 | print_ok "Attempting to escalate privileges via sudo..." |
| 53 | |
| 54 | if ! command -v sudo &> /dev/null; then |
| 55 | print_error "sudo is not installed. Please run this script as root." |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | exec sudo "$0" "$@" |
| 60 | exit 0 |
| 61 | fi |
| 62 | } |
| 63 | |
| 64 | # --- Core Logic --- |
| 65 | |
| 66 | function configure_unattended() { |
| 67 | print_ok "Configuring system for unattended upgrades (avoiding prompts)..." |
| 68 | |
| 69 | # 1. Install debconf-utils if missing (needed to pre-seed answers) |
| 70 | if ! command -v debconf-set-selections &> /dev/null; then |
| 71 | apt-get install -y debconf-utils |
| 72 | fi |
| 73 | |
| 74 | # 2. Pre-answer "Yes" to "Restart services during package upgrades without asking?" |
| 75 | # This kills the specific dialog you saw (libc6/libpam) |
| 76 | echo '* libraries/restart-without-asking boolean true' | debconf-set-selections |
| 77 | |
| 78 | # 3. Configure needrestart to be automatic (fixes the purple screen prompt on newer Ubuntu) |
| 79 | # 'a' = automatically restart services |
| 80 | export NEEDRESTART_MODE=a |
| 81 | export DEBIAN_FRONTEND=noninteractive |
| 82 | |
| 83 | judge "Configure unattended mode" |
| 84 | } |
| 85 | |
| 86 | function rollback_on_error() { |
| 87 | print_error "An error occurred during the upgrade process" |
| 88 | print_warn "Starting rollback procedure..." |
| 89 | |
| 90 | if [ -f "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" ]; then |
| 91 | cp "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" /etc/apt/sources.list.d/ |
| 92 | print_ok "Restored ubuntu.sources" |
| 93 | fi |
| 94 | |
| 95 | if [ -f "$UBUNTU_SOURCE_BACKUP/sources.list" ]; then |
| 96 | cp "$UBUNTU_SOURCE_BACKUP/sources.list" /etc/apt/ |
| 97 | print_ok "Restored sources.list" |
| 98 | fi |
| 99 | |
| 100 | if [ -d "$PPA_BACKUP_DIR" ] && [ "$(ls -A $PPA_BACKUP_DIR)" ]; then |
| 101 | cp "$PPA_BACKUP_DIR"/* /etc/apt/sources.list.d/ || true |
| 102 | print_ok "Restored PPA sources" |
| 103 | fi |
| 104 | |
| 105 | rm -f /etc/apt/apt.conf.d/99-local-versions |
| 106 | |
| 107 | print_ok "Running apt update to restore repository state..." |
| 108 | apt update || true |
| 109 | |
| 110 | print_warn "Rollback completed. Backup preserved in: $BACKUP_DIR" |
| 111 | exit 1 |
| 112 | } |
| 113 | |
| 114 | function judge() { |
| 115 | if [[ 0 -eq $? ]]; then |
| 116 | print_ok "$1 succeeded" |
| 117 | sleep 0.2 |
| 118 | else |
| 119 | print_error "$1 failed" |
| 120 | rollback_on_error |
| 121 | fi |
| 122 | } |
| 123 | |
| 124 | function check_disk_space() { |
| 125 | print_ok "Checking available disk space..." |
| 126 | mkdir -p "$BACKUP_DIR" |
| 127 | local root_space=$(df / | awk 'NR==2 {print $4}') |
| 128 | local root_space_mb=$((root_space / 1024)) |
| 129 | local required_space=2048 |
| 130 | |
| 131 | print_ok "Available space in /: ${root_space_mb}MB" |
| 132 | |
| 133 | if [ "$root_space_mb" -lt "$required_space" ]; then |
| 134 | print_error "Insufficient disk space in /. Required: ${required_space}MB" |
| 135 | exit 1 |
| 136 | fi |
| 137 | print_ok "Disk space check passed" |
| 138 | } |
| 139 | |
| 140 | function update_system() { |
| 141 | print_ok "Running apt update and upgrade..." |
| 142 | apt update |
| 143 | judge "apt update" |
| 144 | |
| 145 | # Pass environment variables explicitly to be safe |
| 146 | DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt upgrade -y |
| 147 | judge "apt upgrade" |
| 148 | } |
| 149 | |
| 150 | function backup_ubuntu_sources() { |
| 151 | print_ok "Backing up Ubuntu official sources..." |
| 152 | mkdir -p "$UBUNTU_SOURCE_BACKUP" |
| 153 | |
| 154 | if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then |
| 155 | cp /etc/apt/sources.list.d/ubuntu.sources "$UBUNTU_SOURCE_BACKUP/" |
| 156 | fi |
| 157 | |
| 158 | if [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then |
| 159 | cp /etc/apt/sources.list "$UBUNTU_SOURCE_BACKUP/" |
| 160 | fi |
| 161 | judge "Backup Ubuntu sources" |
| 162 | } |
| 163 | |
| 164 | function backup_and_remove_ppa() { |
| 165 | print_ok "Backing up and temporarily removing PPA sources..." |
| 166 | mkdir -p "$PPA_BACKUP_DIR" |
| 167 | |
| 168 | if [ -d "/etc/apt/sources.list.d" ]; then |
| 169 | for file in /etc/apt/sources.list.d/*; do |
| 170 | if [ -f "$file" ] && [ "$(basename "$file")" != "ubuntu.sources" ]; then |
| 171 | mv "$file" "$PPA_BACKUP_DIR/" |
| 172 | fi |
| 173 | done |
| 174 | fi |
| 175 | judge "Backup and remove PPA sources" |
| 176 | } |
| 177 | |
| 178 | function detect_apt_format() { |
| 179 | if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then |
| 180 | return 0 |
| 181 | elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then |
| 182 | return 1 |
| 183 | else |
| 184 | print_error "Cannot detect APT source format" |
| 185 | rollback_on_error |
| 186 | fi |
| 187 | } |
| 188 | |
| 189 | function convert_old_to_new_format() { |
| 190 | print_ok "Converting old format to new DEB822 format..." |
| 191 | cp /etc/apt/sources.list /etc/apt/sources.list.backup |
| 192 | |
| 193 | MIRROR_URL=$(grep -E "^deb " /etc/apt/sources.list | grep -v "security" | head -1 | awk '{print $2}') |
| 194 | [ -z "$MIRROR_URL" ] && MIRROR_URL="http://archive.ubuntu.com/ubuntu/" |
| 195 | |
| 196 | SECURITY_URL=$(grep -E "^deb " /etc/apt/sources.list | grep "security" | head -1 | awk '{print $2}') |
| 197 | [ -z "$SECURITY_URL" ] && SECURITY_URL="http://security.ubuntu.com/ubuntu/" |
| 198 | |
| 199 | bash -c "cat > /etc/apt/sources.list.d/ubuntu.sources" <<EOF |
| 200 | Types: deb |
| 201 | URIs: ${MIRROR_URL} |
| 202 | Suites: plucky plucky-updates plucky-backports |
| 203 | Components: main restricted universe multiverse |
| 204 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 205 | |
| 206 | Types: deb |
| 207 | URIs: ${SECURITY_URL} |
| 208 | Suites: plucky-security |
| 209 | Components: main restricted universe multiverse |
| 210 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 211 | EOF |
| 212 | |
| 213 | bash -c 'echo "# This file is deprecated. See /etc/apt/sources.list.d/ubuntu.sources" > /etc/apt/sources.list' |
| 214 | judge "Convert to new format" |
| 215 | } |
| 216 | |
| 217 | function replace_plucky_with_questing() { |
| 218 | print_ok "Replacing plucky with questing..." |
| 219 | sed -i 's/plucky/questing/g' /etc/apt/sources.list.d/ubuntu.sources |
| 220 | judge "Replace plucky with questing" |
| 221 | |
| 222 | print_ok "Updating package lists..." |
| 223 | apt update |
| 224 | judge "apt update with questing" |
| 225 | } |
| 226 | |
| 227 | function install_coreutils_uutils() { |
| 228 | print_ok "Installing coreutils-from-uutils..." |
| 229 | DEBIAN_FRONTEND=noninteractive apt install -y coreutils-from-uutils |
| 230 | judge "Install coreutils-from-uutils" |
| 231 | } |
| 232 | |
| 233 | function run_dist_upgrade() { |
| 234 | print_ok "Simulating upgrade..." |
| 235 | apt -s dist-upgrade > /dev/null |
| 236 | judge "apt simulation" |
| 237 | |
| 238 | print_ok "Running full distribution upgrade..." |
| 239 | |
| 240 | # Create local config to force defaults for config files |
| 241 | bash -c 'cat > /etc/apt/apt.conf.d/99-local-versions <<EOF |
| 242 | Dpkg::Options { |
| 243 | "--force-confdef"; |
| 244 | "--force-confold"; |
| 245 | } |
| 246 | EOF' |
| 247 | |
| 248 | # The Big Command: |
| 249 | # DEBIAN_FRONTEND=noninteractive: Hides standard dialogs |
| 250 | # NEEDRESTART_MODE=a: Automatically restarts services without asking (Fixes your issue) |
| 251 | bash -c 'DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a APT_LISTCHANGES_FRONTEND=none \ |
| 252 | apt-get -y dist-upgrade \ |
| 253 | -o Dpkg::Options::="--force-confdef" \ |
| 254 | -o Dpkg::Options::="--force-confold"' |
| 255 | |
| 256 | judge "apt dist-upgrade" |
| 257 | rm -f /etc/apt/apt.conf.d/99-local-versions |
| 258 | } |
| 259 | |
| 260 | function update_release_files() { |
| 261 | print_ok "Updating release info..." |
| 262 | if [ -f "/etc/os-release" ]; then |
| 263 | bash -c "cat > /etc/os-release" <<EOF |
| 264 | PRETTY_NAME="AnduinOS 1.4.1" |
| 265 | NAME="AnduinOS" |
| 266 | VERSION_ID="1.4.1" |
| 267 | VERSION="1.4.1 (questing)" |
| 268 | VERSION_CODENAME=questing |
| 269 | ID=ubuntu |
| 270 | ID_LIKE=debian |
| 271 | HOME_URL="https://www.anduinos.com/" |
| 272 | SUPPORT_URL="https://github.com/Anduin2017/AnduinOS/discussions" |
| 273 | BUG_REPORT_URL="https://github.com/Anduin2017/AnduinOS/issues" |
| 274 | PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" |
| 275 | UBUNTU_CODENAME=questing |
| 276 | EOF |
| 277 | fi |
| 278 | |
| 279 | if [ -f "/etc/lsb-release" ]; then |
| 280 | bash -c "cat > /etc/lsb-release" <<EOF |
| 281 | DISTRIB_ID=AnduinOS |
| 282 | DISTRIB_RELEASE=1.4.1 |
| 283 | DISTRIB_CODENAME=questing |
| 284 | DISTRIB_DESCRIPTION="AnduinOS 1.4.1" |
| 285 | EOF |
| 286 | fi |
| 287 | judge "Update release files" |
| 288 | } |
| 289 | |
| 290 | function restore_ppa_sources() { |
| 291 | print_ok "Restoring PPA sources..." |
| 292 | if [ -d "$PPA_BACKUP_DIR" ] && [ "$(ls -A $PPA_BACKUP_DIR)" ]; then |
| 293 | mv "$PPA_BACKUP_DIR"/* /etc/apt/sources.list.d/ |
| 294 | apt update |
| 295 | fi |
| 296 | } |
| 297 | |
| 298 | function main() { |
| 299 | ensure_root |
| 300 | |
| 301 | print_ok "Starting AnduinOS upgrade process..." |
| 302 | |
| 303 | # Interactive check for the human, but not for the machine |
| 304 | if [ -t 0 ]; then |
| 305 | read -p "Upgrade from plucky (1.3.7) to questing (1.4.1)? (y/N): " confirm |
| 306 | if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then |
| 307 | exit 1 |
| 308 | fi |
| 309 | fi |
| 310 | |
| 311 | # --- NEW STEP: Pre-configure silencing --- |
| 312 | configure_unattended |
| 313 | # ----------------------------------------- |
| 314 | |
| 315 | check_disk_space |
| 316 | update_system |
| 317 | backup_ubuntu_sources |
| 318 | backup_and_remove_ppa |
| 319 | |
| 320 | if ! detect_apt_format; then |
| 321 | convert_old_to_new_format |
| 322 | fi |
| 323 | |
| 324 | replace_plucky_with_questing |
| 325 | install_coreutils_uutils |
| 326 | run_dist_upgrade |
| 327 | update_release_files |
| 328 | restore_ppa_sources |
| 329 | |
| 330 | print_ok "Upgrade completed successfully!" |
| 331 | print_warn "Please reboot your system." |
| 332 | } |
| 333 | |
| 334 | main |