Compare commits

...

4 Commits

Author SHA1 Message Date
tteckster 7a22dbfa98
Update scaling-governor.sh
tweak
2023-03-08 20:56:23 -05:00
tteckster 65d6956819
Update CHANGELOG.MD 2023-03-08 20:29:42 -05:00
tteckster a153da3465
Update scaling-governor.sh
menu options dynamically based on the available scaling governors
2023-03-08 20:19:37 -05:00
tteckster 6b10aa922a
Update usb-passthrough.sh
clean
2023-03-08 19:08:45 -05:00
3 changed files with 34 additions and 109 deletions

View File

@ -2,6 +2,14 @@
# Change Log
All notable changes to this project will be documented in this file.
## 2023-03-08
### Changed
- **Proxmox CPU Scaling Governor**
- Menu options dynamically based on the available scaling governors.
## 2023-03-07
### Changed

View File

@ -5,20 +5,17 @@
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info {
cat <<"EOF"
header_info() {
clear
cat <<EOF
__________ __ __
/ ____/ __ \/ / / /
/ / / /_/ / / / /
/ /___/ ____/ /_/ /
\____/_/ \____/
Scaling Governors
EOF
}
clear
header_info
set -e
while true; do
read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
case $yn in
@ -27,89 +24,34 @@ while true; do
*) echo "Please answer yes or no." ;;
esac
done
clear
show_menu() {
CL=$(echo "\033[m")
GN=$(echo "\033[32m")
BL=$(echo "\033[36m")
YW=$(echo "\033[33m")
fgred=$(echo "\033[31m")
header_info
CK=$(uname -r)
IP=$(hostname -I)
# MAC=$(cat /sys/class/net/eno1/address)
ACSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
CCSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
echo -e "${YW}Proxmox IP ${BL}${IP}${CL}"
echo -e "${YW}MAC Address ${BL}${MAC}${CL}"
echo -e "${YW}Current Kernel ${BL}${CK}${CL}"
echo -e "\n${YW}Available CPU Scaling Governors
${BL}${ACSG}${CL}"
echo -e "\n${YW}Current CPU Scaling Governor
${BL}${CCSG}${CL}"
printf "\n ${fgred}Only Select Available CPU Scaling Governors From Above${CL}\n \n"
printf "${BL}**${YW} 1)${GN} Switch to ${BL}conservative${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 2)${GN} Switch to ${BL}ondemand${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 3)${GN} Switch to ${BL}userspace${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 4)${GN} Switch to ${BL}powersave${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 5)${GN} Switch to ${BL}performance${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 6)${GN} Switch to ${BL}schedutil${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "\n ${fgred}NOTE: Settings return to default after reboot${CL}\n"
printf "\n Please choose an option from the menu and press [ENTER] or ${fgred}x${CL} to exit."
read opt
echo -e "\nProxmox IP \033[36m$(hostname -I)\033[m"
echo -e "Current Kernel \033[36m$(uname -r)\033[m\n"
available_governors=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
echo -e "Available CPU Scaling Governors\n\033[36m${available_governors}\033[m\n"
echo -e "Current CPU Scaling Governor\n\033[36m$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)\033[m\n"
options=""
i=1
for governor in $available_governors
do
options+="** ${i}) \033[36m${governor}\033[m CPU Scaling Governor\n"
((i=i+1))
done
echo -e "${options}"
echo -e "\033[31mNOTE: Settings return to default after reboot\033[m\n"
read -p "Please choose an option from the menu and press [ENTER] or x to exit." opt
}
clear
show_menu
while [ "$opt" != "" ]; do
if [ "$opt" = "" ]; then
while [[ "$opt" != "" ]]; do
num_governors=$(echo "$available_governors" | wc -w)
if [[ $opt -gt 0 ]] && [[ $opt -le $num_governors ]]; then
governor=$(echo "$available_governors" | cut -d' ' -f $opt)
echo "${governor}" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
elif [[ $opt == "x" ]] || [[ $opt == "\n" ]]; then
exit
else
case $opt in
1)
echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
2)
echo "ondemand" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
3)
echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
4)
echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
5)
echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
6)
echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
x)
exit
;;
\n)
exit
;;
*)
clear
show_menu
;;
esac
show_menu
fi
show_menu
done

View File

@ -15,31 +15,6 @@ while true; do
esac
done
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
shopt -s expand_aliases
alias die='EXIT=$? LINE=$LINENO error_exit'
trap die ERR
trap cleanup EXIT
function error_exit() {
trap - ERR
local DEFAULT='Unknown failure occured.'
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
msg "$FLAG $REASON"
exit $EXIT
}
function msg() {
local TEXT="$1"
echo -e "$TEXT"
}
function cleanup() {
popd >/dev/null
rm -rf $TEMP_DIR
}
TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null
CHAR_DEVS+=("166:.*")