ubuntu_to_aos.sh
· 9.9 KiB · Bash
Raw
#!/bin/bash
#==========================
# Set up the environment
#==========================
set -e # exit on error
set -o pipefail # exit on pipeline error
set -u # treat unset variable as error
#==========================
# Color
#==========================
Green="\033[32m"
Red="\033[31m"
Yellow="\033[33m"
Blue="\033[36m"
Font="\033[0m"
GreenBG="\033[42;37m"
RedBG="\033[41;37m"
OK="${Green}[ OK ]${Font}"
ERROR="${Red}[FAILED]${Font}"
WARNING="${Yellow}[ WARN ]${Font}"
#==========================
# Print Colorful Text
#==========================
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}"
}
#==========================
# Judge function
#==========================
function judge() {
if [[ 0 -eq $? ]]; then
print_ok "$1 succeeded"
sleep 0.2
else
print_error "$1 failed"
exit 1
fi
}
#==========================
# Clean up function
#==========================
function clean_up() {
# Clean up
print_ok "Cleaning up old files..."
sudo umount /mnt/anduinos_squashfs >/dev/null 2>&1 || true
sudo umount /mnt/anduinos_iso >/dev/null 2>&1 || true
sudo rm -rf /mnt/anduinos_squashfs >/dev/null 2>&1 || true
sudo rm -rf /mnt/anduinos_iso >/dev/null 2>&1 || true
sudo rm /tmp/AnduinOS-1.4.0* >/dev/null 2>&1 || true
judge "Cleanup"
}
clean_up
print_ok "Checking system compatibility..."
codename=$(lsb_release -cs)
if [[ "$codename" != "questing" ]] then
print_error "This upgrade script can only be run *from* AnduinOS Questing."
exit 1
fi
judge "System compatibility check"
print_ok "Installing required packages (aria2, curl, lsb-release)..."
sudo apt install -y aria2 curl lsb-release
judge "Install required packages"
# $LANG maybe en_US.UTF-8, so we use only the `en_US` part
CURRENT_LANG=${LANG%%.*}
DOWNLOAD_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-${CURRENT_LANG}.torrent"
HASH_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-${CURRENT_LANG}.sha256"
print_ok "Current system language detected: ${CURRENT_LANG}"
print_ok "Attempting to download with URL: ${DOWNLOAD_URL}"
# If download URL is not reachable, fallback to en_US
if ! curl --head --silent --fail "$DOWNLOAD_URL" >/dev/null; then
print_warn "Language pack for ${CURRENT_LANG} not found, falling back to en_US"
DOWNLOAD_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-en_US.torrent"
HASH_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-en_US.sha256"
fi
# Ensure download URL is reachable
if ! curl --head --silent --fail "$DOWNLOAD_URL" >/dev/null; then
print_error "Download URL is not reachable. Please check your network connection."
exit 1
fi
print_ok "Downloading AnduinOS 1.4.0 torrent, please wait..."
curl -o /tmp/AnduinOS-1.4.0.torrent "$DOWNLOAD_URL"
curl -o /tmp/AnduinOS-1.4.0.sha256 "$HASH_URL"
judge "Download AnduinOS 1.4.0 torrent"
print_ok "Starting download via aria2..."
aria2c --allow-overwrite=true --seed-ratio=0.0 --seed-time=0 -x 16 -s 16 -k 1M -d /tmp /tmp/AnduinOS-1.4.0.torrent
judge "Download AnduinOS 1.4.0 ISO"
ISO_FILE_PATH=$(ls /tmp/AnduinOS-1.4.0*.iso | head -n 1)
print_ok "Ensure downloaded ISO file exists..."
if [[ -f "$ISO_FILE_PATH" ]]; then
print_ok "Downloaded ISO file found: $ISO_FILE_PATH"
else
print_error "Downloaded ISO file not found."
exit 1
fi
SHA256_FILE_PATH="/tmp/AnduinOS-1.4.0.sha256"
print_ok "Verifying download integrity..."
ACTUAL_SHA256=$(sha256sum "$ISO_FILE_PATH" | awk '{print $1}')
EXPECTED_SHA256=$(grep 'SHA256:' "$SHA256_FILE_PATH" | awk '{print $2}')
if [[ "$ACTUAL_SHA256" == "$EXPECTED_SHA256" ]]; then
print_ok "SHA256 checksum verification passed."
else
print_ok "Expected SHA256: $EXPECTED_SHA256"
print_ok "Actual SHA256: $ACTUAL_SHA256"
print_error "SHA256 checksum verification failed. The downloaded file may be corrupted."
exit 1
fi
print_ok "Mounting the ISO..."
sudo mkdir -p /mnt/anduinos_iso
sudo mount -o loop,ro "$ISO_FILE_PATH" /mnt/anduinos_iso
judge "Mount ISO"
print_ok "Verifying content in the ISO..."
(cd /mnt/anduinos_iso && sudo md5sum -c md5sum.txt)
judge "ISO content integrity verification"
print_ok "Mounting the filesystem.squashfs..."
sudo mkdir -p /mnt/anduinos_squashfs
sudo mount -o loop,ro /mnt/anduinos_iso/casper/filesystem.squashfs /mnt/anduinos_squashfs
judge "Mount filesystem.squashfs"
print_ok "Updating package mirrors..."
curl -s https://gitlab.aiursoft.cn/anduin/init-server/-/raw/master/mirror.sh?ref_type=heads | bash
sudo apt update
judge "Update package mirrors"
# Reset apt settings
print_ok "Resetting APT configuration files..."
sudo rm /etc/apt/preferences.d/* >/dev/null 2>&1 || true
judge "Reset APT configuration files"
# Add Mozilla Team PPA
print_ok "Updating Mozilla Team PPA..."
sudo rm -f /etc/apt/sources.list.d/mozillateam*
sudo rsync -Aax /mnt/anduinos_squashfs/etc/apt/sources.list.d/mozillateam* /etc/apt/sources.list.d/
judge "Update Mozilla Team PPA"
# Install missing package.
print_ok "Installing missing packages from the new release..."
MANIFEST_FILE="/mnt/anduinos_iso/casper/filesystem.manifest-desktop"
cut -d' ' -f1 "$MANIFEST_FILE" \
| grep -v '^linux-' \
| grep -v '^lib' \
| grep -v '^plymouth-' \
| grep -v '^software-properties-' \
| xargs sudo apt install -y # <-- 让 xargs 自己调用 apt
judge "Install missing packages"
# Remove obsolete packages.
print_ok "Removing obsolete packages..."
sudo apt autoremove -y \
distro-info \
software-properties-gtk \
ubuntu-advantage-tools \
ubuntu-pro-client \
ubuntu-pro-client-l10n \
ubuntu-release-upgrader-gtk \
ubuntu-report \
ubuntu-settings \
update-notifier-common \
update-manager \
update-manager-core \
update-notifier \
ubuntu-release-upgrader-core \
ubuntu-advantage-desktop-daemon \
kgx
judge "Remove obsolete packages"
print_ok "Upgrading installed packages..."
sudo apt upgrade -y
sudo apt autoremove --purge -y
judge "System package cleanup"
print_ok "Upgrading GNOME Shell extensions..."
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/gnome-shell/extensions/ /usr/share/gnome-shell/extensions/
judge "Upgrade GNOME Shell extensions"
print_ok "Upgrading icon and theme files..."
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/icons/ /usr/share/icons/
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/themes/ /usr/share/themes/
judge "Upgrade icon and theme files"
print_ok "Upgrading desktop backgrounds..."
sudo rsync -Aax --update /mnt/anduinos_squashfs/usr/share/backgrounds/ /usr/share/backgrounds/
sudo rsync -Aax --update /mnt/anduinos_squashfs/usr/share/gnome-background-properties/ /usr/share/gnome-background-properties/
judge "Upgrade desktop backgrounds"
print_ok "Upgrading APT configuration files..."
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/etc/apt/apt.conf.d/ /etc/apt/apt.conf.d/
judge "Upgrade APT configuration files"
print_ok "Upgrading APT preferences files..."
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/etc/apt/preferences.d/ /etc/apt/preferences.d/
judge "Upgrade APT preferences files"
print_ok "Upgrading session files..."
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/gnome-session/sessions/ /usr/share/gnome-session/sessions/
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/wayland-sessions/ /usr/share/wayland-sessions/
judge "Upgrade session files"
print_ok "Upgrading pixmaps..."
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/pixmaps/ /usr/share/pixmaps/
judge "Upgrade pixmaps"
print_ok "Upgrading python-apt templates and distro info..."
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/python-apt/templates/ /usr/share/python-apt/templates/
sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/distro-info/ /usr/share/distro-info/
judge "Upgrade python-apt templates and distro info"
print_ok "Upgrading deskmon service..."
sudo rsync -Aax /mnt/anduinos_squashfs/usr/local/bin/deskmon /usr/local/bin/deskmon
sudo rsync -Aax /mnt/anduinos_squashfs/etc/systemd/user/deskmon.service /etc/systemd/user/deskmon.service
sudo rsync -Aax /mnt/anduinos_squashfs/etc/systemd/user/default.target.wants/deskmon.service /etc/systemd/user/default.target.wants/deskmon.service
judge "Upgrade deskmon service"
print_ok "Updating system version information..."
sudo rsync -Aax /mnt/anduinos_squashfs/usr/local/bin/do_anduinos_upgrade /usr/local/bin/do_anduinos_upgrade
sudo rsync -Aax /mnt/anduinos_squashfs/usr/bin/add-apt-repository /usr/bin/add-apt-repository
sudo rsync -Aax /mnt/anduinos_squashfs/etc/lsb-release /etc/lsb-release
sudo rsync -Aax /mnt/anduinos_squashfs/etc/issue /etc/issue
sudo rsync -Aax /mnt/anduinos_squashfs/etc/issue.net /etc/issue.net
sudo rsync -Aax /mnt/anduinos_squashfs/etc/os-release /etc/os-release
sudo rsync -Aax /mnt/anduinos_squashfs/usr/lib/os-release /usr/lib/os-release
sudo rsync -Aax /mnt/anduinos_squashfs/etc/legal /etc/legal
sudo rsync -Aax /mnt/anduinos_squashfs/etc/sysctl.d/20-apparmor-donotrestrict.conf /etc/sysctl.d/20-apparmor-donotrestrict.conf
judge "Update system version information"
print_ok "Applying dconf settings patch..."
VERSION=$(grep -oP "VERSION_ID=\"\\K\\d+\\.\\d+" /etc/os-release)
PATCH_URL="https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/$VERSION/src/mods/35-dconf-patch/dconf.ini?ref_type=heads"
COMMAND_TO_RUN="set -o pipefail; curl -sL '$PATCH_URL' | dconf load /org/gnome/"
if [[ -n "${SUDO_USER-}" ]]; then
print_ok "Applying dconf patch for user: $SUDO_USER"
sudo -u "$SUDO_USER" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u $SUDO_USER)/bus" \
bash -c "$COMMAND_TO_RUN"
else
print_warn "Running as root without sudo context. Skipping user dconf patch."
true
fi
judge "Apply dconf settings patch"
print_ok "Upgrade completed! Please reboot your system to apply all changes."
print_ok "Starting cleanup..."
clean_up
| 1 | #!/bin/bash |
| 2 | #========================== |
| 3 | # Set up the environment |
| 4 | #========================== |
| 5 | set -e # exit on error |
| 6 | set -o pipefail # exit on pipeline error |
| 7 | set -u # treat unset variable as error |
| 8 | |
| 9 | #========================== |
| 10 | # Color |
| 11 | #========================== |
| 12 | Green="\033[32m" |
| 13 | Red="\033[31m" |
| 14 | Yellow="\033[33m" |
| 15 | Blue="\033[36m" |
| 16 | Font="\033[0m" |
| 17 | GreenBG="\033[42;37m" |
| 18 | RedBG="\033[41;37m" |
| 19 | OK="${Green}[ OK ]${Font}" |
| 20 | ERROR="${Red}[FAILED]${Font}" |
| 21 | WARNING="${Yellow}[ WARN ]${Font}" |
| 22 | |
| 23 | #========================== |
| 24 | # Print Colorful Text |
| 25 | #========================== |
| 26 | function print_ok() { |
| 27 | echo -e "${OK} ${Blue} $1 ${Font}" |
| 28 | } |
| 29 | |
| 30 | function print_error() { |
| 31 | echo -e "${ERROR} ${Red} $1 ${Font}" |
| 32 | } |
| 33 | |
| 34 | function print_warn() { |
| 35 | echo -e "${WARNING} ${Yellow} $1 ${Font}" |
| 36 | } |
| 37 | |
| 38 | #========================== |
| 39 | # Judge function |
| 40 | #========================== |
| 41 | function judge() { |
| 42 | if [[ 0 -eq $? ]]; then |
| 43 | print_ok "$1 succeeded" |
| 44 | sleep 0.2 |
| 45 | else |
| 46 | print_error "$1 failed" |
| 47 | exit 1 |
| 48 | fi |
| 49 | } |
| 50 | #========================== |
| 51 | |
| 52 | # Clean up function |
| 53 | #========================== |
| 54 | function clean_up() { |
| 55 | # Clean up |
| 56 | print_ok "Cleaning up old files..." |
| 57 | sudo umount /mnt/anduinos_squashfs >/dev/null 2>&1 || true |
| 58 | sudo umount /mnt/anduinos_iso >/dev/null 2>&1 || true |
| 59 | sudo rm -rf /mnt/anduinos_squashfs >/dev/null 2>&1 || true |
| 60 | sudo rm -rf /mnt/anduinos_iso >/dev/null 2>&1 || true |
| 61 | sudo rm /tmp/AnduinOS-1.4.0* >/dev/null 2>&1 || true |
| 62 | judge "Cleanup" |
| 63 | } |
| 64 | |
| 65 | clean_up |
| 66 | |
| 67 | print_ok "Checking system compatibility..." |
| 68 | codename=$(lsb_release -cs) |
| 69 | if [[ "$codename" != "questing" ]] then |
| 70 | print_error "This upgrade script can only be run *from* AnduinOS Questing." |
| 71 | exit 1 |
| 72 | fi |
| 73 | judge "System compatibility check" |
| 74 | |
| 75 | print_ok "Installing required packages (aria2, curl, lsb-release)..." |
| 76 | sudo apt install -y aria2 curl lsb-release |
| 77 | judge "Install required packages" |
| 78 | |
| 79 | # $LANG maybe en_US.UTF-8, so we use only the `en_US` part |
| 80 | CURRENT_LANG=${LANG%%.*} |
| 81 | DOWNLOAD_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-${CURRENT_LANG}.torrent" |
| 82 | HASH_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-${CURRENT_LANG}.sha256" |
| 83 | |
| 84 | print_ok "Current system language detected: ${CURRENT_LANG}" |
| 85 | print_ok "Attempting to download with URL: ${DOWNLOAD_URL}" |
| 86 | |
| 87 | # If download URL is not reachable, fallback to en_US |
| 88 | if ! curl --head --silent --fail "$DOWNLOAD_URL" >/dev/null; then |
| 89 | print_warn "Language pack for ${CURRENT_LANG} not found, falling back to en_US" |
| 90 | DOWNLOAD_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-en_US.torrent" |
| 91 | HASH_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-en_US.sha256" |
| 92 | fi |
| 93 | |
| 94 | # Ensure download URL is reachable |
| 95 | if ! curl --head --silent --fail "$DOWNLOAD_URL" >/dev/null; then |
| 96 | print_error "Download URL is not reachable. Please check your network connection." |
| 97 | exit 1 |
| 98 | fi |
| 99 | |
| 100 | print_ok "Downloading AnduinOS 1.4.0 torrent, please wait..." |
| 101 | curl -o /tmp/AnduinOS-1.4.0.torrent "$DOWNLOAD_URL" |
| 102 | curl -o /tmp/AnduinOS-1.4.0.sha256 "$HASH_URL" |
| 103 | judge "Download AnduinOS 1.4.0 torrent" |
| 104 | |
| 105 | print_ok "Starting download via aria2..." |
| 106 | aria2c --allow-overwrite=true --seed-ratio=0.0 --seed-time=0 -x 16 -s 16 -k 1M -d /tmp /tmp/AnduinOS-1.4.0.torrent |
| 107 | judge "Download AnduinOS 1.4.0 ISO" |
| 108 | |
| 109 | ISO_FILE_PATH=$(ls /tmp/AnduinOS-1.4.0*.iso | head -n 1) |
| 110 | print_ok "Ensure downloaded ISO file exists..." |
| 111 | if [[ -f "$ISO_FILE_PATH" ]]; then |
| 112 | print_ok "Downloaded ISO file found: $ISO_FILE_PATH" |
| 113 | else |
| 114 | print_error "Downloaded ISO file not found." |
| 115 | exit 1 |
| 116 | fi |
| 117 | |
| 118 | SHA256_FILE_PATH="/tmp/AnduinOS-1.4.0.sha256" |
| 119 | |
| 120 | print_ok "Verifying download integrity..." |
| 121 | ACTUAL_SHA256=$(sha256sum "$ISO_FILE_PATH" | awk '{print $1}') |
| 122 | EXPECTED_SHA256=$(grep 'SHA256:' "$SHA256_FILE_PATH" | awk '{print $2}') |
| 123 | if [[ "$ACTUAL_SHA256" == "$EXPECTED_SHA256" ]]; then |
| 124 | print_ok "SHA256 checksum verification passed." |
| 125 | else |
| 126 | print_ok "Expected SHA256: $EXPECTED_SHA256" |
| 127 | print_ok "Actual SHA256: $ACTUAL_SHA256" |
| 128 | print_error "SHA256 checksum verification failed. The downloaded file may be corrupted." |
| 129 | exit 1 |
| 130 | fi |
| 131 | |
| 132 | print_ok "Mounting the ISO..." |
| 133 | sudo mkdir -p /mnt/anduinos_iso |
| 134 | sudo mount -o loop,ro "$ISO_FILE_PATH" /mnt/anduinos_iso |
| 135 | judge "Mount ISO" |
| 136 | |
| 137 | print_ok "Verifying content in the ISO..." |
| 138 | (cd /mnt/anduinos_iso && sudo md5sum -c md5sum.txt) |
| 139 | judge "ISO content integrity verification" |
| 140 | |
| 141 | print_ok "Mounting the filesystem.squashfs..." |
| 142 | sudo mkdir -p /mnt/anduinos_squashfs |
| 143 | sudo mount -o loop,ro /mnt/anduinos_iso/casper/filesystem.squashfs /mnt/anduinos_squashfs |
| 144 | judge "Mount filesystem.squashfs" |
| 145 | |
| 146 | print_ok "Updating package mirrors..." |
| 147 | curl -s https://gitlab.aiursoft.cn/anduin/init-server/-/raw/master/mirror.sh?ref_type=heads | bash |
| 148 | sudo apt update |
| 149 | judge "Update package mirrors" |
| 150 | |
| 151 | # Reset apt settings |
| 152 | print_ok "Resetting APT configuration files..." |
| 153 | sudo rm /etc/apt/preferences.d/* >/dev/null 2>&1 || true |
| 154 | judge "Reset APT configuration files" |
| 155 | |
| 156 | # Add Mozilla Team PPA |
| 157 | print_ok "Updating Mozilla Team PPA..." |
| 158 | sudo rm -f /etc/apt/sources.list.d/mozillateam* |
| 159 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/apt/sources.list.d/mozillateam* /etc/apt/sources.list.d/ |
| 160 | judge "Update Mozilla Team PPA" |
| 161 | |
| 162 | # Install missing package. |
| 163 | print_ok "Installing missing packages from the new release..." |
| 164 | MANIFEST_FILE="/mnt/anduinos_iso/casper/filesystem.manifest-desktop" |
| 165 | cut -d' ' -f1 "$MANIFEST_FILE" \ |
| 166 | | grep -v '^linux-' \ |
| 167 | | grep -v '^lib' \ |
| 168 | | grep -v '^plymouth-' \ |
| 169 | | grep -v '^software-properties-' \ |
| 170 | | xargs sudo apt install -y # <-- 让 xargs 自己调用 apt |
| 171 | judge "Install missing packages" |
| 172 | |
| 173 | # Remove obsolete packages. |
| 174 | print_ok "Removing obsolete packages..." |
| 175 | sudo apt autoremove -y \ |
| 176 | distro-info \ |
| 177 | software-properties-gtk \ |
| 178 | ubuntu-advantage-tools \ |
| 179 | ubuntu-pro-client \ |
| 180 | ubuntu-pro-client-l10n \ |
| 181 | ubuntu-release-upgrader-gtk \ |
| 182 | ubuntu-report \ |
| 183 | ubuntu-settings \ |
| 184 | update-notifier-common \ |
| 185 | update-manager \ |
| 186 | update-manager-core \ |
| 187 | update-notifier \ |
| 188 | ubuntu-release-upgrader-core \ |
| 189 | ubuntu-advantage-desktop-daemon \ |
| 190 | kgx |
| 191 | judge "Remove obsolete packages" |
| 192 | |
| 193 | print_ok "Upgrading installed packages..." |
| 194 | sudo apt upgrade -y |
| 195 | sudo apt autoremove --purge -y |
| 196 | judge "System package cleanup" |
| 197 | |
| 198 | print_ok "Upgrading GNOME Shell extensions..." |
| 199 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/gnome-shell/extensions/ /usr/share/gnome-shell/extensions/ |
| 200 | judge "Upgrade GNOME Shell extensions" |
| 201 | |
| 202 | print_ok "Upgrading icon and theme files..." |
| 203 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/icons/ /usr/share/icons/ |
| 204 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/themes/ /usr/share/themes/ |
| 205 | judge "Upgrade icon and theme files" |
| 206 | |
| 207 | print_ok "Upgrading desktop backgrounds..." |
| 208 | sudo rsync -Aax --update /mnt/anduinos_squashfs/usr/share/backgrounds/ /usr/share/backgrounds/ |
| 209 | sudo rsync -Aax --update /mnt/anduinos_squashfs/usr/share/gnome-background-properties/ /usr/share/gnome-background-properties/ |
| 210 | judge "Upgrade desktop backgrounds" |
| 211 | |
| 212 | print_ok "Upgrading APT configuration files..." |
| 213 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/etc/apt/apt.conf.d/ /etc/apt/apt.conf.d/ |
| 214 | judge "Upgrade APT configuration files" |
| 215 | |
| 216 | print_ok "Upgrading APT preferences files..." |
| 217 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/etc/apt/preferences.d/ /etc/apt/preferences.d/ |
| 218 | judge "Upgrade APT preferences files" |
| 219 | |
| 220 | print_ok "Upgrading session files..." |
| 221 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/gnome-session/sessions/ /usr/share/gnome-session/sessions/ |
| 222 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/wayland-sessions/ /usr/share/wayland-sessions/ |
| 223 | judge "Upgrade session files" |
| 224 | |
| 225 | print_ok "Upgrading pixmaps..." |
| 226 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/pixmaps/ /usr/share/pixmaps/ |
| 227 | judge "Upgrade pixmaps" |
| 228 | |
| 229 | print_ok "Upgrading python-apt templates and distro info..." |
| 230 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/python-apt/templates/ /usr/share/python-apt/templates/ |
| 231 | sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/distro-info/ /usr/share/distro-info/ |
| 232 | judge "Upgrade python-apt templates and distro info" |
| 233 | |
| 234 | print_ok "Upgrading deskmon service..." |
| 235 | sudo rsync -Aax /mnt/anduinos_squashfs/usr/local/bin/deskmon /usr/local/bin/deskmon |
| 236 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/systemd/user/deskmon.service /etc/systemd/user/deskmon.service |
| 237 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/systemd/user/default.target.wants/deskmon.service /etc/systemd/user/default.target.wants/deskmon.service |
| 238 | judge "Upgrade deskmon service" |
| 239 | |
| 240 | print_ok "Updating system version information..." |
| 241 | sudo rsync -Aax /mnt/anduinos_squashfs/usr/local/bin/do_anduinos_upgrade /usr/local/bin/do_anduinos_upgrade |
| 242 | sudo rsync -Aax /mnt/anduinos_squashfs/usr/bin/add-apt-repository /usr/bin/add-apt-repository |
| 243 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/lsb-release /etc/lsb-release |
| 244 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/issue /etc/issue |
| 245 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/issue.net /etc/issue.net |
| 246 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/os-release /etc/os-release |
| 247 | sudo rsync -Aax /mnt/anduinos_squashfs/usr/lib/os-release /usr/lib/os-release |
| 248 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/legal /etc/legal |
| 249 | sudo rsync -Aax /mnt/anduinos_squashfs/etc/sysctl.d/20-apparmor-donotrestrict.conf /etc/sysctl.d/20-apparmor-donotrestrict.conf |
| 250 | judge "Update system version information" |
| 251 | |
| 252 | print_ok "Applying dconf settings patch..." |
| 253 | VERSION=$(grep -oP "VERSION_ID=\"\\K\\d+\\.\\d+" /etc/os-release) |
| 254 | PATCH_URL="https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/$VERSION/src/mods/35-dconf-patch/dconf.ini?ref_type=heads" |
| 255 | COMMAND_TO_RUN="set -o pipefail; curl -sL '$PATCH_URL' | dconf load /org/gnome/" |
| 256 | if [[ -n "${SUDO_USER-}" ]]; then |
| 257 | print_ok "Applying dconf patch for user: $SUDO_USER" |
| 258 | sudo -u "$SUDO_USER" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u $SUDO_USER)/bus" \ |
| 259 | bash -c "$COMMAND_TO_RUN" |
| 260 | else |
| 261 | print_warn "Running as root without sudo context. Skipping user dconf patch." |
| 262 | true |
| 263 | fi |
| 264 | judge "Apply dconf settings patch" |
| 265 | |
| 266 | print_ok "Upgrade completed! Please reboot your system to apply all changes." |
| 267 | |
| 268 | print_ok "Starting cleanup..." |
| 269 | clean_up |
| 270 |