Zforkowane z ZeTian/do_anduinos_distupgrade.sh

Ostatnio aktywny 2 weeks ago

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

Brak zmian

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

1 file changed, 8 insertions

do_anduinos_distupgrade.sh

@@ -720,6 +720,14 @@ function main() {
720 720 print_ok "Your system has been upgraded to AnduinOS 1.4.1 (questing)"
721 721 print_ok "Backup files are stored in: $BACKUP_DIR"
722 722 print_warn "Please reboot your system to complete the upgrade."
723 +
724 + if [ -t 0 ]; then
725 + read -p "Do you want to reboot now? (y/N): " reboot_confirm
726 + if [[ "$reboot_confirm" == "y" || "$reboot_confirm" == "Y" ]]; then
727 + print_ok "Rebooting system..."
728 + reboot
729 + fi
730 + fi
723 731 }
724 732
725 733 main

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

1 file changed, 312 insertions, 56 deletions

do_anduinos_distupgrade.sh

@@ -65,6 +65,30 @@ function ensure_root() {
65 65 # If we are here, we are root.
66 66 }
67 67
68 + # --- 4.5 SSH & Persistence Check ---
69 +
70 + function check_ssh_safeguard() {
71 + if [ -n "${SSH_CLIENT:-}" ] || [ -n "${SSH_TTY:-}" ]; then
72 + # Check for screen/tmux
73 + if [ -n "${STY:-}" ] || [ -n "${TMUX:-}" ] || [[ "${TERM:-}" == *"screen"* ]] || [[ "${TERM:-}" == *"tmux"* ]]; then
74 + print_ok "SSH detected, but running inside persistence (screen/tmux). Safe."
75 + return
76 + fi
77 +
78 + print_warn "SSH session detected WITHOUT screen/tmux!"
79 + print_warn "Network disconnection could kill the critical upgrade process."
80 +
81 + if [ -t 0 ]; then
82 + read -p "Continue anyway? (y/N): " confirm
83 + if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
84 + print_error "Aborted. Please use screen/tmux."
85 + exit 1
86 + fi
87 + fi
88 +
89 + fi
90 + }
91 +
68 92 # --- 5. Unattended Configuration (Anti-Prompt) ---
69 93
70 94 function configure_unattended() {
@@ -227,67 +251,219 @@ function backup_and_remove_ppa() {
227 251 judge "Backup and remove PPA sources"
228 252 }
229 253
230 - function detect_apt_format() {
231 - print_ok "Detecting APT source format..."
232 -
254 + function check_apt_source_format() {
255 + local old_format=false
256 + local new_format=false
257 +
258 + # Check old format (.list)
259 + if [ -f "/etc/apt/sources.list" ]; then
260 + if grep -v '^#' /etc/apt/sources.list | grep -q '[^[:space:]]'; then
261 + old_format=true
262 + fi
263 + fi
264 +
265 + # Check for ubuntu.sources file in new format
233 266 if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
234 - print_ok "Detected new DEB822 format (ubuntu.sources)"
235 - return 0
236 - elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
237 - print_ok "Detected old format (sources.list)"
238 - return 1
267 + if grep -v '^#' /etc/apt/sources.list.d/ubuntu.sources | grep -q '[^[:space:]]'; then
268 + new_format=true
269 + fi
270 + fi
271 +
272 + # Return status
273 + if $old_format && $new_format; then
274 + echo "both"
275 + elif $old_format; then
276 + echo "old"
277 + elif $new_format; then
278 + echo "new"
239 279 else
240 - print_error "Cannot detect APT source format"
241 - rollback_on_error
280 + echo "none"
242 281 fi
243 282 }
244 283
245 - function convert_old_to_new_format() {
246 - print_ok "Converting old format to new DEB822 format..."
247 -
248 - if [ ! -f "/etc/apt/sources.list" ] || [ ! -s "/etc/apt/sources.list" ]; then
249 - print_error "/etc/apt/sources.list not found or empty"
250 - rollback_on_error
251 - fi
252 -
253 - # Backup the old sources.list
254 - cp /etc/apt/sources.list /etc/apt/sources.list.backup
255 -
256 - # Extract mirror URLs from existing sources.list (Restored from Old Script)
257 - # Try to detect main archive mirror
258 - MIRROR_URL=$(grep -E "^deb " /etc/apt/sources.list | grep -v "security" | head -1 | awk '{print $2}')
259 - if [ -z "$MIRROR_URL" ]; then
260 - MIRROR_URL="http://archive.ubuntu.com/ubuntu/"
261 - fi
262 -
263 - # Try to detect security mirror
264 - SECURITY_URL=$(grep -E "^deb " /etc/apt/sources.list | grep "security" | head -1 | awk '{print $2}')
265 - if [ -z "$SECURITY_URL" ]; then
266 - SECURITY_URL="http://security.ubuntu.com/ubuntu/"
284 + function find_fastest_mirror() {
285 + # Redirect all output to stderr
286 + echo "Testing mirror speeds..." >&2
287 +
288 + # Enable required packages
289 + apt install -y curl lsb-release >&2
290 +
291 + # Get current Ubuntu codename
292 + codename=$(lsb_release -cs)
293 +
294 + # Define list of potential mirrors
295 + mirrors=(
296 + "https://archive.ubuntu.com/ubuntu/"
297 + "https://mirror.aarnet.edu.au/pub/ubuntu/archive/" # Australia
298 + "https://mirror.fsmg.org.nz/ubuntu/" # New Zealand
299 + "https://mirrors.neterra.net/ubuntu/archive/" # Bulgaria
300 + "https://mirror.csclub.uwaterloo.ca/ubuntu/" # Canada
301 + "https://mirrors.dotsrc.org/ubuntu/" # Denmark
302 + "https://mirrors.nic.funet.fi/ubuntu/" # Finland
303 + "https://mirror.ubuntu.ikoula.com/" # France
304 + "https://mirror.xtom.com.hk/ubuntu/" # Hong Kong
305 + "https://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu/" # India
306 + "https://ftp.udx.icscoe.jp/Linux/ubuntu/" # Japan
307 + "https://ftp.kaist.ac.kr/ubuntu/" # Korea
308 + "https://ubuntu.mirror.garr.it/ubuntu/" # Italy
309 + "https://ftp.uni-stuttgart.de/ubuntu/" # Germany
310 + "https://mirror.i3d.net/pub/ubuntu/" # Netherlands
311 + "https://mirroronet.pl/pub/mirrors/ubuntu/" # Poland
312 + "https://ubuntu.mobinhost.com/ubuntu/" # Iran
313 + "http://sg.archive.ubuntu.com/ubuntu/" # Singapore
314 + "http://ossmirror.mycloud.services/os/linux/ubuntu/" # Singapore
315 + "https://mirror.enzu.com/ubuntu/" # United States
316 + "http://jp.archive.ubuntu.com/ubuntu/" # Japan
317 + "http://kr.archive.ubuntu.com/ubuntu/" # Korea
318 + "http://us.archive.ubuntu.com/ubuntu/" # United States
319 + "http://tw.archive.ubuntu.com/ubuntu/" # Taiwan
320 + "https://mirror.twds.com.tw/ubuntu/" # Taiwan
321 + "https://ubuntu.mirrors.uk2.net/ubuntu/" # United Kingdom
322 + "http://mirrors.ustc.edu.cn/ubuntu/" # USTC
323 + "http://ftp.sjtu.edu.cn/ubuntu/" # SJTU
324 + "http://mirrors.tuna.tsinghua.edu.cn/ubuntu/" # Tsinghua
325 + "http://mirrors.aliyun.com/ubuntu/" # Aliyun
326 + "http://mirrors.163.com/ubuntu/" # NetEase
327 + "http://mirrors.cloud.tencent.com/ubuntu/" # Tencent Cloud
328 + "http://mirrors.huaweicloud.com/ubuntu/" # Huawei Cloud
329 + "http://mirrors.zju.edu.cn/ubuntu/" # Zhejiang University
330 + "http://azure.archive.ubuntu.com/ubuntu/" # Azure
331 + "https://mirrors.isu.net.sa/apt-mirror/" # Saudi Arabia
332 + "https://mirror.team-host.ru/ubuntu/" # Russia
333 + "https://labs.eif.urjc.es/mirror/ubuntu/" # Spain
334 + "https://mirror.alastyr.com/ubuntu/ubuntu-archive/" # Turkey
335 + "https://ftp.acc.umu.se/ubuntu/" # Sweden
336 + "https://mirror.kku.ac.th/ubuntu/" # Thailand
337 + "https://mirror.bizflycloud.vn/ubuntu/" # Vietnam
338 + )
339 +
340 + declare -A results
341 +
342 + # Test speed of each mirror
343 + for mirror in "${mirrors[@]}"; do
344 + echo "Testing $mirror ..." >&2
345 + response="$(curl -o /dev/null -s -w "%{http_code} %{time_total}\n" \
346 + --connect-timeout 1 --max-time 3 "${mirror}dists/${codename}/Release")"
347 +
348 + http_code=$(echo "$response" | awk '{print $1}')
349 + time_total=$(echo "$response" | awk '{print $2}')
350 +
351 + if [ "$http_code" -eq 200 ]; then
352 + results["$mirror"]="$time_total"
353 + echo " Success: $time_total seconds" >&2
354 + else
355 + echo " Failed: HTTP code $http_code" >&2
356 + results["$mirror"]="9999"
357 + fi
358 + done
359 +
360 + # Sort mirrors by response time
361 + sorted_mirrors="$(
362 + for url in "${!results[@]}"; do
363 + echo "$url ${results[$url]}"
364 + done | sort -k2 -n
365 + )"
366 +
367 + echo >&2
368 + echo "=== Mirrors sorted by response time (ascending) ===" >&2
369 + echo "$sorted_mirrors" >&2
370 + echo >&2
371 +
372 + # Choose the fastest mirror
373 + fastest_mirror="$(echo "$sorted_mirrors" | head -n 1 | awk '{print $1}')"
374 +
375 + if [[ "$fastest_mirror" == "" || "${results[$fastest_mirror]}" == "9999" ]]; then
376 + echo "No usable mirror found, using default mirror" >&2
377 + fastest_mirror="http://archive.ubuntu.com/ubuntu/"
267 378 fi
379 +
380 + echo "Fastest mirror found: $fastest_mirror" >&2
268 381
269 - print_ok "Detected mirror URL: $MIRROR_URL"
270 - print_ok "Detected security URL: $SECURITY_URL"
271 -
272 - # Create new ubuntu.sources file using detected mirrors
273 - bash -c "cat > /etc/apt/sources.list.d/ubuntu.sources" <<EOF
382 + # Only this line will be returned to caller
383 + echo "$fastest_mirror"
384 + }
385 +
386 + function generate_new_format() {
387 + local mirror="$1"
388 + local codename="$2"
389 +
390 + print_ok "Generating new format source list /etc/apt/sources.list.d/ubuntu.sources"
391 +
392 + cat > /etc/apt/sources.list.d/ubuntu.sources <<EOF
274 393 Types: deb
275 - URIs: ${MIRROR_URL}
276 - Suites: plucky plucky-updates plucky-backports
394 + URIs: $mirror
395 + Suites: $codename
277 396 Components: main restricted universe multiverse
278 397 Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
279 398
280 399 Types: deb
281 - URIs: ${SECURITY_URL}
282 - Suites: plucky-security
400 + URIs: $mirror
401 + Suites: $codename-updates
402 + Components: main restricted universe multiverse
403 + Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
404 +
405 + Types: deb
406 + URIs: $mirror
407 + Suites: $codename-backports
408 + Components: main restricted universe multiverse
409 + Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
410 +
411 + Types: deb
412 + URIs: $mirror
413 + Suites: $codename-security
283 414 Components: main restricted universe multiverse
284 415 Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
285 416 EOF
286 -
287 - # Clear the old sources.list
288 - bash -c 'echo "# This file is deprecated. See /etc/apt/sources.list.d/ubuntu.sources" > /etc/apt/sources.list'
289 -
290 - judge "Convert to new format"
417 +
418 + print_ok "New format source list updated"
419 + }
420 +
421 + function optimize_apt_sources() {
422 + print_ok "Optimizing APT sources..."
423 +
424 + # Install required packages if missing
425 + if ! command -v curl &> /dev/null || ! command -v lsb_release &> /dev/null; then
426 + print_ok "Installing curl and lsb-release..."
427 + apt update && apt install -y curl lsb-release
428 + fi
429 +
430 + local format=$(check_apt_source_format)
431 + print_ok "Current APT source format status: $format"
432 +
433 + local codename=$(lsb_release -cs)
434 + print_ok "Ubuntu codename: $codename"
435 +
436 + if [ "$format" == "new" ]; then
437 + print_ok "Already in new format. Skipping mirror re-check to preserve user settings."
438 + return
439 + fi
440 +
441 + print_ok "Searching for the fastest mirror..."
442 + # Capture output, separating stdout (result) from stderr (logs)
443 + # But find_fastest_mirror already handles >&2 for logs
444 + local fastest_mirror
445 + fastest_mirror=$(find_fastest_mirror)
446 + print_ok "Fastest mirror selected: $fastest_mirror"
447 +
448 + case "$format" in
449 + "none" | "old")
450 + print_ok "Converting to modern format..."
451 + generate_new_format "$fastest_mirror" "$codename"
452 +
453 + if [ -f "/etc/apt/sources.list" ]; then
454 + mv /etc/apt/sources.list /etc/apt/sources.list.bak
455 + print_ok "Old sources.list backed up"
456 + fi
457 + ;;
458 + "both")
459 + print_ok "Consolidating formats..."
460 + mv /etc/apt/sources.list /etc/apt/sources.list.bak
461 + print_ok "Old format source list backed up to /etc/apt/sources.list.bak"
462 + generate_new_format "$fastest_mirror" "$codename"
463 + ;;
464 + esac
465 +
466 + judge "Optimize APT sources"
291 467 }
292 468
293 469 function replace_plucky_with_questing() {
@@ -382,13 +558,14 @@ EOF
382 558 print_ok "Release files updated successfully"
383 559 }
384 560
385 - function restore_ppa_sources() {
386 - print_ok "Restoring PPA sources..."
561 + function restore_and_upgrade_ppa_sources() {
562 + print_ok "Restoring and upgrading PPA sources..."
387 563
388 564 if [ -d "$PPA_BACKUP_DIR" ]; then
389 565 ppa_count=$(ls -1 "$PPA_BACKUP_DIR" 2>/dev/null | wc -l)
390 566
391 567 if [ "$ppa_count" -gt 0 ]; then
568 + # Restore files first
392 569 for file in "$PPA_BACKUP_DIR"/*; do
393 570 if [ -f "$file" ]; then
394 571 mv "$file" /etc/apt/sources.list.d/
@@ -396,9 +573,57 @@ function restore_ppa_sources() {
396 573 fi
397 574 done
398 575
576 + # Check and upgrade PPA configurations
577 + print_ok "Checking restored PPAs for version 'plucky'..."
578 + local upgraded_count=0
579 +
580 + # Iterate over all files in sources.list.d to be safe
581 + for file in /etc/apt/sources.list.d/*; do
582 + if [ -f "$file" ]; then
583 + # Skip ubuntu.sources to avoid messing with core repos
584 + if [ "$(basename "$file")" == "ubuntu.sources" ]; then
585 + continue
586 + fi
587 +
588 + # Check if file contains "plucky"
589 + if grep -q "plucky" "$file"; then
590 + local ppa_name=$(basename "$file")
591 +
592 + # Extract URL (First valid HTTP/HTTPS URL)
593 + local url=$(grep -oE 'https?://[^ ]+' "$file" | head -n1)
594 + local can_upgrade=false
595 +
596 + if [ -n "$url" ]; then
597 + # Remove trailing slash
598 + url="${url%/}"
599 +
600 + # Check availability (Release or InRelease)
601 + # We use a silent check with timeout to verify if the new questing dist exists
602 + if curl -s -I -f -L --max-time 3 "$url/dists/questing/Release" &>/dev/null || \
603 + curl -s -I -f -L --max-time 3 "$url/dists/questing/InRelease" &>/dev/null; then
604 + can_upgrade=true
605 + fi
606 + fi
607 +
608 + if $can_upgrade; then
609 + sed -i 's/plucky/questing/g' "$file"
610 + print_ok "Upgraded PPA $ppa_name to questing"
611 + ((upgraded_count++))
612 + else
613 + print_warn "PPA $ppa_name does not support 'questing' yet (Connection failed or 404)."
614 + print_warn "Disabling $ppa_name to ensure clean upgrade."
615 + mv "$file" "${file}.save"
616 + fi
617 + fi
618 + fi
619 + done
620 +
621 + if [ "$upgraded_count" -eq 0 ]; then
622 + print_ok "No PPA files needed version upgrading."
623 + fi
399 624 print_ok "Running apt update with restored PPAs..."
400 625 apt update
401 - judge "Restore PPA sources and update"
626 + judge "Restore and upgrade PPA sources"
402 627 else
403 628 print_ok "No PPA sources to restore"
404 629 fi
@@ -407,10 +632,37 @@ function restore_ppa_sources() {
407 632 fi
408 633 }
409 634
635 + function cleanup_system() {
636 + print_ok "Cleaning up system..."
637 + print_ok "Removing unused packages (orphans)..."
638 + if apt autoremove -y; then
639 + print_ok "apt autoremove succeeded"
640 + else
641 + print_warn "apt autoremove failed, but upgrade was successful."
642 + fi
643 +
644 + print_ok "Cleaning apt cache..."
645 + if apt clean; then
646 + print_ok "apt clean succeeded"
647 + else
648 + print_warn "apt clean failed, but upgrade was successful."
649 + fi
650 + }
651 +
410 652 function main() {
411 653 # 1. Ensure we are root first
412 654 ensure_root
413 655
656 + # --- Enable Logging ---
657 + LOG_FILE="/var/log/anduinos-upgrade.log"
658 + # Create a fresh log section
659 + echo "--- Upgrade Session Started at $(date) ---" >> "$LOG_FILE"
660 +
661 + # Redirect stdout and stderr to tee, appending to the log file
662 + exec > >(tee -a "$LOG_FILE") 2>&1
663 +
664 + print_ok "Output is being logged to: $LOG_FILE"
665 +
414 666 print_ok "Starting AnduinOS upgrade process..."
415 667
416 668 echo -e "${Yellow}WARNING: This script will upgrade your system from 1.3.7 (plucky) to 1.4.1 (questing).${Font}"
@@ -425,7 +677,10 @@ function main() {
425 677 fi
426 678 fi
427 679
428 - # Step 0: Configure Unattended (Anti-Prompt)
680 + # Step 0: Check Safeguards
681 + check_ssh_safeguard
682 +
683 + # Step 1: Configure Unattended (Anti-Prompt)
429 684 configure_unattended
430 685
431 686 # Step 1: Check disk space
@@ -440,10 +695,8 @@ function main() {
440 695 # Step 4: Backup and remove PPA sources
441 696 backup_and_remove_ppa
442 697
443 - # Step 5: Detect and convert APT format if needed
444 - if ! detect_apt_format; then
445 - convert_old_to_new_format
446 - fi
698 + # Step 5: Detect and convert APT format
699 + optimize_apt_sources
447 700
448 701 # Step 6: Replace plucky with questing
449 702 replace_plucky_with_questing
@@ -457,8 +710,11 @@ function main() {
457 710 # Step 9: Update release files (to 1.4.1)
458 711 update_release_files
459 712
460 - # Step 10: Restore PPA sources
461 - restore_ppa_sources
713 + # Step 10: Restore and upgrade PPA sources
714 + restore_and_upgrade_ppa_sources
715 +
716 + # Step 11: Cleanup system
717 + cleanup_system
462 718
463 719 print_ok "Upgrade completed successfully!"
464 720 print_ok "Your system has been upgraded to AnduinOS 1.4.1 (questing)"

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

1 file changed, 6 insertions, 2 deletions

do_anduinos_distupgrade.sh

@@ -176,10 +176,14 @@ function check_disk_space() {
176 176 }
177 177
178 178 function update_system() {
179 - print_ok "Running apt update and upgrade (pre-flight)..."
179 + print_ok "Ensuring current system (1.3 / Ubuntu 25.04) is fully updated..."
180 +
181 + print_ok "Running apt update..."
180 182 apt update
181 183 judge "apt update"
182 - # Use non-interactive flags
184 +
185 + print_ok "Installing any missing updates for the current version..."
186 + # Use non-interactive flags to ensure current 1.3 packages are up-to-date
183 187 DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt upgrade -y
184 188 judge "apt upgrade"
185 189 }

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

1 file changed, 172 insertions, 41 deletions

do_anduinos_distupgrade.sh

@@ -15,6 +15,7 @@ set -e
15 15 set -o pipefail
16 16 set -u
17 17
18 + # --- 1. Visual Definitions ---
18 19 Green="\033[32m"
19 20 Red="\033[31m"
20 21 Yellow="\033[33m"
@@ -24,13 +25,14 @@ OK="${Green}[ OK ]${Font}"
24 25 ERROR="${Red}[FAILED]${Font}"
25 26 WARNING="${Yellow}[ WARN ]${Font}"
26 27
27 - # Backup Configuration
28 + # --- 2. Configuration ---
29 + # Use /var/backups for persistence and space safety
28 30 BACKUP_ROOT="/var/backups/anduinos-upgrade"
29 31 BACKUP_DIR="$BACKUP_ROOT/backup_$(date +%Y%m%d_%H%M%S)"
30 32 PPA_BACKUP_DIR="$BACKUP_DIR/ppa"
31 33 UBUNTU_SOURCE_BACKUP="$BACKUP_DIR/ubuntu_sources"
32 34
33 - # --- Helper Functions ---
35 + # --- 3. Helper Functions (Logging) ---
34 36
35 37 function print_ok() {
36 38 echo -e "${OK} ${Blue} $1 ${Font}"
@@ -44,7 +46,7 @@ function print_warn() {
44 46 echo -e "${WARNING} ${Yellow} $1 ${Font}"
45 47 }
46 48
47 - # --- Privilege Check ---
49 + # --- 4. Privilege Check (Auto-Elevation) ---
48 50
49 51 function ensure_root() {
50 52 if [ "$EUID" -ne 0 ]; then
@@ -56,58 +58,86 @@ function ensure_root() {
56 58 exit 1
57 59 fi
58 60
61 + # Re-execute the script with sudo, preserving arguments
59 62 exec sudo "$0" "$@"
60 63 exit 0
61 64 fi
65 + # If we are here, we are root.
62 66 }
63 67
64 - # --- Core Logic ---
68 + # --- 5. Unattended Configuration (Anti-Prompt) ---
65 69
66 70 function configure_unattended() {
67 - print_ok "Configuring system for unattended upgrades (avoiding prompts)..."
71 + print_ok "Configuring system for unattended upgrades..."
68 72
69 - # 1. Install debconf-utils if missing (needed to pre-seed answers)
73 + # Install debconf-utils to pre-seed answers
70 74 if ! command -v debconf-set-selections &> /dev/null; then
71 - apt-get install -y debconf-utils
75 + print_ok "Installing debconf-utils..."
76 + apt-get update && apt-get install -y debconf-utils
72 77 fi
73 78
74 - # 2. Pre-answer "Yes" to "Restart services during package upgrades without asking?"
75 - # This kills the specific dialog you saw (libc6/libpam)
79 + # Pre-answer "Yes" to "Restart services during package upgrades without asking?"
80 + # This kills the libc6/libpam dialog.
76 81 echo '* libraries/restart-without-asking boolean true' | debconf-set-selections
77 82
78 - # 3. Configure needrestart to be automatic (fixes the purple screen prompt on newer Ubuntu)
79 - # 'a' = automatically restart services
83 + # Configure environment variables for the session
84 + # NEEDRESTART_MODE=a : Automatically restart services (fixes purple screen prompt)
80 85 export NEEDRESTART_MODE=a
81 86 export DEBIAN_FRONTEND=noninteractive
82 87
83 88 judge "Configure unattended mode"
84 89 }
85 90
91 + # --- 6. Core Logic with Detailed Rollback ---
92 +
86 93 function rollback_on_error() {
87 94 print_error "An error occurred during the upgrade process"
88 95 print_warn "Starting rollback procedure..."
89 96
97 + # Restore ubuntu.sources if backup exists
90 98 if [ -f "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" ]; then
99 + print_ok "Restoring ubuntu.sources..."
91 100 cp "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" /etc/apt/sources.list.d/
92 101 print_ok "Restored ubuntu.sources"
93 102 fi
94 103
104 + # Restore sources.list if backup exists
95 105 if [ -f "$UBUNTU_SOURCE_BACKUP/sources.list" ]; then
106 + print_ok "Restoring sources.list..."
96 107 cp "$UBUNTU_SOURCE_BACKUP/sources.list" /etc/apt/
97 108 print_ok "Restored sources.list"
98 109 fi
99 110
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"
111 + # Restore PPA sources (Detailed Loop from Old Script)
112 + if [ -d "$PPA_BACKUP_DIR" ]; then
113 + ppa_count=$(ls -1 "$PPA_BACKUP_DIR" 2>/dev/null | wc -l)
114 +
115 + if [ "$ppa_count" -gt 0 ]; then
116 + print_ok "Restoring PPA sources..."
117 + for file in "$PPA_BACKUP_DIR"/*; do
118 + if [ -f "$file" ]; then
119 + cp "$file" /etc/apt/sources.list.d/
120 + print_ok "Restored $(basename "$file")"
121 + fi
122 + done
123 + fi
103 124 fi
104 125
105 - rm -f /etc/apt/apt.conf.d/99-local-versions
126 + # Remove temporary apt configuration if exists
127 + if [ -f "/etc/apt/apt.conf.d/99-local-versions" ]; then
128 + rm -f /etc/apt/apt.conf.d/99-local-versions
129 + print_ok "Removed temporary apt configuration"
130 + fi
106 131
132 + # Run apt update to restore repository state
107 133 print_ok "Running apt update to restore repository state..."
108 134 apt update || true
109 135
110 - print_warn "Rollback completed. Backup preserved in: $BACKUP_DIR"
136 + print_warn "Rollback completed"
137 + print_warn "Your system has been restored to the previous state"
138 + print_warn "Backup files are preserved in: $BACKUP_DIR"
139 + print_error "Please check the error messages above and try again"
140 +
111 141 exit 1
112 142 }
113 143
@@ -123,62 +153,84 @@ function judge() {
123 153
124 154 function check_disk_space() {
125 155 print_ok "Checking available disk space..."
156 +
157 + # Ensure backup directory exists
126 158 mkdir -p "$BACKUP_DIR"
159 +
160 + # Get available space in / (in KB)
127 161 local root_space=$(df / | awk 'NR==2 {print $4}')
162 + # Convert to MB
128 163 local root_space_mb=$((root_space / 1024))
164 + # Required space: 2GB
129 165 local required_space=2048
130 166
131 167 print_ok "Available space in /: ${root_space_mb}MB"
168 + print_ok "Backup location: $BACKUP_DIR"
132 169
133 170 if [ "$root_space_mb" -lt "$required_space" ]; then
134 - print_error "Insufficient disk space in /. Required: ${required_space}MB"
171 + print_error "Insufficient disk space in /. Required: ${required_space}MB, Available: ${root_space_mb}MB"
135 172 exit 1
136 173 fi
174 +
137 175 print_ok "Disk space check passed"
138 176 }
139 177
140 178 function update_system() {
141 - print_ok "Running apt update and upgrade..."
179 + print_ok "Running apt update and upgrade (pre-flight)..."
142 180 apt update
143 181 judge "apt update"
144 -
145 - # Pass environment variables explicitly to be safe
182 + # Use non-interactive flags
146 183 DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt upgrade -y
147 184 judge "apt upgrade"
148 185 }
149 186
150 187 function backup_ubuntu_sources() {
151 188 print_ok "Backing up Ubuntu official sources..."
189 +
152 190 mkdir -p "$UBUNTU_SOURCE_BACKUP"
153 191
192 + # Backup ubuntu.sources if exists
154 193 if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
155 194 cp /etc/apt/sources.list.d/ubuntu.sources "$UBUNTU_SOURCE_BACKUP/"
195 + print_ok "Backed up ubuntu.sources"
156 196 fi
157 197
198 + # Backup sources.list if it exists and is not empty
158 199 if [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
159 200 cp /etc/apt/sources.list "$UBUNTU_SOURCE_BACKUP/"
201 + print_ok "Backed up sources.list"
160 202 fi
203 +
161 204 judge "Backup Ubuntu sources"
162 205 }
163 206
164 207 function backup_and_remove_ppa() {
165 208 print_ok "Backing up and temporarily removing PPA sources..."
209 +
166 210 mkdir -p "$PPA_BACKUP_DIR"
167 211
212 + # Move all files in /etc/apt/sources.list.d/ except ubuntu.sources
168 213 if [ -d "/etc/apt/sources.list.d" ]; then
169 214 for file in /etc/apt/sources.list.d/*; do
170 215 if [ -f "$file" ] && [ "$(basename "$file")" != "ubuntu.sources" ]; then
171 216 mv "$file" "$PPA_BACKUP_DIR/"
217 + print_ok "Moved $(basename "$file") to backup"
172 218 fi
173 219 done
174 220 fi
221 +
222 + print_ok "PPA sources moved to: $PPA_BACKUP_DIR"
175 223 judge "Backup and remove PPA sources"
176 224 }
177 225
178 226 function detect_apt_format() {
227 + print_ok "Detecting APT source format..."
228 +
179 229 if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
230 + print_ok "Detected new DEB822 format (ubuntu.sources)"
180 231 return 0
181 232 elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
233 + print_ok "Detected old format (sources.list)"
182 234 return 1
183 235 else
184 236 print_error "Cannot detect APT source format"
@@ -188,14 +240,32 @@ function detect_apt_format() {
188 240
189 241 function convert_old_to_new_format() {
190 242 print_ok "Converting old format to new DEB822 format..."
243 +
244 + if [ ! -f "/etc/apt/sources.list" ] || [ ! -s "/etc/apt/sources.list" ]; then
245 + print_error "/etc/apt/sources.list not found or empty"
246 + rollback_on_error
247 + fi
248 +
249 + # Backup the old sources.list
191 250 cp /etc/apt/sources.list /etc/apt/sources.list.backup
192 251
252 + # Extract mirror URLs from existing sources.list (Restored from Old Script)
253 + # Try to detect main archive mirror
193 254 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/"
255 + if [ -z "$MIRROR_URL" ]; then
256 + MIRROR_URL="http://archive.ubuntu.com/ubuntu/"
257 + fi
195 258
259 + # Try to detect security mirror
196 260 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/"
261 + if [ -z "$SECURITY_URL" ]; then
262 + SECURITY_URL="http://security.ubuntu.com/ubuntu/"
263 + fi
198 264
265 + print_ok "Detected mirror URL: $MIRROR_URL"
266 + print_ok "Detected security URL: $SECURITY_URL"
267 +
268 + # Create new ubuntu.sources file using detected mirrors
199 269 bash -c "cat > /etc/apt/sources.list.d/ubuntu.sources" <<EOF
200 270 Types: deb
201 271 URIs: ${MIRROR_URL}
@@ -210,34 +280,43 @@ Components: main restricted universe multiverse
210 280 Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
211 281 EOF
212 282
283 + # Clear the old sources.list
213 284 bash -c 'echo "# This file is deprecated. See /etc/apt/sources.list.d/ubuntu.sources" > /etc/apt/sources.list'
285 +
214 286 judge "Convert to new format"
215 287 }
216 288
217 289 function replace_plucky_with_questing() {
218 - print_ok "Replacing plucky with questing..."
290 + print_ok "Replacing plucky with questing in ubuntu.sources..."
291 +
292 + if [ ! -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
293 + print_error "/etc/apt/sources.list.d/ubuntu.sources not found"
294 + rollback_on_error
295 + fi
296 +
219 297 sed -i 's/plucky/questing/g' /etc/apt/sources.list.d/ubuntu.sources
220 298 judge "Replace plucky with questing"
221 299
222 - print_ok "Updating package lists..."
300 + print_ok "Running apt update with questing repositories..."
223 301 apt update
224 302 judge "apt update with questing"
225 303 }
226 304
227 305 function install_coreutils_uutils() {
228 306 print_ok "Installing coreutils-from-uutils..."
307 +
229 308 DEBIAN_FRONTEND=noninteractive apt install -y coreutils-from-uutils
230 309 judge "Install coreutils-from-uutils"
231 310 }
232 311
233 312 function run_dist_upgrade() {
234 - print_ok "Simulating upgrade..."
313 + print_ok "Simulating apt dist-upgrade first..."
235 314 apt -s dist-upgrade > /dev/null
236 - judge "apt simulation"
315 + judge "apt -s dist-upgrade"
237 316
238 - print_ok "Running full distribution upgrade..."
317 + print_ok "Running apt dist-upgrade in non-interactive mode..."
239 318
240 - # Create local config to force defaults for config files
319 + # Configure dpkg to keep local versions by default
241 320 bash -c 'cat > /etc/apt/apt.conf.d/99-local-versions <<EOF
242 321 Dpkg::Options {
243 322 "--force-confdef";
@@ -245,21 +324,25 @@ Dpkg::Options {
245 324 }
246 325 EOF'
247 326
248 - # The Big Command:
249 - # DEBIAN_FRONTEND=noninteractive: Hides standard dialogs
250 - # NEEDRESTART_MODE=a: Automatically restarts services without asking (Fixes your issue)
327 + # Run dist-upgrade
328 + # Combine variables: DEBIAN_FRONTEND, NEEDRESTART_MODE, APT_LISTCHANGES
251 329 bash -c 'DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a APT_LISTCHANGES_FRONTEND=none \
252 330 apt-get -y dist-upgrade \
253 331 -o Dpkg::Options::="--force-confdef" \
254 332 -o Dpkg::Options::="--force-confold"'
255 333
256 334 judge "apt dist-upgrade"
335 +
336 + # Remove temporary configuration
257 337 rm -f /etc/apt/apt.conf.d/99-local-versions
258 338 }
259 339
260 340 function update_release_files() {
261 - print_ok "Updating release info..."
341 + print_ok "Updating release information files to 1.4.1..."
342 +
343 + # Update /etc/os-release
262 344 if [ -f "/etc/os-release" ]; then
345 + print_ok "Updating /etc/os-release..."
263 346 bash -c "cat > /etc/os-release" <<EOF
264 347 PRETTY_NAME="AnduinOS 1.4.1"
265 348 NAME="AnduinOS"
@@ -274,61 +357,109 @@ BUG_REPORT_URL="https://github.com/Anduin2017/AnduinOS/issues"
274 357 PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
275 358 UBUNTU_CODENAME=questing
276 359 EOF
360 +
361 + judge "Update /etc/os-release"
277 362 fi
278 363
364 + # Update /etc/lsb-release
279 365 if [ -f "/etc/lsb-release" ]; then
366 + print_ok "Updating /etc/lsb-release..."
367 +
280 368 bash -c "cat > /etc/lsb-release" <<EOF
281 369 DISTRIB_ID=AnduinOS
282 370 DISTRIB_RELEASE=1.4.1
283 371 DISTRIB_CODENAME=questing
284 372 DISTRIB_DESCRIPTION="AnduinOS 1.4.1"
285 373 EOF
374 +
375 + judge "Update /etc/lsb-release"
286 376 fi
287 - judge "Update release files"
377 +
378 + print_ok "Release files updated successfully"
288 379 }
289 380
290 381 function restore_ppa_sources() {
291 382 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
383 +
384 + if [ -d "$PPA_BACKUP_DIR" ]; then
385 + ppa_count=$(ls -1 "$PPA_BACKUP_DIR" 2>/dev/null | wc -l)
386 +
387 + if [ "$ppa_count" -gt 0 ]; then
388 + for file in "$PPA_BACKUP_DIR"/*; do
389 + if [ -f "$file" ]; then
390 + mv "$file" /etc/apt/sources.list.d/
391 + print_ok "Restored $(basename "$file")"
392 + fi
393 + done
394 +
395 + print_ok "Running apt update with restored PPAs..."
396 + apt update
397 + judge "Restore PPA sources and update"
398 + else
399 + print_ok "No PPA sources to restore"
400 + fi
401 + else
402 + print_warn "PPA backup directory not found, skipping restore"
295 403 fi
296 404 }
297 405
298 406 function main() {
407 + # 1. Ensure we are root first
299 408 ensure_root
300 409
301 410 print_ok "Starting AnduinOS upgrade process..."
302 411
303 - # Interactive check for the human, but not for the machine
412 + echo -e "${Yellow}WARNING: This script will upgrade your system from 1.3.7 (plucky) to 1.4.1 (questing).${Font}"
413 + echo -e "${Yellow}Please ensure you have backed up important data before proceeding.${Font}"
414 +
415 + # Interactive check only if we have a terminal (TTY)
304 416 if [ -t 0 ]; then
305 - read -p "Upgrade from plucky (1.3.7) to questing (1.4.1)? (y/N): " confirm
417 + read -p "Do you want to continue? (y/N): " confirm
306 418 if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
419 + print_error "Upgrade process aborted by user."
307 420 exit 1
308 421 fi
309 422 fi
310 423
311 - # --- NEW STEP: Pre-configure silencing ---
424 + # Step 0: Configure Unattended (Anti-Prompt)
312 425 configure_unattended
313 - # -----------------------------------------
314 426
427 + # Step 1: Check disk space
315 428 check_disk_space
429 +
430 + # Step 2: Update current system
316 431 update_system
432 +
433 + # Step 3: Backup Ubuntu official sources
317 434 backup_ubuntu_sources
435 +
436 + # Step 4: Backup and remove PPA sources
318 437 backup_and_remove_ppa
319 438
439 + # Step 5: Detect and convert APT format if needed
320 440 if ! detect_apt_format; then
321 441 convert_old_to_new_format
322 442 fi
323 443
444 + # Step 6: Replace plucky with questing
324 445 replace_plucky_with_questing
446 +
447 + # Step 7: Install coreutils-from-uutils
325 448 install_coreutils_uutils
449 +
450 + # Step 8: Run dist-upgrade
326 451 run_dist_upgrade
452 +
453 + # Step 9: Update release files (to 1.4.1)
327 454 update_release_files
455 +
456 + # Step 10: Restore PPA sources
328 457 restore_ppa_sources
329 458
330 459 print_ok "Upgrade completed successfully!"
331 - print_warn "Please reboot your system."
460 + print_ok "Your system has been upgraded to AnduinOS 1.4.1 (questing)"
461 + print_ok "Backup files are stored in: $BACKUP_DIR"
462 + print_warn "Please reboot your system to complete the upgrade."
332 463 }
333 464
334 465 main

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

1 file changed, 41 insertions, 56 deletions

do_anduinos_distupgrade.sh

@@ -51,64 +51,63 @@ function ensure_root() {
51 51 print_warn "This script requires root privileges."
52 52 print_ok "Attempting to escalate privileges via sudo..."
53 53
54 - # Check if sudo is available
55 54 if ! command -v sudo &> /dev/null; then
56 55 print_error "sudo is not installed. Please run this script as root."
57 56 exit 1
58 57 fi
59 58
60 - # Re-execute the script with sudo, preserving arguments
61 - # exec replaces the current process, so the script runs anew as root
62 59 exec sudo "$0" "$@"
63 60 exit 0
64 61 fi
65 - # If we are here, we are root (or sudo-ed successfully)
66 62 }
67 63
68 64 # --- Core Logic ---
69 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 +
70 86 function rollback_on_error() {
71 87 print_error "An error occurred during the upgrade process"
72 88 print_warn "Starting rollback procedure..."
73 89
74 - # Restore ubuntu.sources if backup exists
75 90 if [ -f "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" ]; then
76 - print_ok "Restoring ubuntu.sources..."
77 91 cp "$UBUNTU_SOURCE_BACKUP/ubuntu.sources" /etc/apt/sources.list.d/
78 92 print_ok "Restored ubuntu.sources"
79 93 fi
80 94
81 - # Restore sources.list if backup exists
82 95 if [ -f "$UBUNTU_SOURCE_BACKUP/sources.list" ]; then
83 - print_ok "Restoring sources.list..."
84 96 cp "$UBUNTU_SOURCE_BACKUP/sources.list" /etc/apt/
85 97 print_ok "Restored sources.list"
86 98 fi
87 99
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 + 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"
100 103 fi
101 104
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
105 + rm -f /etc/apt/apt.conf.d/99-local-versions
106 106
107 107 print_ok "Running apt update to restore repository state..."
108 108 apt update || true
109 109
110 - print_warn "Rollback completed. System restored to previous state."
111 - print_warn "Backup preserved in: $BACKUP_DIR"
110 + print_warn "Rollback completed. Backup preserved in: $BACKUP_DIR"
112 111 exit 1
113 112 }
114 113
@@ -124,21 +123,17 @@ function judge() {
124 123
125 124 function check_disk_space() {
126 125 print_ok "Checking available disk space..."
127 -
128 126 mkdir -p "$BACKUP_DIR"
129 -
130 127 local root_space=$(df / | awk 'NR==2 {print $4}')
131 128 local root_space_mb=$((root_space / 1024))
132 129 local required_space=2048
133 130
134 131 print_ok "Available space in /: ${root_space_mb}MB"
135 - print_ok "Backup location: $BACKUP_DIR"
136 132
137 133 if [ "$root_space_mb" -lt "$required_space" ]; then
138 - print_error "Insufficient disk space in /. Required: ${required_space}MB, Available: ${root_space_mb}MB"
134 + print_error "Insufficient disk space in /. Required: ${required_space}MB"
139 135 exit 1
140 136 fi
141 -
142 137 print_ok "Disk space check passed"
143 138 }
144 139
@@ -146,7 +141,9 @@ function update_system() {
146 141 print_ok "Running apt update and upgrade..."
147 142 apt update
148 143 judge "apt update"
149 - apt upgrade -y
144 +
145 + # Pass environment variables explicitly to be safe
146 + DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt upgrade -y
150 147 judge "apt upgrade"
151 148 }
152 149
@@ -156,12 +153,10 @@ function backup_ubuntu_sources() {
156 153
157 154 if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
158 155 cp /etc/apt/sources.list.d/ubuntu.sources "$UBUNTU_SOURCE_BACKUP/"
159 - print_ok "Backed up ubuntu.sources"
160 156 fi
161 157
162 158 if [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
163 159 cp /etc/apt/sources.list "$UBUNTU_SOURCE_BACKUP/"
164 - print_ok "Backed up sources.list"
165 160 fi
166 161 judge "Backup Ubuntu sources"
167 162 }
@@ -174,7 +169,6 @@ function backup_and_remove_ppa() {
174 169 for file in /etc/apt/sources.list.d/*; do
175 170 if [ -f "$file" ] && [ "$(basename "$file")" != "ubuntu.sources" ]; then
176 171 mv "$file" "$PPA_BACKUP_DIR/"
177 - print_ok "Moved $(basename "$file") to backup"
178 172 fi
179 173 done
180 174 fi
@@ -182,12 +176,9 @@ function backup_and_remove_ppa() {
182 176 }
183 177
184 178 function detect_apt_format() {
185 - print_ok "Detecting APT source format..."
186 179 if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
187 - print_ok "Detected new DEB822 format"
188 180 return 0
189 181 elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
190 - print_ok "Detected old format (sources.list)"
191 182 return 1
192 183 else
193 184 print_error "Cannot detect APT source format"
@@ -197,7 +188,6 @@ function detect_apt_format() {
197 188
198 189 function convert_old_to_new_format() {
199 190 print_ok "Converting old format to new DEB822 format..."
200 -
201 191 cp /etc/apt/sources.list /etc/apt/sources.list.backup
202 192
203 193 MIRROR_URL=$(grep -E "^deb " /etc/apt/sources.list | grep -v "security" | head -1 | awk '{print $2}')
@@ -236,7 +226,7 @@ function replace_plucky_with_questing() {
236 226
237 227 function install_coreutils_uutils() {
238 228 print_ok "Installing coreutils-from-uutils..."
239 - apt install -y coreutils-from-uutils
229 + DEBIAN_FRONTEND=noninteractive apt install -y coreutils-from-uutils
240 230 judge "Install coreutils-from-uutils"
241 231 }
242 232
@@ -246,8 +236,8 @@ function run_dist_upgrade() {
246 236 judge "apt simulation"
247 237
248 238 print_ok "Running full distribution upgrade..."
249 - export DEBIAN_FRONTEND=noninteractive
250 239
240 + # Create local config to force defaults for config files
251 241 bash -c 'cat > /etc/apt/apt.conf.d/99-local-versions <<EOF
252 242 Dpkg::Options {
253 243 "--force-confdef";
@@ -255,19 +245,20 @@ Dpkg::Options {
255 245 }
256 246 EOF'
257 247
258 - bash -c 'DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none \
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 \
259 252 apt-get -y dist-upgrade \
260 253 -o Dpkg::Options::="--force-confdef" \
261 254 -o Dpkg::Options::="--force-confold"'
262 255
263 256 judge "apt dist-upgrade"
264 257 rm -f /etc/apt/apt.conf.d/99-local-versions
265 - unset DEBIAN_FRONTEND
266 258 }
267 259
268 260 function update_release_files() {
269 261 print_ok "Updating release info..."
270 -
271 262 if [ -f "/etc/os-release" ]; then
272 263 bash -c "cat > /etc/os-release" <<EOF
273 264 PRETTY_NAME="AnduinOS 1.4.1"
@@ -300,31 +291,27 @@ function restore_ppa_sources() {
300 291 print_ok "Restoring PPA sources..."
301 292 if [ -d "$PPA_BACKUP_DIR" ] && [ "$(ls -A $PPA_BACKUP_DIR)" ]; then
302 293 mv "$PPA_BACKUP_DIR"/* /etc/apt/sources.list.d/
303 - print_ok "Restored PPAs"
304 294 apt update
305 - judge "Update after PPA restore"
306 - else
307 - print_ok "No PPA sources to restore"
308 295 fi
309 296 }
310 297
311 298 function main() {
312 - # 1. Ensure we are root first
313 299 ensure_root
314 300
315 301 print_ok "Starting AnduinOS upgrade process..."
316 - echo -e "${Yellow}WARNING: Upgrading from 1.3.7 (plucky) to 1.4.1 (questing).${Font}"
317 302
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.
303 + # Interactive check for the human, but not for the machine
320 304 if [ -t 0 ]; then
321 - read -p "Do you want to continue? (y/N): " confirm
305 + read -p "Upgrade from plucky (1.3.7) to questing (1.4.1)? (y/N): " confirm
322 306 if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
323 - print_error "Aborted by user."
324 307 exit 1
325 308 fi
326 309 fi
327 310
311 + # --- NEW STEP: Pre-configure silencing ---
312 + configure_unattended
313 + # -----------------------------------------
314 +
328 315 check_disk_space
329 316 update_system
330 317 backup_ubuntu_sources
@@ -341,8 +328,6 @@ function main() {
341 328 restore_ppa_sources
342 329
343 330 print_ok "Upgrade completed successfully!"
344 - print_ok "System is now AnduinOS 1.4.1 (questing)"
345 - print_ok "Backups: $BACKUP_DIR"
346 331 print_warn "Please reboot your system."
347 332 }
348 333

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

1 file changed, 8 insertions, 8 deletions

do_anduinos_distupgrade.sh

@@ -4,7 +4,7 @@
4 4 # AnduinOS Upgrade Script
5 5 #=================================================
6 6 # This script upgrades AnduinOS from 1.3.7 (plucky)
7 - # to 1.4.0 (questing).
7 + # to 1.4.1 (questing).
8 8 #
9 9 # Usage:
10 10 # ./do_anduinos_distupgrade.sh
@@ -270,10 +270,10 @@ function update_release_files() {
270 270
271 271 if [ -f "/etc/os-release" ]; then
272 272 bash -c "cat > /etc/os-release" <<EOF
273 - PRETTY_NAME="AnduinOS 1.4.0"
273 + PRETTY_NAME="AnduinOS 1.4.1"
274 274 NAME="AnduinOS"
275 - VERSION_ID="1.4.0"
276 - VERSION="1.4.0 (questing)"
275 + VERSION_ID="1.4.1"
276 + VERSION="1.4.1 (questing)"
277 277 VERSION_CODENAME=questing
278 278 ID=ubuntu
279 279 ID_LIKE=debian
@@ -288,9 +288,9 @@ EOF
288 288 if [ -f "/etc/lsb-release" ]; then
289 289 bash -c "cat > /etc/lsb-release" <<EOF
290 290 DISTRIB_ID=AnduinOS
291 - DISTRIB_RELEASE=1.4.0
291 + DISTRIB_RELEASE=1.4.1
292 292 DISTRIB_CODENAME=questing
293 - DISTRIB_DESCRIPTION="AnduinOS 1.4.0"
293 + DISTRIB_DESCRIPTION="AnduinOS 1.4.1"
294 294 EOF
295 295 fi
296 296 judge "Update release files"
@@ -313,7 +313,7 @@ function main() {
313 313 ensure_root
314 314
315 315 print_ok "Starting AnduinOS upgrade process..."
316 - echo -e "${Yellow}WARNING: Upgrading from 1.3.7 (plucky) to 1.4.0 (questing).${Font}"
316 + echo -e "${Yellow}WARNING: Upgrading from 1.3.7 (plucky) to 1.4.1 (questing).${Font}"
317 317
318 318 # Since we are likely root now, we check if the script is running interactively before asking
319 319 # If we sudo-ed, we might have lost some TTY context, but usually 'read' works fine.
@@ -341,7 +341,7 @@ function main() {
341 341 restore_ppa_sources
342 342
343 343 print_ok "Upgrade completed successfully!"
344 - print_ok "System is now AnduinOS 1.4.0 (questing)"
344 + print_ok "System is now AnduinOS 1.4.1 (questing)"
345 345 print_ok "Backups: $BACKUP_DIR"
346 346 print_warn "Please reboot your system."
347 347 }

anduin's Avatar anduin zrewidował ten Gist 2 weeks ago. Przejdź do rewizji

1 file changed, 69 insertions, 145 deletions

do_anduinos_distupgrade.sh

@@ -6,11 +6,9 @@
6 6 # This script upgrades AnduinOS from 1.3.7 (plucky)
7 7 # to 1.4.0 (questing).
8 8 #
9 - # Run this script as root.
10 - # or user with privileges.
11 - #
12 - # Example:
13 - # sudo ./do_anduinos_distupgrade.sh
9 + # Usage:
10 + # ./do_anduinos_distupgrade.sh
11 + # (Script will auto-elevate to root/sudo)
14 12 #=================================================
15 13
16 14 set -e
@@ -22,16 +20,18 @@ Red="\033[31m"
22 20 Yellow="\033[33m"
23 21 Blue="\033[36m"
24 22 Font="\033[0m"
25 - GreenBG="\033[42;37m"
26 - RedBG="\033[41;37m"
27 23 OK="${Green}[ OK ]${Font}"
28 24 ERROR="${Red}[FAILED]${Font}"
29 25 WARNING="${Yellow}[ WARN ]${Font}"
30 26
31 - BACKUP_DIR="/tmp/anduinos_upgrade_backup_$(date +%Y%m%d_%H%M%S)"
27 + # Backup Configuration
28 + BACKUP_ROOT="/var/backups/anduinos-upgrade"
29 + BACKUP_DIR="$BACKUP_ROOT/backup_$(date +%Y%m%d_%H%M%S)"
32 30 PPA_BACKUP_DIR="$BACKUP_DIR/ppa"
33 31 UBUNTU_SOURCE_BACKUP="$BACKUP_DIR/ubuntu_sources"
34 32
33 + # --- Helper Functions ---
34 +
35 35 function print_ok() {
36 36 echo -e "${OK} ${Blue} $1 ${Font}"
37 37 }
@@ -44,6 +44,29 @@ function print_warn() {
44 44 echo -e "${WARNING} ${Yellow} $1 ${Font}"
45 45 }
46 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 +
47 70 function rollback_on_error() {
48 71 print_error "An error occurred during the upgrade process"
49 72 print_warn "Starting rollback procedure..."
@@ -65,7 +88,6 @@ function rollback_on_error() {
65 88 # Restore PPA sources
66 89 if [ -d "$PPA_BACKUP_DIR" ]; then
67 90 ppa_count=$(ls -1 "$PPA_BACKUP_DIR" 2>/dev/null | wc -l)
68 -
69 91 if [ "$ppa_count" -gt 0 ]; then
70 92 print_ok "Restoring PPA sources..."
71 93 for file in "$PPA_BACKUP_DIR"/*; do
@@ -80,18 +102,13 @@ function rollback_on_error() {
80 102 # Remove temporary apt configuration if exists
81 103 if [ -f "/etc/apt/apt.conf.d/99-local-versions" ]; then
82 104 rm -f /etc/apt/apt.conf.d/99-local-versions
83 - print_ok "Removed temporary apt configuration"
84 105 fi
85 106
86 - # Run apt update to restore repository state
87 107 print_ok "Running apt update to restore repository state..."
88 108 apt update || true
89 109
90 - print_warn "Rollback completed"
91 - print_warn "Your system has been restored to the previous state"
92 - print_warn "Backup files are preserved in: $BACKUP_DIR"
93 - print_error "Please check the error messages above and try again"
94 -
110 + print_warn "Rollback completed. System restored to previous state."
111 + print_warn "Backup preserved in: $BACKUP_DIR"
95 112 exit 1
96 113 }
97 114
@@ -108,25 +125,14 @@ function judge() {
108 125 function check_disk_space() {
109 126 print_ok "Checking available disk space..."
110 127
111 - # Get available space in /tmp (in KB)
112 - local tmp_space=$(df /tmp | awk 'NR==2 {print $4}')
113 - # Get available space in / (in KB)
114 - local root_space=$(df / | awk 'NR==2 {print $4}')
128 + mkdir -p "$BACKUP_DIR"
115 129
116 - # Convert to MB
117 - local tmp_space_mb=$((tmp_space / 1024))
130 + local root_space=$(df / | awk 'NR==2 {print $4}')
118 131 local root_space_mb=$((root_space / 1024))
119 -
120 - # Required space: 2GB = 2048MB
121 132 local required_space=2048
122 133
123 - print_ok "Available space in /tmp: ${tmp_space_mb}MB"
124 134 print_ok "Available space in /: ${root_space_mb}MB"
125 -
126 - if [ "$tmp_space_mb" -lt "$required_space" ]; then
127 - print_error "Insufficient disk space in /tmp. Required: ${required_space}MB, Available: ${tmp_space_mb}MB"
128 - exit 1
129 - fi
135 + print_ok "Backup location: $BACKUP_DIR"
130 136
131 137 if [ "$root_space_mb" -lt "$required_space" ]; then
132 138 print_error "Insufficient disk space in /. Required: ${required_space}MB, Available: ${root_space_mb}MB"
@@ -146,30 +152,24 @@ function update_system() {
146 152
147 153 function backup_ubuntu_sources() {
148 154 print_ok "Backing up Ubuntu official sources..."
149 -
150 155 mkdir -p "$UBUNTU_SOURCE_BACKUP"
151 156
152 - # Backup ubuntu.sources if exists
153 157 if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
154 158 cp /etc/apt/sources.list.d/ubuntu.sources "$UBUNTU_SOURCE_BACKUP/"
155 159 print_ok "Backed up ubuntu.sources"
156 160 fi
157 161
158 - # Backup sources.list if it exists and is not empty
159 162 if [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
160 163 cp /etc/apt/sources.list "$UBUNTU_SOURCE_BACKUP/"
161 164 print_ok "Backed up sources.list"
162 165 fi
163 -
164 166 judge "Backup Ubuntu sources"
165 167 }
166 168
167 169 function backup_and_remove_ppa() {
168 170 print_ok "Backing up and temporarily removing PPA sources..."
169 -
170 171 mkdir -p "$PPA_BACKUP_DIR"
171 172
172 - # Move all files in /etc/apt/sources.list.d/ except ubuntu.sources
173 173 if [ -d "/etc/apt/sources.list.d" ]; then
174 174 for file in /etc/apt/sources.list.d/*; do
175 175 if [ -f "$file" ] && [ "$(basename "$file")" != "ubuntu.sources" ]; then
@@ -178,16 +178,13 @@ function backup_and_remove_ppa() {
178 178 fi
179 179 done
180 180 fi
181 -
182 - print_ok "PPA sources moved to: $PPA_BACKUP_DIR"
183 181 judge "Backup and remove PPA sources"
184 182 }
185 183
186 184 function detect_apt_format() {
187 185 print_ok "Detecting APT source format..."
188 -
189 186 if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
190 - print_ok "Detected new DEB822 format (ubuntu.sources)"
187 + print_ok "Detected new DEB822 format"
191 188 return 0
192 189 elif [ -f "/etc/apt/sources.list" ] && [ -s "/etc/apt/sources.list" ]; then
193 190 print_ok "Detected old format (sources.list)"
@@ -201,31 +198,14 @@ function detect_apt_format() {
201 198 function convert_old_to_new_format() {
202 199 print_ok "Converting old format to new DEB822 format..."
203 200
204 - if [ ! -f "/etc/apt/sources.list" ] || [ ! -s "/etc/apt/sources.list" ]; then
205 - print_error "/etc/apt/sources.list not found or empty"
206 - rollback_on_error
207 - fi
208 -
209 - # Backup the old sources.list
210 201 cp /etc/apt/sources.list /etc/apt/sources.list.backup
211 202
212 - # Extract mirror URLs from existing sources.list
213 - # Try to detect main archive mirror
214 203 MIRROR_URL=$(grep -E "^deb " /etc/apt/sources.list | grep -v "security" | head -1 | awk '{print $2}')
215 - if [ -z "$MIRROR_URL" ]; then
216 - MIRROR_URL="http://archive.ubuntu.com/ubuntu/"
217 - fi
204 + [ -z "$MIRROR_URL" ] && MIRROR_URL="http://archive.ubuntu.com/ubuntu/"
218 205
219 - # Try to detect security mirror
220 206 SECURITY_URL=$(grep -E "^deb " /etc/apt/sources.list | grep "security" | head -1 | awk '{print $2}')
221 - if [ -z "$SECURITY_URL" ]; then
222 - SECURITY_URL="http://security.ubuntu.com/ubuntu/"
223 - fi
207 + [ -z "$SECURITY_URL" ] && SECURITY_URL="http://security.ubuntu.com/ubuntu/"
224 208
225 - print_ok "Detected mirror URL: $MIRROR_URL"
226 - print_ok "Detected security URL: $SECURITY_URL"
227 -
228 - # Create new ubuntu.sources file using detected mirrors
229 209 bash -c "cat > /etc/apt/sources.list.d/ubuntu.sources" <<EOF
230 210 Types: deb
231 211 URIs: ${MIRROR_URL}
@@ -240,46 +220,34 @@ Components: main restricted universe multiverse
240 220 Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
241 221 EOF
242 222
243 - # Clear the old sources.list
244 223 bash -c 'echo "# This file is deprecated. See /etc/apt/sources.list.d/ubuntu.sources" > /etc/apt/sources.list'
245 -
246 224 judge "Convert to new format"
247 225 }
248 226
249 227 function replace_plucky_with_questing() {
250 - print_ok "Replacing plucky with questing in ubuntu.sources..."
251 -
252 - if [ ! -f "/etc/apt/sources.list.d/ubuntu.sources" ]; then
253 - print_error "/etc/apt/sources.list.d/ubuntu.sources not found"
254 - rollback_on_error
255 - fi
256 -
228 + print_ok "Replacing plucky with questing..."
257 229 sed -i 's/plucky/questing/g' /etc/apt/sources.list.d/ubuntu.sources
258 230 judge "Replace plucky with questing"
259 231
260 - print_ok "Running apt update with questing repositories..."
232 + print_ok "Updating package lists..."
261 233 apt update
262 234 judge "apt update with questing"
263 235 }
264 236
265 237 function install_coreutils_uutils() {
266 238 print_ok "Installing coreutils-from-uutils..."
267 -
268 239 apt install -y coreutils-from-uutils
269 240 judge "Install coreutils-from-uutils"
270 241 }
271 242
272 243 function run_dist_upgrade() {
273 - print_ok "Simulating apt dist-upgrade first..."
274 - apt -s dist-upgrade
275 - judge "apt -s dist-upgrade"
244 + print_ok "Simulating upgrade..."
245 + apt -s dist-upgrade > /dev/null
246 + judge "apt simulation"
276 247
277 - print_ok "Running apt dist-upgrade in non-interactive mode..."
278 -
279 - # Set environment for non-interactive mode
248 + print_ok "Running full distribution upgrade..."
280 249 export DEBIAN_FRONTEND=noninteractive
281 250
282 - # Configure dpkg to keep local versions by default
283 251 bash -c 'cat > /etc/apt/apt.conf.d/99-local-versions <<EOF
284 252 Dpkg::Options {
285 253 "--force-confdef";
@@ -287,26 +255,20 @@ Dpkg::Options {
287 255 }
288 256 EOF'
289 257
290 - # Run dist-upgrade
291 258 bash -c 'DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none \
292 259 apt-get -y dist-upgrade \
293 260 -o Dpkg::Options::="--force-confdef" \
294 261 -o Dpkg::Options::="--force-confold"'
295 262
296 263 judge "apt dist-upgrade"
297 -
298 - # Remove temporary configuration
299 264 rm -f /etc/apt/apt.conf.d/99-local-versions
300 -
301 265 unset DEBIAN_FRONTEND
302 266 }
303 267
304 268 function update_release_files() {
305 - print_ok "Updating release information files..."
269 + print_ok "Updating release info..."
306 270
307 - # Update /etc/os-release
308 271 if [ -f "/etc/os-release" ]; then
309 - print_ok "Updating /etc/os-release..."
310 272 bash -c "cat > /etc/os-release" <<EOF
311 273 PRETTY_NAME="AnduinOS 1.4.0"
312 274 NAME="AnduinOS"
@@ -321,105 +283,67 @@ BUG_REPORT_URL="https://github.com/Anduin2017/AnduinOS/issues"
321 283 PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
322 284 UBUNTU_CODENAME=questing
323 285 EOF
324 -
325 - judge "Update /etc/os-release"
326 286 fi
327 287
328 - # Update /etc/lsb-release
329 288 if [ -f "/etc/lsb-release" ]; then
330 - print_ok "Updating /etc/lsb-release..."
331 -
332 289 bash -c "cat > /etc/lsb-release" <<EOF
333 290 DISTRIB_ID=AnduinOS
334 291 DISTRIB_RELEASE=1.4.0
335 292 DISTRIB_CODENAME=questing
336 293 DISTRIB_DESCRIPTION="AnduinOS 1.4.0"
337 294 EOF
338 -
339 - judge "Update /etc/lsb-release"
340 295 fi
341 -
342 - print_ok "Release files updated successfully"
296 + judge "Update release files"
343 297 }
344 298
345 299 function restore_ppa_sources() {
346 300 print_ok "Restoring PPA sources..."
347 -
348 - if [ -d "$PPA_BACKUP_DIR" ]; then
349 - ppa_count=$(ls -1 "$PPA_BACKUP_DIR" 2>/dev/null | wc -l)
350 -
351 - if [ "$ppa_count" -gt 0 ]; then
352 - for file in "$PPA_BACKUP_DIR"/*; do
353 - if [ -f "$file" ]; then
354 - mv "$file" /etc/apt/sources.list.d/
355 - print_ok "Restored $(basename "$file")"
356 - fi
357 - done
358 -
359 - print_ok "Running apt update with restored PPAs..."
360 - apt update
361 - judge "Restore PPA sources and update"
362 - else
363 - print_ok "No PPA sources to restore"
364 - fi
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"
365 306 else
366 - print_warn "PPA backup directory not found, skipping restore"
307 + print_ok "No PPA sources to restore"
367 308 fi
368 309 }
369 310
370 311 function main() {
312 + # 1. Ensure we are root first
313 + ensure_root
314 +
371 315 print_ok "Starting AnduinOS upgrade process..."
372 -
373 - echo -e "${Yellow}WARNING: This script will upgrade your system from 1.3.7 (plucky) to 1.4.0 (questing).${Font}"
374 - echo -e "${Yellow}Please ensure you have backed up important data before proceeding.${Font}"
375 - read -p "Do you want to continue? (y/N): " confirm
376 - if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
377 - print_error "Upgrade process aborted by user."
378 - exit 1
379 - fi
380 -
381 - # Check if running as root
382 - if [[ "$(id -u)" -ne 0 ]]; then
383 - print_error "This script must be run as root."
384 - exit 1
316 + echo -e "${Yellow}WARNING: Upgrading from 1.3.7 (plucky) to 1.4.0 (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
385 326 fi
386 327
387 - # Step 0: Check disk space
388 328 check_disk_space
389 -
390 - # Step 1: Update current system
391 329 update_system
392 -
393 - # Step 2: Backup Ubuntu official sources
394 330 backup_ubuntu_sources
395 -
396 - # Step 3: Backup and remove PPA sources
397 331 backup_and_remove_ppa
398 332
399 - # Step 4: Detect and convert APT format if needed
400 333 if ! detect_apt_format; then
401 334 convert_old_to_new_format
402 335 fi
403 336
404 - # Step 5: Replace plucky with questing
405 337 replace_plucky_with_questing
406 -
407 - # Step 6: Install coreutils-from-uutils
408 338 install_coreutils_uutils
409 -
410 - # Step 7: Run dist-upgrade
411 339 run_dist_upgrade
412 -
413 - # Step 8: Update release files
414 340 update_release_files
415 -
416 - # Step 9: Restore PPA sources
417 341 restore_ppa_sources
418 342
419 343 print_ok "Upgrade completed successfully!"
420 - print_ok "Your system has been upgraded to AnduinOS 1.4.0 (questing)"
421 - print_ok "Backup files are stored in: $BACKUP_DIR"
422 - print_warn "Please reboot your system to complete the upgrade."
344 + print_ok "System is now AnduinOS 1.4.0 (questing)"
345 + print_ok "Backups: $BACKUP_DIR"
346 + print_warn "Please reboot your system."
423 347 }
424 348
425 349 main

ZeTian zrewidował ten Gist 3 weeks ago. Przejdź do rewizji

1 file changed, 1 insertion, 2 deletions

do_anduinos_distupgrade.sh

@@ -422,5 +422,4 @@ function main() {
422 422 print_warn "Please reboot your system to complete the upgrade."
423 423 }
424 424
425 - # main
426 - update_release_files
425 + main

ZeTian zrewidował ten Gist 3 weeks ago. Przejdź do rewizji

1 file changed, 25 insertions, 10 deletions

do_anduinos_distupgrade.sh

@@ -307,21 +307,35 @@ function update_release_files() {
307 307 # Update /etc/os-release
308 308 if [ -f "/etc/os-release" ]; then
309 309 print_ok "Updating /etc/os-release..."
310 - sed -i 's/UBUNTU_CODENAME=plucky/UBUNTU_CODENAME=questing/g' /etc/os-release
311 - sed -i 's/VERSION_CODENAME=plucky/VERSION_CODENAME=questing/g' /etc/os-release
312 - sed -i 's/VERSION_ID="1\.3\.7"/VERSION_ID="1.4.0"/g' /etc/os-release
313 - sed -i 's/VERSION="1\.3\.7 (plucky)"/VERSION="1.4.0 (questing)"/g' /etc/os-release
314 - sed -i 's/PRETTY_NAME="AnduinOS 1\.3\.7"/PRETTY_NAME="AnduinOS 1.4.0"/g' /etc/os-release
315 - sed -i 's/PRETTY_NAME="AnduinOS 1\.3\.7"/PRETTY_NAME="AnduinOS 1.4.0"/g' /etc/os-release
310 + bash -c "cat > /etc/os-release" <<EOF
311 + PRETTY_NAME="AnduinOS 1.4.0"
312 + NAME="AnduinOS"
313 + VERSION_ID="1.4.0"
314 + VERSION="1.4.0 (questing)"
315 + VERSION_CODENAME=questing
316 + ID=ubuntu
317 + ID_LIKE=debian
318 + HOME_URL="https://www.anduinos.com/"
319 + SUPPORT_URL="https://github.com/Anduin2017/AnduinOS/discussions"
320 + BUG_REPORT_URL="https://github.com/Anduin2017/AnduinOS/issues"
321 + PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
322 + UBUNTU_CODENAME=questing
323 + EOF
324 +
316 325 judge "Update /etc/os-release"
317 326 fi
318 327
319 328 # Update /etc/lsb-release
320 329 if [ -f "/etc/lsb-release" ]; then
321 330 print_ok "Updating /etc/lsb-release..."
322 - sed -i 's/DISTRIB_RELEASE=1\.3\.7/DISTRIB_RELEASE=1.4.0/g' /etc/lsb-release
323 - sed -i 's/DISTRIB_CODENAME=plucky/DISTRIB_CODENAME=questing/g' /etc/lsb-release
324 - sed -i 's/DISTRIB_DESCRIPTION="AnduinOS 1\.3\.7"/DISTRIB_DESCRIPTION="AnduinOS 1.4.0"/g' /etc/lsb-release
331 +
332 + bash -c "cat > /etc/lsb-release" <<EOF
333 + DISTRIB_ID=AnduinOS
334 + DISTRIB_RELEASE=1.4.0
335 + DISTRIB_CODENAME=questing
336 + DISTRIB_DESCRIPTION="AnduinOS 1.4.0"
337 + EOF
338 +
325 339 judge "Update /etc/lsb-release"
326 340 fi
327 341
@@ -408,4 +422,5 @@ function main() {
408 422 print_warn "Please reboot your system to complete the upgrade."
409 423 }
410 424
411 - main
425 + # main
426 + update_release_files
Nowsze Starsze