From 3e41899b4fef10cbfc530a96de281570ba86594d Mon Sep 17 00:00:00 2001 From: Hutch-45D Date: Fri, 20 Dec 2024 11:12:49 -0400 Subject: [PATCH] Changing Rocky scripts for 8 and 9 and adding steps to preconfig scripts for ceph --- ...cher.sh => rocky8-offline-repo-switcher.sh | 10 + ...config-ceph.sh => rocky8-preconfig-ceph.sh | 78 ++++- ...-offline.sh => rocky8-preconfig-offline.sh | 9 + rocky-preconfig.sh => rocky8-preconfig.sh | 20 +- rocky9-preconfig-ceph.sh | 299 ++++++++++++++++++ ubuntu20-preconfig-ceph.sh | 31 +- ubuntu20-preconfig-offline.sh | 8 + ubuntu20-preconfig.sh | 8 + ubuntu22-preconfig-ceph.sh | 13 +- 9 files changed, 464 insertions(+), 12 deletions(-) rename rocky-offline-repo-switcher.sh => rocky8-offline-repo-switcher.sh (85%) mode change 100755 => 100644 rename rocky-preconfig-ceph.sh => rocky8-preconfig-ceph.sh (69%) rename rocky-preconfig-offline.sh => rocky8-preconfig-offline.sh (94%) rename rocky-preconfig.sh => rocky8-preconfig.sh (92%) create mode 100644 rocky9-preconfig-ceph.sh diff --git a/rocky-offline-repo-switcher.sh b/rocky8-offline-repo-switcher.sh old mode 100755 new mode 100644 similarity index 85% rename from rocky-offline-repo-switcher.sh rename to rocky8-offline-repo-switcher.sh index 6a69720..7a0f8dc --- a/rocky-offline-repo-switcher.sh +++ b/rocky8-offline-repo-switcher.sh @@ -1,4 +1,14 @@ #!/usr/bin/bash + +ID=$(grep -w ID= /etc/os-release | cut -d= -f2 | tr -d '"') +Platform=$(grep -w PLATFORM_ID= /etc/os-release | cut -d= -f2 | tr -d '"') + +# Check if the OS is Rocky Linux 8 +if [[ "$ID" != "rocky" || "$Platform" != "platform:el8" ]]; then + echo "OS is not Rocky8 Linux" + exit 1 +fi + usage() { echo "Options: e - Enable Offline Repos, d - Disable Offline Repos" >&2 } diff --git a/rocky-preconfig-ceph.sh b/rocky8-preconfig-ceph.sh similarity index 69% rename from rocky-preconfig-ceph.sh rename to rocky8-preconfig-ceph.sh index 729a1f6..72697fa 100644 --- a/rocky-preconfig-ceph.sh +++ b/rocky8-preconfig-ceph.sh @@ -1,5 +1,17 @@ #!/bin/bash +# Matthew Hutchinson + +# Rocky 8 System Configuration Tweaks for Cluster Nodes + +ID=$(grep -w ID= /etc/os-release | cut -d= -f2 | tr -d '"') +Platform=$(grep -w PLATFORM_ID= /etc/os-release | cut -d= -f2 | tr -d '"') + +# Check if the OS is Rocky Linux 8 +if [[ "$ID" != "rocky" || "$Platform" != "platform:el8" ]]; then + echo "OS is not Rocky8 Linux" + exit 1 +fi interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') @@ -31,7 +43,7 @@ Welcome to the | ##| ######/| #######/| ## | ## \ #/ | ####### /#######/ |__/ \______/ |_______/ |__/ |__/ \_/ \_______/|_______/ - Rocky Preconfiguration Script. + Rocky8 Preconfiguration Script. This script will install epel-release, zfs, cockpit and add our repos. Houston UI will be configured with our latest tools and packages. @@ -56,6 +68,66 @@ EOF setup_45drives_repo() { local res + + #Install Ceph Repo + read -p "What version of Ceph are you using (15/16/17): " response + if [[ "$response" == "15" ]]; then + echo "Configuring Ceph Stable repository for version 15" + cat < /etc/yum.repos.d/ceph_stable.repo +[ceph_stable] +baseurl = http://download.ceph.com/rpm-octopus/el8/\$basearch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable \$basearch repo +priority = 2 + +[ceph_stable_noarch] +baseurl = http://download.ceph.com/rpm-octopus/el8/noarch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable noarch repo +priority = 2 +EOF + elif [[ "$response" == "16" ]]; then + echo "Configuring Ceph Stable repository for version 16" + cat < /etc/yum.repos.d/ceph_stable.repo +[ceph_stable] +baseurl = http://download.ceph.com/rpm-pacific/el8/\$basearch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable \$basearch repo +priority = 2 + +[ceph_stable_noarch] +baseurl = http://download.ceph.com/rpm-pacific/el8/noarch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable noarch repo +priority = 2 +EOF + elif [[ "$response" == "17" ]]; then + echo "Configuring Ceph Stable repository for version 17" + cat < /etc/yum.repos.d/ceph_stable.repo +[ceph_stable] +baseurl = http://download.ceph.com/rpm-17.2.7/el8/\$basearch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable \$basearch repo +priority = 2 + +[ceph_stable_noarch] +baseurl = http://download.ceph.com/rpm-17.2.7/el8/noarch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable noarch repo +priority = 2 +EOF + else + echo "Invalid Selection, Please enter '15''16' or '17'" + exit + fi + + #Install 45Drives Repository echo "Downloading 45Drives Repo Setup Script" curl -sSL https://repo.45drives.com/setup -o setup-repo.sh @@ -108,7 +180,7 @@ houston_configuration() { dnf -y install dnf-plugins-core dnf config-manager --set-enabled powertools dnf install -y cockpit cockpit-pcp cockpit-benchmark cockpit-navigator cockpit-file-sharing cockpit-45drives-hardware cockpit-identities cockpit-machines \ - cockpit-sosreport cockpit-storaged cockpit-scheduler cockpit-zfs + cockpit-sosreport cockpit-storaged cockpit-scheduler res=$? if [[ $res != 0 ]]; then echo "Error Installing Cockpit" @@ -138,7 +210,7 @@ update_system() { local res echo "Updating system" - dnf update -y + dnf update --nobest -y res=$? if [[ $res != 0 ]]; then diff --git a/rocky-preconfig-offline.sh b/rocky8-preconfig-offline.sh similarity index 94% rename from rocky-preconfig-offline.sh rename to rocky8-preconfig-offline.sh index cf82ca1..ffc2bc4 100644 --- a/rocky-preconfig-offline.sh +++ b/rocky8-preconfig-offline.sh @@ -1,5 +1,14 @@ #!/bin/bash +ID=$(grep -w ID= /etc/os-release | cut -d= -f2 | tr -d '"') +Platform=$(grep -w PLATFORM_ID= /etc/os-release | cut -d= -f2 | tr -d '"') + +# Check if the OS is Rocky Linux 8 +if [[ "$ID" != "rocky" || "$Platform" != "platform:el8" ]]; then + echo "OS is not Rocky8 Linux" + exit 1 +fi + interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') if [ "$interpreter" != "bash" ]; then diff --git a/rocky-preconfig.sh b/rocky8-preconfig.sh similarity index 92% rename from rocky-preconfig.sh rename to rocky8-preconfig.sh index e3bfe3b..eea638c 100644 --- a/rocky-preconfig.sh +++ b/rocky8-preconfig.sh @@ -1,5 +1,21 @@ #!/bin/bash +# Matthew Hutchinson + + +# Rocky 8 System Configuration Tweaks + + +ID=$(grep -w ID= /etc/os-release | cut -d= -f2 | tr -d '"') +Platform=$(grep -w PLATFORM_ID= /etc/os-release | cut -d= -f2 | tr -d '"') + +# Check if the OS is Rocky Linux 8 +if [[ "$ID" != "rocky" || "$Platform" != "platform:el8" ]]; then + echo "OS is not Rocky8 Linux" + exit 1 +fi + + interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') if [ "$interpreter" != "bash" ]; then @@ -29,7 +45,7 @@ Welcome to the | ##| ######/| #######/| ## | ## \ #/ | ####### /#######/ |__/ \______/ |_______/ |__/ |__/ \_/ \_______/|_______/ - Rocky Preconfiguration Script. + Rocky8 Preconfiguration Script. This script will install epel-release, zfs, cockpit and add our repos. Houston UI will be configured with our latest tools and packages. @@ -178,7 +194,7 @@ update_system() { local res echo "Updating system" - dnf update -y + dnf update --nobest -y res=$? if [[ $res != 0 ]]; then diff --git a/rocky9-preconfig-ceph.sh b/rocky9-preconfig-ceph.sh new file mode 100644 index 0000000..13ecf7b --- /dev/null +++ b/rocky9-preconfig-ceph.sh @@ -0,0 +1,299 @@ +#!/bin/bash + +# Matthew Hutchinson + +# Rocky 9 System Configuration Tweaks for Cluster Nodes + +ID=$(grep -w ID= /etc/os-release | cut -d= -f2 | tr -d '"') +Platform=$(grep -w PLATFORM_ID= /etc/os-release | cut -d= -f2 | tr -d '"') + +# Check if the OS is Rocky Linux 9 +if [[ "$ID" != "rocky" || "$Platform" != "platform:el9" ]]; then + echo "OS is not Rocky9 Linux" + exit 1 +fi + + +interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') + +if [ "$interpreter" != "bash" ]; then + echo "Please run with bash. (\`./rocky-preconfig.sh\` or \`bash rocky-preconfig.sh\`)" + echo "Current interpreter: $interpreter" + exit 1 +fi + +euid=$(id -u) + +if [[ "$euid" != 0 ]]; then + echo "Please run as root or with sudo." + exit 1 +fi + +welcome() { + local response + cat < /etc/yum.repos.d/ceph_stable.repo +[ceph_stable] +baseurl = http://download.ceph.com/rpm-17.2.7/el9/\$basearch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable \$basearch repo +priority = 2 + +[ceph_stable_noarch] +baseurl = http://download.ceph.com/rpm-17.2.7/el9/noarch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable noarch repo +priority = 2 +EOF + elif [[ "$response" == "18" ]]; then + echo "Configuring Ceph Stable repository for version 18" + cat < /etc/yum.repos.d/ceph_stable.repo +[ceph_stable] +baseurl = http://download.ceph.com/rpm-reef/el9/\$basearch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable \$basearch repo +priority = 2 + +[ceph_stable_noarch] +baseurl = http://download.ceph.com/rpm-reef/el9/noarch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable noarch repo +priority = 2 +EOF + elif [[ "$response" == "19" ]]; then + echo "Configuring Ceph Stable repository for version 19" + cat < /etc/yum.repos.d/ceph_stable.repo +[ceph_stable] +baseurl = http://download.ceph.com/rpm-squid/el9/\$basearch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable \$basearch repo +priority = 2 + +[ceph_stable_noarch] +baseurl = http://download.ceph.com/rpm-squid/el9/noarch +gpgcheck = 1 +gpgkey = https://download.ceph.com/keys/release.asc +name = Ceph Stable noarch repo +priority = 2 +EOF + else + echo "Invalid Selection, Please enter '17''18' or '19'" + exit + fi + + + #Install 45Drives Repository + # echo "Downloading 45Drives Repo Setup Script" + # curl -sSL https://repo.45drives.com/setup -o setup-repo.sh + + # res=$? + # if [[ $res != 0 ]]; then + # echo "Failed to download repo setup script! (https://repo.45drives.com/setup)" + # exit $res + # fi + + # echo "Running 45Drives Repo Setup Script" + # bash setup-repo.sh + # res=$? + # if [[ $res != 0 ]]; then + # echo "Failed to run the setup script! (https://repo.45drives.com/setup)" + # exit $res + # fi + + # return 0 +} + + +install_epel_release() { + local res + echo "Installing epel-release" + dnf install epel-release -y + + res=$? + + if [[ $res != 0 ]]; then + echo "epel-release install failed!" + exit $res + fi + return 0 +} + +selinux_permissive() { + echo "Setting SELinux to permissive" + setenforce 0 + + echo "Ensuring Setting Persists on Reboot" + sed -i 's/^\(SELINUX=\).*$/\1permissive/' /etc/selinux/config + return 0 +} + +houston_configuration() { + local res + + echo "Installing Cockpit and Modules" + dnf -y install dnf-plugins-core + dnf config-manager --set-enabled powertools + dnf install -y cockpit + #cockpit-pcp cockpit-benchmark cockpit-navigator cockpit-file-sharing cockpit-45drives-hardware cockpit-identities cockpit-machines cockpit-sosreport cockpit-storaged cockpit-scheduler + res=$? + if [[ $res != 0 ]]; then + echo "Error Installing Cockpit" + exit $res + fi + + echo "Configuring Firewall" + firewall-cmd --add-service=cockpit --permanent + res=$? + if [[ $res != 0 ]]; then + echo "Error Configuring Firewall" + exit $res + fi + firewall-cmd --reload + + echo "Enabling Cockpit" + systemctl enable --now cockpit.socket + res=$? + if [[ $res != 0 ]]; then + echo "Error Configuring Firewall" + exit $res + fi + return 0 +} + +update_system() { + local res + + echo "Updating system" + dnf update --nobest -y + res=$? + + if [[ $res != 0 ]]; then + echo "Failed to update system" + exit $res + fi + + echo "Successfully Updated System" + return 0 +} + +setup_done() { + + echo "Installation Complete" + echo "Access Houston UI at https://$(hostname -I | awk '{print $1}'):9090 in a browser" + + return 0 +} + +progress="" + +if [[ -f .rocky-preconfig.progress ]]; then + progress=$(cat .rocky-preconfig.progress) +fi + +if [[ $progress != "" ]]; then + echo "Found progress from previous time running this script. ($PWD/.rocky-preconfig.progress)" + echo "1. Continue from last successful step." + echo "2. Start from beginning." + echo "3. Exit. (default)" + read -p "[1-3]: " response + case $response in + 1) + echo "Starting from last successful step." + ;; + 2) + echo "Starting from beginning." + progress="" + ;; + *) + echo "Exiting..." + exit 0 + ;; + esac +fi + +case $progress in + "") + welcome + ;& + 0) + echo "################################################################################" + setup_45drives_repo + echo 1 > .rocky-preconfig.progress + ;& + 1) + echo "################################################################################" + install_epel_release + echo 2 > .rocky-preconfig.progress + ;& + 2) + echo "################################################################################" + selinux_permissive + echo 3 > .rocky-preconfig.progress + ;& + 3) + echo "################################################################################" + houston_configuration + echo 4 > .rocky-preconfig.progress + ;& + 4) + echo "################################################################################" + update_system + echo 5 > .rocky-preconfig.progress + ;& + 5) + echo "################################################################################" + setup_done + echo 6 > .rocky-preconfig.progress + ;& + 6) + echo "Setup successfully finished the previous time running this script." + ;; +esac + +exit 0 \ No newline at end of file diff --git a/ubuntu20-preconfig-ceph.sh b/ubuntu20-preconfig-ceph.sh index 04c2794..1e82ad1 100644 --- a/ubuntu20-preconfig-ceph.sh +++ b/ubuntu20-preconfig-ceph.sh @@ -3,8 +3,17 @@ # Brett Kelly # Josh Boudreau # Dawson Della Valle +# Matthew Hutchinson + +# Ubuntu 20.04 LTS System Configuration Tweaks for Cluster Nodes + +OS=$(cat /etc/os-release | grep -w VERSION_ID) + +if [ "$OS" != 'VERSION_ID="20.04"' ] ; then + echo "OS is not Ubuntu20.04 LTS" + exit +fi -# Ubuntu 20.04 LTS System Configuration Tweaks interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') @@ -35,7 +44,7 @@ Welcome to the | ##| ######/| #######/| ## | ## \ #/ | ####### /#######/ |__/ \______/ |_______/ |__/ |__/ \_/ \_______/|_______/ - Ubuntu Preconfiguration Script. + Ubuntu20 Preconfiguration Script. This will set up the root login password, enable root login over SSH, add the 45Drives apt repository, replace systemd-networkd with network-manager, @@ -146,9 +155,23 @@ EOF update_system() { local res ## Update system - # Install 45drives repository - echo "UPDATING SYSTEM" + # Install Ceph repo + wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add - + + read -p "What version of Ceph are you using? (15/16/17): " response + + if [[ "$response" == "17" ]]; then + apt-add-repository 'deb https://download.ceph.com/debian-octopus/ jammy main' + elif [[ "$response" == "18" ]]; then + apt-add-repository 'deb https://download.ceph.com/debian-pacific/ jammy main' + elif [[ "$response" == "19" ]]; then + apt-add-repository 'deb https://download.ceph.com/debian-quincy/ jammy main' + else + echo "Invalid response. Please enter '15''16' or '17'." + exit 0 + fi + # Install 45drives repository echo "Downloading 45Drives Repo Setup Script" curl -sSL https://repo.45drives.com/setup -o setup-repo.sh diff --git a/ubuntu20-preconfig-offline.sh b/ubuntu20-preconfig-offline.sh index ce5619a..3209313 100644 --- a/ubuntu20-preconfig-offline.sh +++ b/ubuntu20-preconfig-offline.sh @@ -6,6 +6,14 @@ # Ubuntu 20.04 LTS System Configuration Tweaks +OS=$(cat /etc/os-release | grep -w VERSION_ID) + +if [ "$OS" != 'VERSION_ID="20.04"' ] ; then + echo "OS is not Ubuntu20" + exit +fi + + interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') if [ "$interpreter" != "bash" ]; then diff --git a/ubuntu20-preconfig.sh b/ubuntu20-preconfig.sh index 7404b21..4c54b70 100644 --- a/ubuntu20-preconfig.sh +++ b/ubuntu20-preconfig.sh @@ -6,6 +6,14 @@ # Ubuntu 20.04 LTS System Configuration Tweaks +OS=$(cat /etc/os-release | grep -w VERSION_ID) + +if [ "$OS" != 'VERSION_ID="20.04"' ] ; then + echo "OS is not Ubuntu20" + exit +fi + + interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') if [ "$interpreter" != "bash" ]; then diff --git a/ubuntu22-preconfig-ceph.sh b/ubuntu22-preconfig-ceph.sh index 414ecd7..3914ded 100644 --- a/ubuntu22-preconfig-ceph.sh +++ b/ubuntu22-preconfig-ceph.sh @@ -5,7 +5,15 @@ # Dawson Della Valle # Matthew Hutchinson -# Ubuntu 22.04 LTS System Configuration Tweaks +# Ubuntu 22.04 LTS System Configuration Tweaks for Cluster Nodes + +OS=$(cat /etc/os-release | grep -w VERSION_ID) + +if [ "$OS" != 'VERSION_ID="22.04"' ] ; then + echo "OS is not Ubuntu22.04 LTS" + exit +fi + interpreter=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()') @@ -162,8 +170,7 @@ update_system() { echo "Invalid response. Please enter '17''18' or '19'." exit 0 fi - - echo "UPDATING SYSTEM" + # Install 45drives repository # echo "Downloading 45Drives Repo Setup Script" # curl -sSL https://repo.45drives.com/setup -o setup-repo.sh