Script rewrite for safety and Fedora 44 prep
This commit is contained in:
1 parent
fc41d02316
commit
616039ef45
1 file changed
+178
-61
+178
-61
@@ -1,87 +1,204 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Fedora New Machine Setup Script
|
set -Eeuo pipefail
|
||||||
# Run as root or with sudo where needed
|
|
||||||
# Logs everything to setup.log
|
|
||||||
|
|
||||||
set -euo pipefail # Exit on error, undefined vars, pipe failures
|
LOGFILE="${HOME:-/root}/fedora-setup-$(date +%Y%m%d-%H%M%S).log"
|
||||||
|
exec > >(tee -a "$LOGFILE") 2>&1
|
||||||
|
|
||||||
LOGFILE="$HOME/fedora-setup-$(date +%Y%m%d-%H%M%S).log"
|
echo "=== Fedora New Machine Setup Started at $(date --iso-8601=seconds) ==="
|
||||||
exec &> >(tee -a "$LOGFILE")
|
|
||||||
|
|
||||||
echo "=== Fedora New Machine Setup Started at $(date) ==="
|
if [[ ${EUID:-$(id -u)} -eq 0 ]]; then
|
||||||
|
SUDO=""
|
||||||
# Check if running as root
|
REAL_USER="${SUDO_USER:-root}"
|
||||||
if [[ $EUID -ne 0 ]]; then
|
REAL_HOME="$(getent passwd "$REAL_USER" | cut -d: -f6)"
|
||||||
echo "Run this script with sudo for full functionality."
|
else
|
||||||
|
SUDO="sudo"
|
||||||
|
REAL_USER="$USER"
|
||||||
|
REAL_HOME="$HOME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Creating mount points..."
|
FEDORA_VER="$(rpm -E %fedora)"
|
||||||
sudo mkdir -p /mnt/games /mnt/media
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
|
|
||||||
echo "Installing RPM Fusion repos..."
|
run() {
|
||||||
sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
|
echo
|
||||||
|
echo ">>> $*"
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
echo "Adding Signal repo..."
|
warn() {
|
||||||
sudo dnf config-manager addrepo --from-repofile https://download.opensuse.org/repositories/network:im:signal/Fedora_$(rpm -E %fedora)/network:im:signal.repo
|
echo "WARNING: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
echo "Enabling Flatpak..."
|
have_cmd() {
|
||||||
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
command -v "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
echo "Upgrading system..."
|
pkg_installed() {
|
||||||
sudo dnf upgrade -y
|
rpm -q "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
echo "Installing multimedia codecs..."
|
pkg_install() {
|
||||||
sudo dnf swap ffmpeg-free ffmpeg --allowerasing
|
local to_install=()
|
||||||
sudo dnf install -y mozilla-openh264 gstreamer1-plugins-bad-freeworld ffmpeg
|
local pkg
|
||||||
sudo dnf update @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
|
|
||||||
sudo dnf install -y gstreamer1-plugins-{bad-freeworld,good,base} gstreamer1-plugin-openh264 lame* ffmpeg
|
|
||||||
sudo dnf group install -y multimedia sound-and-video --skip-unavailable
|
|
||||||
|
|
||||||
echo "Installing common apps..."
|
for pkg in "$@"; do
|
||||||
sudo dnf install -y davfs2 discord git hugo NetworkManager-openvpn openvpn
|
if ! pkg_installed "$pkg"; then
|
||||||
sudo dnf install -y oh-my-posh openrgb qbittorrent screenfetch signal-desktop steam thunderbird
|
to_install+=("$pkg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Installing Flatpaks..."
|
if ((${#to_install[@]} == 0)); then
|
||||||
flatpak install -y flathub org.signal.Signal com.bitwarden.desktop io.missioncenter.MissionCenter io.github.martinrotter.rssguard org.kde.konversation
|
echo "Packages already installed: $*"
|
||||||
flatpak install -y com.spotify.Client org.kde.konversation io.github.Archeb.opentrace
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Installing fonts..."
|
run $SUDO dnf install -y "${to_install[@]}" || warn "Some packages failed to install: ${to_install[*]}"
|
||||||
sudo dnf install -y cascadia-fonts-all
|
}
|
||||||
sudo fc-cache -f -v
|
|
||||||
|
|
||||||
echo "Setting up VS Code repo..."
|
flatpak_install() {
|
||||||
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
|
local ref
|
||||||
sudo tee /etc/yum.repos.d/vscode.repo > /dev/null <<EOF
|
for ref in "$@"; do
|
||||||
|
if flatpak info "$ref" >/dev/null 2>&1; then
|
||||||
|
echo "Flatpak already installed: $ref"
|
||||||
|
else
|
||||||
|
run flatpak install -y flathub "$ref" || warn "Flatpak failed: $ref"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
write_vscode_repo() {
|
||||||
|
run $SUDO rpm --import https://packages.microsoft.com/keys/microsoft.asc
|
||||||
|
run $SUDO tee /etc/yum.repos.d/vscode.repo >/dev/null <<'EOF'
|
||||||
[code]
|
[code]
|
||||||
name=Visual Studio Code
|
name=Visual Studio Code
|
||||||
baseurl=https://packages.microsoft.com/yumrepos/vscode
|
baseurl=https://packages.microsoft.com/yumrepos/vscode
|
||||||
enabled=1
|
enabled=1
|
||||||
autorefresh=1
|
|
||||||
type=rpm-md
|
type=rpm-md
|
||||||
gpgcheck=1
|
gpgcheck=1
|
||||||
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
|
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
|
||||||
EOF
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
echo "Updating repos and installing VS Code..."
|
echo "Detected Fedora version: $FEDORA_VER"
|
||||||
sudo dnf check-update
|
echo "Running as: ${REAL_USER}"
|
||||||
sudo dnf install -y code
|
|
||||||
|
|
||||||
echo "=== Setup completed at $(date). Check $LOGFILE for full log. ==="
|
echo
|
||||||
|
echo "Creating mount points..."
|
||||||
|
run $SUDO mkdir -p /mnt/games /mnt/media
|
||||||
|
|
||||||
echo ""
|
if have_cmd systemctl; then
|
||||||
echo "⚠️ WARNING: Mount Point Configuration Required ⚠️"
|
run $SUDO systemctl daemon-reload || true
|
||||||
echo ""
|
fi
|
||||||
echo "TODO: Add mount points to /etc/fstab with UUIDs for /mnt/games and /mnt/media."
|
|
||||||
echo " 1. Identify UUIDs: blkid | grep -E 'TYPE=\"ntfs\"'"
|
echo
|
||||||
echo " 2. Edit /etc/fstab (backup first: sudo cp /etc/fstab /etc/fstab.bak)"
|
echo "Installing DNF tools..."
|
||||||
echo " 3. Add lines like:"
|
pkg_install dnf-plugins-core
|
||||||
echo " UUID=XXXXXX-XXXX /mnt/games ntfs defaults,nofail,uid=1000,gid=1000,exec 0 0"
|
|
||||||
echo " UUID=YYYYYY-YYYY /mnt/media ntfs defaults,nofail,uid=1000,gid=1000 0 0"
|
echo
|
||||||
echo " 4. Test: sudo mount -a"
|
echo "Installing RPM Fusion repos..."
|
||||||
echo " 5. Reboot to verify."
|
run $SUDO dnf install -y \
|
||||||
echo ""
|
"https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-${FEDORA_VER}.noarch.rpm" \
|
||||||
echo "Use KDE Partition Manager for a GUI alternative."
|
"https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${FEDORA_VER}.noarch.rpm" \
|
||||||
echo ""
|
|| warn "RPM Fusion install failed or repos may already exist"
|
||||||
echo "⚠️ ⚠️"
|
|
||||||
|
echo
|
||||||
|
echo "Enabling Flatpak + Flathub..."
|
||||||
|
pkg_install flatpak
|
||||||
|
run flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Upgrading system..."
|
||||||
|
run $SUDO dnf upgrade -y || warn "System upgrade encountered errors"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Installing multimedia codecs..."
|
||||||
|
run $SUDO dnf swap -y ffmpeg-free ffmpeg --allowerasing || warn "ffmpeg swap failed"
|
||||||
|
run $SUDO dnf install -y \
|
||||||
|
mozilla-openh264 \
|
||||||
|
gstreamer1-plugins-bad-freeworld \
|
||||||
|
ffmpeg \
|
||||||
|
|| warn "Codec package install failed"
|
||||||
|
run $SUDO dnf update -y @multimedia --setopt=install_weak_deps=False --exclude=PackageKit-gstreamer-plugin \
|
||||||
|
|| warn "Multimedia group update failed"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Installing common RPM apps..."
|
||||||
|
pkg_install \
|
||||||
|
git \
|
||||||
|
hugo \
|
||||||
|
NetworkManager-openvpn \
|
||||||
|
openvpn \
|
||||||
|
qbittorrent \
|
||||||
|
steam \
|
||||||
|
thunderbird \
|
||||||
|
oh-my-posh \
|
||||||
|
openrgb \
|
||||||
|
screenfetch
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Installing fonts..."
|
||||||
|
pkg_install cascadia-fonts-all
|
||||||
|
run $SUDO fc-cache -f || true
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Setting up VS Code repo..."
|
||||||
|
write_vscode_repo
|
||||||
|
run $SUDO dnf makecache -y || warn "dnf makecache failed"
|
||||||
|
pkg_install code
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Installing optional RPM apps..."
|
||||||
|
pkg_install discord || warn "discord not available from enabled repos"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Installing Flatpaks..."
|
||||||
|
flatpak_install \
|
||||||
|
org.signal.Signal \
|
||||||
|
com.bitwarden.desktop \
|
||||||
|
io.missioncenter.MissionCenter \
|
||||||
|
io.github.martinrotter.rssguard \
|
||||||
|
org.kde.konversation \
|
||||||
|
com.spotify.Client \
|
||||||
|
io.github.Archeb.opentrace
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Setting ownership hint for /mnt/games..."
|
||||||
|
echo "After you mount the ext4 games partition, you may want:"
|
||||||
|
echo " sudo chown -R ${REAL_USER}:${REAL_USER} /mnt/games"
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
=== Setup completed at $(date --iso-8601=seconds) ===
|
||||||
|
Check log: $LOGFILE
|
||||||
|
|
||||||
|
Manual mount follow-up:
|
||||||
|
|
||||||
|
1. Find UUIDs:
|
||||||
|
lsblk -f
|
||||||
|
|
||||||
|
2. Back up fstab:
|
||||||
|
sudo cp /etc/fstab /etc/fstab.bak
|
||||||
|
|
||||||
|
3. Add entries like these:
|
||||||
|
|
||||||
|
# ext4 games partition
|
||||||
|
UUID=XXXXXX-XXXX /mnt/games ext4 defaults,nofail 0 2
|
||||||
|
|
||||||
|
# example media partition if still NTFS
|
||||||
|
UUID=YYYYYY-YYYY /mnt/media ntfs defaults,nofail,uid=1000,gid=1000 0 0
|
||||||
|
|
||||||
|
4. Test mounts:
|
||||||
|
sudo mount -a
|
||||||
|
|
||||||
|
5. For the ext4 games partition, fix ownership if needed:
|
||||||
|
sudo chown -R ${REAL_USER}:${REAL_USER} /mnt/games
|
||||||
|
|
||||||
|
6. Reboot and verify.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- /mnt/games is assumed to be ext4.
|
||||||
|
- Signal Desktop is installed via Flatpak only.
|
||||||
|
- ext4 stores ownership/permissions in the filesystem itself.
|
||||||
|
- Use KDE Partition Manager or GNOME Disks if you prefer a GUI.
|
||||||
|
|
||||||
|
EOF
|
||||||
Reference in new issue
Block a user