-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall.sh
More file actions
114 lines (87 loc) · 3.41 KB
/
Copy pathinstall.sh
File metadata and controls
114 lines (87 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
# install.sh
# ----------------
# Installs and configures Snapper + grub-btrfs on Fedora
# along with SysGuides Snapper integration scripts.
#
# This script:
# - Installs required packages
# - Configures Snapper (root + home)
# - Sets permissions and ACLs
# - Configures updatedb to ignore snapshots
# - Installs grub-btrfs
# - Installs Snapper integration scripts (DNF5 actions)
#
# Project: sysguides-snapper-fedora
# Author: Madhu Desai (SysGuides)
# Website: https://sysguides.com
# GitHub: https://github.com/SysGuides/sysguides-snapper-fedora
set -e
# Get absolute path of this script (works regardless of current directory)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Prevent running as root
if [[ $EUID -eq 0 ]]; then
echo "Please run this script as a normal user:"
echo " ./install.sh"
exit 1
fi
echo "[1/6] Installing required packages..."
sudo dnf install -y snapper libdnf5-plugin-actions btrfs-assistant inotify-tools make
# Check if system is using Btrfs
if ! findmnt -n -o FSTYPE / | grep -q btrfs; then
echo "Error: Root filesystem is not Btrfs"
exit 1
fi
echo "[2/6] Configuring Snapper..."
# Create configs if not present
[ -d /.snapshots ] || sudo snapper -c root create-config /
[ -d /home/.snapshots ] || sudo snapper -c home create-config /home
# Fix SELinux contexts
sudo restorecon -RFv /.snapshots
sudo restorecon -RFv /home/.snapshots
# Set permissions for current user
REAL_USER=${SUDO_USER:-$USER}
sudo snapper -c root set-config ALLOW_USERS=$REAL_USER SYNC_ACL=yes
sudo snapper -c home set-config ALLOW_USERS=$REAL_USER SYNC_ACL=yes
# Disable timeline snapshots for home
sudo snapper -c home set-config TIMELINE_CREATE=no
echo "[3/6] Updating locate database config..."
# Ensure .snapshots is excluded from updatedb
if grep -q '^PRUNENAMES' /etc/updatedb.conf; then
grep -q '\.snapshots' /etc/updatedb.conf || \
sudo sed -i 's|^PRUNENAMES *= *"|PRUNENAMES = ".snapshots |' /etc/updatedb.conf
else
echo 'PRUNENAMES = ".snapshots"' | sudo tee -a /etc/updatedb.conf
fi
echo "[4/6] Installing grub-btrfs..."
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
cd "$tmpdir"
git clone --depth 1 https://github.com/Antynea/grub-btrfs
cd grub-btrfs
# Configure grub-btrfs for Fedora
sed -i \
-e 's|^#GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS=.*|GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1"|' \
-e 's|^#GRUB_BTRFS_GRUB_DIRNAME=.*|GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"|' \
-e 's|^#GRUB_BTRFS_MKCONFIG=.*|GRUB_BTRFS_MKCONFIG=/usr/bin/grub2-mkconfig|' \
-e 's|^#GRUB_BTRFS_SCRIPT_CHECK=.*|GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check|' \
config
sudo make install
sudo systemctl enable --now grub-btrfsd.service
# Generate GRUB config (important for first run)
echo "==> Updating GRUB configuration..."
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
echo "[5/6] Installing Snapper integration scripts..."
# Install scripts
sudo install -m 755 "$SCRIPT_DIR"/scripts/* /usr/local/bin/
# Restore SELinux context
sudo restorecon -v /usr/local/bin/snapper-*.sh
# Install DNF5 actions file
sudo mkdir -p /etc/dnf/libdnf5-plugins/actions.d/
sudo install -m 644 "$SCRIPT_DIR"/config/snapper.actions /etc/dnf/libdnf5-plugins/actions.d/
echo "[6/6] Enabling Snapper timers..."
sudo systemctl enable --now snapper-timeline.timer
sudo systemctl enable --now snapper-cleanup.timer
echo ""
echo "✅ Installation complete!"
echo "Snapper is now fully integrated with DNF5 (CLI + GUI)."