#!/bin/bash ceph_health=$(ceph -s 2>/dev/null | awk '$1 ~ /(noout,norebalance,norecover)/ {print $0}') ceph2=$(echo $ceph_health) ID=$(awk -F= '/^ID=/{gsub(/"/, "", $2); print $2}' /etc/os-release) # Check for supported OS and ceph-common package if [[ "$ID" == "ubuntu" ]]; then # Check for ceph-common using apt if ! apt list --installed 2>/dev/null | grep -qi ceph-common; then echo "ceph-common not installed on Ubuntu" exit 1 fi elif [[ "$ID" == "rocky" || "$ID" == "rhel" ]]; then # Check for ceph-common using dnf if ! dnf list installed ceph-common &>/dev/null; then echo "ceph-common not installed on $ID" exit 1 fi else echo "Unsupported OS: $ID" exit 1 fi ceph -s >/dev/null 2>&1 if [ $? != 0 ]; then echo you do not have permission to enable this exit 1 fi if [[ "$ceph_health" != *"noout,norebalance,norecover flag(s) set"* ]]; then ceph osd set noout ceph osd set norebalance ceph osd set norecover echo -e "ceph maintenance options: \e[1;35mnoout,norebalance,norecover\e[0m \e[1;32menabled\e[0m" else ceph osd unset noout ceph osd unset norebalance ceph osd unset norecover echo -e "ceph maintenance options: \e[1;35mnoout,norebalance,norecover\e[0m \e[1;31mdisabled\e[0m" fi