Skip to content

Commit 3a83bfa

Browse files
committed
Adds installation_scripts directory with rocky8 setup scripts for installing Desktop Environment, Cockpit + 45D Repos + Modules + ZFS
1 parent f634d88 commit 3a83bfa

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
3+
# For fresh installs of Rocky (8)
4+
# Installs desktop environment + sets up distros
5+
6+
get_base_distro() {
7+
local base_distro
8+
base_distro=$(grep '^ID_LIKE=' /etc/os-release | cut -d= -f2 | tr -d '"' | awk '{print $1}')
9+
10+
if [ -z "$base_distro" ]; then
11+
# fallback to ID if ID_LIKE is not found
12+
base_distro=$(grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"' | awk '{print $1}')
13+
fi
14+
15+
echo "$base_distro"
16+
}
17+
18+
get_distro() {
19+
grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"'
20+
}
21+
22+
get_version_id() {
23+
grep '^VERSION_ID=' /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d '.' -f1
24+
}
25+
26+
require_root() {
27+
if [ "$(id -u)" -ne 0 ]; then
28+
echo "This script must be run as root."
29+
exit 1
30+
fi
31+
}
32+
33+
backup_existing_repo() {
34+
if [[ -f /etc/yum.repos.d/45drives.repo ]]; then
35+
mkdir -p /opt/45drives/archives/repos
36+
mv /etc/yum.repos.d/45drives.repo /opt/45drives/archives/repos/45drives-$(date +%F).repo
37+
echo "Existing 45Drives repo backed up."
38+
fi
39+
if [[ -f /etc/apt/sources.list.d/45drives.list ]]; then
40+
mkdir -p /opt/45drives/archives/repos
41+
mv /etc/apt/sources.list.d/45drives.list /opt/45drives/archives/repos/45drives-$(date +%F).list
42+
echo "Existing 45Drives APT repo backed up."
43+
fi
44+
}
45+
46+
install_desktop_env() {
47+
if [[ $distro == "rhel" || $distro == "fedora" ]]; then
48+
echo "Installing XFCE Desktop Environment for Rocky/RHEL..."
49+
dnf update -y
50+
dnf install -y epel-release kernel-headers
51+
dnf groupinstall -y "Xfce" "base-x"
52+
echo "exec /usr/bin/xfce4-session" >> ~/.xinitrc
53+
systemctl set-default graphical
54+
fi
55+
}
56+
57+
add_cockpit_overrides() {
58+
echo "Adding Cockpit override configurations..."
59+
cat > /usr/share/cockpit/45drives-system/override.json <<EOF
60+
{
61+
"menu": {
62+
"45drives-system": {
63+
"order": 112
64+
}
65+
}
66+
}
67+
EOF
68+
}
69+
70+
allow_root_in_cockpit() {
71+
echo "Ensuring root is allowed in Cockpit..."
72+
local disallowed_file="/etc/cockpit/disallowed-users"
73+
74+
if [[ -f "$disallowed_file" ]]; then
75+
grep -q "^root$" "$disallowed_file" && {
76+
sed -i '/^root$/d' "$disallowed_file"
77+
echo "Removed root from $disallowed_file"
78+
} || echo "Root not present in disallowed-users"
79+
else
80+
echo "$disallowed_file does not exist. Skipping."
81+
fi
82+
}
83+
84+
run_preconfig_inline() {
85+
echo "Running integrated preconfiguration for $distro_id $distro_version..."
86+
backup_existing_repo
87+
88+
if [[ "$distro" == "rhel" || "$distro" == "fedora" ]]; then
89+
setenforce 0
90+
sed -i 's/SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
91+
curl -sSL https://repo.45drives.com/setup | bash
92+
dnf install -y cockpit cockpit-pcp cockpit-benchmark cockpit-navigator cockpit-file-sharing cockpit-45drives-hardware cockpit-identities cockpit-sosreport cockpit-storaged cockpit-scheduler
93+
firewall-cmd --add-service=cockpit --permanent && firewall-cmd --reload
94+
systemctl enable --now cockpit.socket
95+
dnf update -y
96+
fi
97+
98+
allow_root_in_cockpit
99+
100+
echo "Preconfiguration complete. Houston UI available at: https://$(hostname -I | awk '{print $1}'):9090"
101+
}
102+
103+
# Start Execution
104+
require_root
105+
distro=$(get_base_distro)
106+
distro_id=$(get_distro)
107+
distro_version=$(get_version_id)
108+
109+
echo "Detected distro: $distro_id (base: $distro), version: $distro_version"
110+
111+
if [[ "$distro" != "rhel" && "$distro" != "fedora" && "$distro" != "rocky" ]]; then
112+
echo "This is an unsupported distro. Please run on a Rocky, RHEL, or Fedora system."
113+
exit 1
114+
fi
115+
116+
install_desktop_env
117+
run_preconfig_inline
118+
119+
echo "Finished initial setup.... Reboot required."
120+
echo "Run ZFS-setup.sh after reboot to install zfs and cockpit zfs modules"
121+
122+
read -n 1 -s -r -p "Press any key to reboot..."
123+
echo
124+
125+
sudo reboot
126+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# For use after initial setup script
4+
# Installs ZFS and Cockpit-ZFS
5+
6+
get_base_distro() {
7+
grep '^ID_LIKE=' /etc/os-release | cut -d= -f2 | tr -d '"' | awk '{print $1}'
8+
}
9+
10+
get_distro() {
11+
grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"'
12+
}
13+
14+
get_version_id() {
15+
grep '^VERSION_ID=' /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d '.' -f1
16+
}
17+
18+
require_root() {
19+
if [ "$(id -u)" -ne 0 ]; then
20+
echo "This script must be run as root."
21+
exit 1
22+
fi
23+
}
24+
25+
require_root
26+
distro=$(get_base_distro)
27+
distro_id=$(get_distro)
28+
distro_version=$(get_version_id)
29+
30+
echo "Detected distro: $distro_id (base: $distro), version: $distro_version"
31+
32+
if [[ "$distro" != "rhel" && "$distro" != "fedora" && "$distro" != "rocky" ]]; then
33+
echo "This is an unsupported distro. Please run on a Rocky, RHEL, or Fedora system."
34+
exit 1
35+
fi
36+
37+
if ! command -v zfs &>/dev/null; then
38+
echo "ZFS not detected. Installing ZFS..."
39+
dnf install -y https://zfsonlinux.org/epel/zfs-release-2-3$(rpm --eval "%{dist}").noarch.rpm
40+
dnf install -y kernel-devel dkms zfs
41+
echo "zfs" > /etc/modules-load.d/zfs.conf
42+
modprobe zfs
43+
systemctl enable zfs-import-cache zfs-import-scan zfs-mount zfs.target zfs-zed
44+
else
45+
echo "ZFS already installed."
46+
fi
47+
48+
# Make sure SELinux is permissive
49+
setenforce 0
50+
sed -i 's/SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
51+
52+
# Re-run repo setup to ensure 45Drives repo is present
53+
curl -sSL https://repo.45drives.com/setup | bash
54+
55+
echo "Installing Cockpit ZFS module..."
56+
dnf install -y cockpit-zfs
57+
58+
# Ensure cockpit.socket is active
59+
systemctl enable --now cockpit.socket
60+
61+
echo "ZFS and Cockpit-ZFS installation complete."
62+
echo "Access Cockpit at: https://$(hostname -I | awk '{print $1}'):9090"
63+
64+
read -n 1 -s -r -p "Press any key to reboot and load ZFS modules..."
65+
echo
66+
67+
sudo reboot

0 commit comments

Comments
 (0)