Gnome Desktop Installation Script for openEuler 24.03-LTS-SP3

Background: The system is openEuler 24.03-LTS-SP3 server version (not Developer Edition), and Standard Installation was selected during installation.

#!/usr/bin/bash

# Switch to Peking University mirror (optional)
sudo bash -c 'sed  -e "s|http://repo.openeuler.org|https://mirrors.pku.edu.cn/openeuler|g" \
          -e "s|https://repo.openeuler.org|https://mirrors.pku.edu.cn/openeuler|g" \
          -e "s|metalink=|#metalink=|g" \
          -i.bak \
          /etc/yum.repos.d/openEuler.repo'

# Install system and basic software
sudo bash -c 'yum -y install gnome-shell gnome-session dnf* nautilus flatpak gedit xchm gnome-terminal vim libusb nm-connection-editor linux-firmware-iwlwifi google*sc* google-noto-{sans,serif,sans-mono}-fonts google-noto-emoji-fonts xorg-x11-drivers xorg-x11-server ffmpeg gvfs xdg-user-dirs-gtk'

# Install GUI software manager (optional)
sudo bash -c 'yum -y install gnome-software gnome-packagekit*'

# Advanced network settings (optional, use nm-connection-editor for configuration)
# sudo yum install network* Network*

# Set boot to graphical mode
sudo systemctl enable gdm
sudo systemctl set-default graphical.target

# Install fcitx5 input method using openEuler 24.09 EPOL repository
## Add 24.09 repository
sudo bash -c 'cat > /etc/yum.repos.d/repo.openEuler24.09-EPOL.repo <<END
[openEuler24.09-EPOL]
name=created by dnf config-manager from https://repo.openeuler.org/openEuler-24.09/EPOL/main/x86_64
baseurl=https://repo.openeuler.org/openEuler-24.09/EPOL/main/x86_64
enabled=1
priority=99
END'

## Refresh repository and install
sudo dnf makecache
sudo dnf -y install fcitx5*

## Remove 24.09 repo and back it up
sudo mv /etc/yum.repos.d/repo.openEuler24.09-EPOL.repo /etc/yum.repos.d/repo.openEuler24.09-EPOL.repo.bak

# Add fcitx5 input method environment variables
sudo bash -c 'cat > /etc/environment << END
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
SDL_IM_MODULE=fcitx
GLFW_IM_MODULE=ibus
END'

# Install oepkgs software repository (manually enabled during installation, disabled by default)
sudo bash -c 'cat > /etc/yum.repos.d/oepkgs-repos.repo <<END
[oepkgs-centos9]
name=oepkgs-centos9
baseurl=https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/centos9/$basearch
enabled=0
gpgcheck=0
priority=100

[oepkgs-contrib-driver]
name=coepkgs-contrib-driver
baseurl=https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/drivers/$basearch
enabled=0
gpgcheck=0
priority=100

[oepkgs-extras]
name=oepkgs-extras
baseurl=https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/extras/$basearch
enabled=0
gpgcheck=0
priority=100

[oepkgs-fedora40]
name=oepkgs-fedora40
baseurl=https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/fedora40/$basearch
enabled=0
gpgcheck=0
priority=100

END'

sudo dnf makecache

# Allow wheel group to auto-mount without password (replace "wheel" with other group if needed)
sudo bash -c 'cat > /etc/polkit-1/rules.d/10-allow-mount.rules <<END
polkit.addRule(function(action, subject) {
    // Match udisks2 mount operations
    if (action.id.match("org.freedesktop.udisks2") && subject.isInGroup("wheel")) {
        return polkit.Result.YES;
    }
});
END'

sudo systemctl restart polkit

# Move files to trash (optional)
# Trash location: ~/.local/share/Trash/, root files go to root's home directory
# sudo yum -y install python3-Send2Trash
# sudo sed "$a alias rm='send2trash'" -i.bak /etc/bashrc

# Print and scan support
sudo yum install sane-* cups*
## Install additional scanning features using oepkgs repo
sudo yum -y --enablerepo=oepkgs* install sane-airscan libsane-airscan
## HP printer manager
sudo dnf -y install hplip-gui

# Enable dnf command auto-completion
sudo yum -y install bash-completion dnf*
cp ~/.bashrc ~/.bashrc.bak.$(date +"%Y-%m-%d_%H-%M-%S")
cat >> ~/.bashrc << END
if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
fi
END

# Add Flatpak repository
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
## Set USTC mirror
sudo flatpak remote-modify flathub --url=https://mirrors.ustc.edu.cn/flathub
# Install extension manager and optimization tools
flatpak install com.mattjakeman.ExtensionManager -y
flatpak install page.tesk.Refine -y

# Install Linglong (Deepin's app container)
## Official Linglong repo has issues; community repo lacks dependencies. Use both, lower priority for official
sudo bash -c 'cat > /etc/yum.repos.d/oepkgs-repos.repo <<END
[linglong_CI_release]
name=linglong:CI:release (openEuler_24.03)
type=rpm-md
baseurl=https://ci.deepin.com/repo/obs/linglong:/CI:/release/openEuler_24.03/
priority=100
gpgcheck=0
enabled=1

[copr:copr.fedorainfracloud.org:mozixun:OpenAtom-Linyaps]
name=Copr repo for OpenAtom-Linyaps owned by mozixun
baseurl=https://download.copr.fedorainfracloud.org/results/mozixun/OpenAtom-Linyaps/openeuler-24.03-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://download.copr.fedorainfracloud.org/results/mozixun/OpenAtom-Linyaps/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1

END'

# Refresh cache
sudo dnf makecache

# Install Linglong
sudo dnf install linglong

# Install 360 Browser
sudo dnf -y install https://gedown.360safe.com/gc/browser360-cn-stable-13.4.1100.108-1.x86_64.rpm

# Install Firefox Browser (optional)
# sudo dnf install firefox

# Add user to audio and video groups (may not be necessary)
sudo usermod -a -G audio $USER
sudo usermod -aG video $USER

# Show weekday and seconds in clock
gsettings set org.gnome.desktop.interface clock-show-weekday true
gsettings set org.gnome.desktop.interface clock-show-seconds true

The initial setup is now complete. Use sudo systemctl start gdm or reboot to restart and enter the graphical interface.