do_anduinos_distupgrade.sh
· 9.5 KiB · Bash
Eredeti
#!/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..."
# Check if sudo is available
if ! command -v sudo &> /dev/null; then
print_error "sudo is not installed. Please run this script as root."
exit 1
fi
# Re-execute the script with sudo, preserving arguments
# exec replaces the current process, so the script runs anew as root
exec sudo "$0" "$@"
exit 0
fi
# If we are here, we are root (or sudo-ed successfully)
}
# --- Core Logic ---
function rollback_on_error() {
print_error "An error occurred during the upgrade process"
print_warn "Starting rollback procedure..."
# Restore ubuntu.sources if backup exists
if [ -f "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" ]; then
print_ok "Restoring ubuntu.sources..."
cp "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" /etc/apt/sources.list.d/
print_ok "Restored ubuntu.sources"
fi
# Restore sources.list if backup exists
if [ -f "$UBUNTU_SOURCE_BACKUP/sources.list" ]; then
print_ok "Restoring sources.list..."
cp "$UBUNTU_SOURCE_BACKUP/sources.list" /etc/apt/
print_ok "Restored sources.list"
fi
# Restore PPA sources
if [ -d "$PPA_BACKUP_DIR" ]; then
ppa_count=$(ls -1 "$PPA_BACKUP_DIR" 2>/dev/null | wc -l)
if [ "$ppa_count" -gt 0 ]; then
print_ok "Restoring PPA sources..."
for file in "$PPA_BACKUP_DIR"/*; do
if [ -f "$file" ]; then
cp "$file" /etc/apt/sources.list.d/
print_ok "Restored $(basename "$file")"
fi
done
fi
fi
# Remove temporary apt configuration if exists
if [ -f "/etc/apt/apt.conf.d/99-local-versions" ]; then
rm -f /etc/apt/apt.conf.d/99-local-versions
fi
print_ok "Running apt update to restore repository state..."
apt update || true
print_warn "Rollback completed. System restored to previous state."
print_warn "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"
print_ok "Backup location: $BACKUP_DIR"
if [ "$root_space_mb" -lt "$required_space" ]; then
print_error "Insufficient disk space in /. Required: ${required_space}MB, Available: ${root_space_mb}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"
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/"
print_ok "Backed up ubuntu.sources"
fi
if [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
cp /etc/apt/sources.list "$UBUNTU_SOURCE_BACKUP/"
print_ok "Backed up sources.list"
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/"
print_ok "Moved $(basename "$file") to backup"
fi
done
fi
judge "Backup and remove PPA sources"
}
function detect_apt_format() {
print_ok "Detecting APT source format..."
if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
print_ok "Detected new DEB822 format"
return 0
elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
print_ok "Detected old format (sources.list)"
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..."
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..."
export DEBIAN_FRONTEND=noninteractive
bash -c 'cat > /etc/apt/apt.conf.d/99-local-versions <<EOF
Dpkg::Options {
"--force-confdef";
"--force-confold";
}
EOF'
bash -c 'DEBIAN_FRONTEND=noninteractive 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
unset DEBIAN_FRONTEND
}
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/
print_ok "Restored PPAs"
apt update
judge "Update after PPA restore"
else
print_ok "No PPA sources to restore"
fi
}
function main() {
# 1. Ensure we are root first
ensure_root
print_ok "Starting AnduinOS upgrade process..."
echo -e "${Yellow}WARNING: Upgrading from 1.3.7 (plucky) to 1.4.1 (questing).${Font}"
# Since we are likely root now, we check if the script is running interactively before asking
# If we sudo-ed, we might have lost some TTY context, but usually 'read' works fine.
if [ -t 0 ]; then
read -p "Do you want to continue? (y/N): " confirm
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
print_error "Aborted by user."
exit 1
fi
fi
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_ok "System is now AnduinOS 1.4.1 (questing)"
print_ok "Backups: $BACKUP_DIR"
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 | # Check if sudo is available |
| 55 | if ! command -v sudo &> /dev/null; then |
| 56 | print_error "sudo is not installed. Please run this script as root." |
| 57 | exit 1 |
| 58 | fi |
| 59 | |
| 60 | # Re-execute the script with sudo, preserving arguments |
| 61 | # exec replaces the current process, so the script runs anew as root |
| 62 | exec sudo "$0" "$@" |
| 63 | exit 0 |
| 64 | fi |
| 65 | # If we are here, we are root (or sudo-ed successfully) |
| 66 | } |
| 67 | |
| 68 | # --- Core Logic --- |
| 69 | |
| 70 | function rollback_on_error() { |
| 71 | print_error "An error occurred during the upgrade process" |
| 72 | print_warn "Starting rollback procedure..." |
| 73 | |
| 74 | # Restore ubuntu.sources if backup exists |
| 75 | if [ -f "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" ]; then |
| 76 | print_ok "Restoring ubuntu.sources..." |
| 77 | cp "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" /etc/apt/sources.list.d/ |
| 78 | print_ok "Restored ubuntu.sources" |
| 79 | fi |
| 80 | |
| 81 | # Restore sources.list if backup exists |
| 82 | if [ -f "$UBUNTU_SOURCE_BACKUP/sources.list" ]; then |
| 83 | print_ok "Restoring sources.list..." |
| 84 | cp "$UBUNTU_SOURCE_BACKUP/sources.list" /etc/apt/ |
| 85 | print_ok "Restored sources.list" |
| 86 | fi |
| 87 | |
| 88 | # Restore PPA sources |
| 89 | if [ -d "$PPA_BACKUP_DIR" ]; then |
| 90 | ppa_count=$(ls -1 "$PPA_BACKUP_DIR" 2>/dev/null | wc -l) |
| 91 | if [ "$ppa_count" -gt 0 ]; then |
| 92 | print_ok "Restoring PPA sources..." |
| 93 | for file in "$PPA_BACKUP_DIR"/*; do |
| 94 | if [ -f "$file" ]; then |
| 95 | cp "$file" /etc/apt/sources.list.d/ |
| 96 | print_ok "Restored $(basename "$file")" |
| 97 | fi |
| 98 | done |
| 99 | fi |
| 100 | fi |
| 101 | |
| 102 | # Remove temporary apt configuration if exists |
| 103 | if [ -f "/etc/apt/apt.conf.d/99-local-versions" ]; then |
| 104 | rm -f /etc/apt/apt.conf.d/99-local-versions |
| 105 | fi |
| 106 | |
| 107 | print_ok "Running apt update to restore repository state..." |
| 108 | apt update || true |
| 109 | |
| 110 | print_warn "Rollback completed. System restored to previous state." |
| 111 | print_warn "Backup preserved in: $BACKUP_DIR" |
| 112 | exit 1 |
| 113 | } |
| 114 | |
| 115 | function judge() { |
| 116 | if [[ 0 -eq $? ]]; then |
| 117 | print_ok "$1 succeeded" |
| 118 | sleep 0.2 |
| 119 | else |
| 120 | print_error "$1 failed" |
| 121 | rollback_on_error |
| 122 | fi |
| 123 | } |
| 124 | |
| 125 | function check_disk_space() { |
| 126 | print_ok "Checking available disk space..." |
| 127 | |
| 128 | mkdir -p "$BACKUP_DIR" |
| 129 | |
| 130 | local root_space=$(df / | awk 'NR==2 {print $4}') |
| 131 | local root_space_mb=$((root_space / 1024)) |
| 132 | local required_space=2048 |
| 133 | |
| 134 | print_ok "Available space in /: ${root_space_mb}MB" |
| 135 | print_ok "Backup location: $BACKUP_DIR" |
| 136 | |
| 137 | if [ "$root_space_mb" -lt "$required_space" ]; then |
| 138 | print_error "Insufficient disk space in /. Required: ${required_space}MB, Available: ${root_space_mb}MB" |
| 139 | exit 1 |
| 140 | fi |
| 141 | |
| 142 | print_ok "Disk space check passed" |
| 143 | } |
| 144 | |
| 145 | function update_system() { |
| 146 | print_ok "Running apt update and upgrade..." |
| 147 | apt update |
| 148 | judge "apt update" |
| 149 | apt upgrade -y |
| 150 | judge "apt upgrade" |
| 151 | } |
| 152 | |
| 153 | function backup_ubuntu_sources() { |
| 154 | print_ok "Backing up Ubuntu official sources..." |
| 155 | mkdir -p "$UBUNTU_SOURCE_BACKUP" |
| 156 | |
| 157 | if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then |
| 158 | cp /etc/apt/sources.list.d/ubuntu.sources "$UBUNTU_SOURCE_BACKUP/" |
| 159 | print_ok "Backed up ubuntu.sources" |
| 160 | fi |
| 161 | |
| 162 | if [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then |
| 163 | cp /etc/apt/sources.list "$UBUNTU_SOURCE_BACKUP/" |
| 164 | print_ok "Backed up sources.list" |
| 165 | fi |
| 166 | judge "Backup Ubuntu sources" |
| 167 | } |
| 168 | |
| 169 | function backup_and_remove_ppa() { |
| 170 | print_ok "Backing up and temporarily removing PPA sources..." |
| 171 | mkdir -p "$PPA_BACKUP_DIR" |
| 172 | |
| 173 | if [ -d "/etc/apt/sources.list.d" ]; then |
| 174 | for file in /etc/apt/sources.list.d/*; do |
| 175 | if [ -f "$file" ] && [ "$(basename "$file")" != "ubuntu.sources" ]; then |
| 176 | mv "$file" "$PPA_BACKUP_DIR/" |
| 177 | print_ok "Moved $(basename "$file") to backup" |
| 178 | fi |
| 179 | done |
| 180 | fi |
| 181 | judge "Backup and remove PPA sources" |
| 182 | } |
| 183 | |
| 184 | function detect_apt_format() { |
| 185 | print_ok "Detecting APT source format..." |
| 186 | if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then |
| 187 | print_ok "Detected new DEB822 format" |
| 188 | return 0 |
| 189 | elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then |
| 190 | print_ok "Detected old format (sources.list)" |
| 191 | return 1 |
| 192 | else |
| 193 | print_error "Cannot detect APT source format" |
| 194 | rollback_on_error |
| 195 | fi |
| 196 | } |
| 197 | |
| 198 | function convert_old_to_new_format() { |
| 199 | print_ok "Converting old format to new DEB822 format..." |
| 200 | |
| 201 | cp /etc/apt/sources.list /etc/apt/sources.list.backup |
| 202 | |
| 203 | MIRROR_URL=$(grep -E "^deb " /etc/apt/sources.list | grep -v "security" | head -1 | awk '{print $2}') |
| 204 | [ -z "$MIRROR_URL" ] && MIRROR_URL="http://archive.ubuntu.com/ubuntu/" |
| 205 | |
| 206 | SECURITY_URL=$(grep -E "^deb " /etc/apt/sources.list | grep "security" | head -1 | awk '{print $2}') |
| 207 | [ -z "$SECURITY_URL" ] && SECURITY_URL="http://security.ubuntu.com/ubuntu/" |
| 208 | |
| 209 | bash -c "cat > /etc/apt/sources.list.d/ubuntu.sources" <<EOF |
| 210 | Types: deb |
| 211 | URIs: ${MIRROR_URL} |
| 212 | Suites: plucky plucky-updates plucky-backports |
| 213 | Components: main restricted universe multiverse |
| 214 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 215 | |
| 216 | Types: deb |
| 217 | URIs: ${SECURITY_URL} |
| 218 | Suites: plucky-security |
| 219 | Components: main restricted universe multiverse |
| 220 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 221 | EOF |
| 222 | |
| 223 | bash -c 'echo "# This file is deprecated. See /etc/apt/sources.list.d/ubuntu.sources" > /etc/apt/sources.list' |
| 224 | judge "Convert to new format" |
| 225 | } |
| 226 | |
| 227 | function replace_plucky_with_questing() { |
| 228 | print_ok "Replacing plucky with questing..." |
| 229 | sed -i 's/plucky/questing/g' /etc/apt/sources.list.d/ubuntu.sources |
| 230 | judge "Replace plucky with questing" |
| 231 | |
| 232 | print_ok "Updating package lists..." |
| 233 | apt update |
| 234 | judge "apt update with questing" |
| 235 | } |
| 236 | |
| 237 | function install_coreutils_uutils() { |
| 238 | print_ok "Installing coreutils-from-uutils..." |
| 239 | apt install -y coreutils-from-uutils |
| 240 | judge "Install coreutils-from-uutils" |
| 241 | } |
| 242 | |
| 243 | function run_dist_upgrade() { |
| 244 | print_ok "Simulating upgrade..." |
| 245 | apt -s dist-upgrade > /dev/null |
| 246 | judge "apt simulation" |
| 247 | |
| 248 | print_ok "Running full distribution upgrade..." |
| 249 | export DEBIAN_FRONTEND=noninteractive |
| 250 | |
| 251 | bash -c 'cat > /etc/apt/apt.conf.d/99-local-versions <<EOF |
| 252 | Dpkg::Options { |
| 253 | "--force-confdef"; |
| 254 | "--force-confold"; |
| 255 | } |
| 256 | EOF' |
| 257 | |
| 258 | bash -c 'DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none \ |
| 259 | apt-get -y dist-upgrade \ |
| 260 | -o Dpkg::Options::="--force-confdef" \ |
| 261 | -o Dpkg::Options::="--force-confold"' |
| 262 | |
| 263 | judge "apt dist-upgrade" |
| 264 | rm -f /etc/apt/apt.conf.d/99-local-versions |
| 265 | unset DEBIAN_FRONTEND |
| 266 | } |
| 267 | |
| 268 | function update_release_files() { |
| 269 | print_ok "Updating release info..." |
| 270 | |
| 271 | if [ -f "/etc/os-release" ]; then |
| 272 | bash -c "cat > /etc/os-release" <<EOF |
| 273 | PRETTY_NAME="AnduinOS 1.4.1" |
| 274 | NAME="AnduinOS" |
| 275 | VERSION_ID="1.4.1" |
| 276 | VERSION="1.4.1 (questing)" |
| 277 | VERSION_CODENAME=questing |
| 278 | ID=ubuntu |
| 279 | ID_LIKE=debian |
| 280 | HOME_URL="https://www.anduinos.com/" |
| 281 | SUPPORT_URL="https://github.com/Anduin2017/AnduinOS/discussions" |
| 282 | BUG_REPORT_URL="https://github.com/Anduin2017/AnduinOS/issues" |
| 283 | PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" |
| 284 | UBUNTU_CODENAME=questing |
| 285 | EOF |
| 286 | fi |
| 287 | |
| 288 | if [ -f "/etc/lsb-release" ]; then |
| 289 | bash -c "cat > /etc/lsb-release" <<EOF |
| 290 | DISTRIB_ID=AnduinOS |
| 291 | DISTRIB_RELEASE=1.4.1 |
| 292 | DISTRIB_CODENAME=questing |
| 293 | DISTRIB_DESCRIPTION="AnduinOS 1.4.1" |
| 294 | EOF |
| 295 | fi |
| 296 | judge "Update release files" |
| 297 | } |
| 298 | |
| 299 | function restore_ppa_sources() { |
| 300 | print_ok "Restoring PPA sources..." |
| 301 | if [ -d "$PPA_BACKUP_DIR" ] && [ "$(ls -A $PPA_BACKUP_DIR)" ]; then |
| 302 | mv "$PPA_BACKUP_DIR"/* /etc/apt/sources.list.d/ |
| 303 | print_ok "Restored PPAs" |
| 304 | apt update |
| 305 | judge "Update after PPA restore" |
| 306 | else |
| 307 | print_ok "No PPA sources to restore" |
| 308 | fi |
| 309 | } |
| 310 | |
| 311 | function main() { |
| 312 | # 1. Ensure we are root first |
| 313 | ensure_root |
| 314 | |
| 315 | print_ok "Starting AnduinOS upgrade process..." |
| 316 | echo -e "${Yellow}WARNING: Upgrading from 1.3.7 (plucky) to 1.4.1 (questing).${Font}" |
| 317 | |
| 318 | # Since we are likely root now, we check if the script is running interactively before asking |
| 319 | # If we sudo-ed, we might have lost some TTY context, but usually 'read' works fine. |
| 320 | if [ -t 0 ]; then |
| 321 | read -p "Do you want to continue? (y/N): " confirm |
| 322 | if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then |
| 323 | print_error "Aborted by user." |
| 324 | exit 1 |
| 325 | fi |
| 326 | fi |
| 327 | |
| 328 | check_disk_space |
| 329 | update_system |
| 330 | backup_ubuntu_sources |
| 331 | backup_and_remove_ppa |
| 332 | |
| 333 | if ! detect_apt_format; then |
| 334 | convert_old_to_new_format |
| 335 | fi |
| 336 | |
| 337 | replace_plucky_with_questing |
| 338 | install_coreutils_uutils |
| 339 | run_dist_upgrade |
| 340 | update_release_files |
| 341 | restore_ppa_sources |
| 342 | |
| 343 | print_ok "Upgrade completed successfully!" |
| 344 | print_ok "System is now AnduinOS 1.4.1 (questing)" |
| 345 | print_ok "Backups: $BACKUP_DIR" |
| 346 | print_warn "Please reboot your system." |
| 347 | } |
| 348 | |
| 349 | main |