Skip to content

Instantly share code, notes, and snippets.

@nik-gnomic
Last active February 29, 2024 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nik-gnomic/607421bb494ffb0e84778cfa56aa5879 to your computer and use it in GitHub Desktop.
Save nik-gnomic/607421bb494ffb0e84778cfa56aa5879 to your computer and use it in GitHub Desktop.
#!/bin/bash
# ManjaroRealtimeConfig.sh
# Bash script to check Manjaro OS realtime configuration for JACK
NOTGOOD='\033[0;31mNot Good\033[0m'
GOOD='\033[0;32mGood\033[0m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
WHITE='\033[0m'
RebootMsg=false
echo -e "\n--- Manjaro JACK Configuration Scan ---"
echo -e "\n${BLUE} for more information see https://forums.manjaro.org/t${WHITE}\n"
## check user is in audio group ##
echo " 1 Checking audio group"
if ( groups | grep audio > /dev/null );
then
echo -e "\tuser is a member of audio group\t\t${GOOD}"
else
echo -e "\tuser is NOT a member of audio group\t${NOTGOOD}"
echo -e "\tAdd user to audio group\n\t${YELLOW}sudo gpasswd $USER -a audio${WHITE}"
RebootMsg=true
fi
## check realtime-privileges is installed and user is in realtime group ##
echo -e "\n 2 Checking realtime-privileges"
# check realtime-privileges installed
if (pacman -Q | grep realtime-privileges) > /dev/null;
then
echo -e "\trealtime-privileges installed\t\t${GOOD}"
# Checking realtime group membership
if (groups | grep realtime) > /dev/null;
then
echo -e "\tUser is a member of realtime group \t${GOOD}"
else
echo -e "\tUser is NOT a member of realtime group\t${NOTGOOD}"
echo -e "\tAdd user to realtime group\n\t${YELLOW}sudo gpasswd $USER -a realtime${WHITE}"
RebootMsg=true
fi
else
echo -e "\trealtime-privileges NOT installed\t${NOTGOOD}"
echo -e "\tInstall realtime-privileges\n\t${YELLOW}pamac install realtime-privileges${WHITE}"
echo -e "\tAdd user to realtime group\n\t${YELLOW}sudo gpasswd $USER -a realtime${WHITE}"
RebootMsg=true
fi
## check sysctl configuration inotify watches and swappiness
echo -e "\n 3 Checking sysctl parameters"
## 3.1 inotify.max_user_watches check
echo -en "\tinotify.max_user_watches = $(sysctl -n fs.inotify.max_user_watches)"
if (( $(sysctl -n fs.inotify.max_user_watches) < 524288 ));
then
echo -e "\t${NOTGOOD}"
echo -e "\tincrease value to 524288"
echo -e "\t${YELLOW}echo '52488' | sudo tee -a /etc/sysctl.d/99-sysctl-realtime.conf${WHITE}"
RebootMsg=true
else
echo -e "\t${GOOD}";
fi
# 3.2 swappiness check
echo -en "\tvm.swappiness = ""$(sysctl -n vm.swappiness)"
if (( $(sysctl -n vm.swappiness) > 10 ));
then
echo -e "\t\t\t${NOTGOOD}"
echo -e "\tdecrease value to 10"
echo -e "\t${YELLOW}echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.d/99-sysctl-realtime.conf${WHITE}"
RebootMsg=true
else
echo -e "\t\t\t${GOOD}"
fi
## Kernel check ##
echo -e "\n 4 Checking kernel"
# 4.1 RT kernel check #
if (mhwd-kernel -li | grep rt) > /dev/null;
then
echo -e "\tRealtime kernel installed\t\t${GOOD}"
else
echo -e "\tRealtime kernel NOT installed"
# 4.2 rtirq check #
if (pacman -Q | grep rtirq) > /dev/null;
then
echo -e "\trtirq installed\t\t\t\t${GOOD}"
# 4.3 threadirqs check
if (grep threadirqs /etc/default/grub) > /dev/null ;
then
echo -e "\tthreadirqs boot option detected\t\t${GOOD}"
else
echo -e "\tthreadirqs boot option NOT detected\t\t${NOTGOOD}"
echo -e "\tAdd threadirqs boot option to GRUB\n\t${YELLOW}sudo sed 's/CMDLINE_LINUX_DEFAULT=\"/CMDLINE_LINUX_DEFAULT=\"threadirqs /g' /etc/default/grub"
echo -e "\tUpdate GRUB\n\t${YELLOW}sudo update-grub${WHITE}"
RebootMsg=true
fi
else
echo -e "\trtirq for kernel NOT installed\t\t${NOTGOOD}"
echo -e "\tInstall rtirq\n\t${YELLOW}pamac install rtirq${WHITE}"
echo -e "\tAdd threadirqs boot option to GRUB\nsudo sed 's/CMDLINE_LINUX_DEFAULT=\"/CMDLINE_LINUX_DEFAULT=\"threadirqs /g' /etc/default/grub${WHITE}"
echo -e "\tUpdate GRUB\n\t${YELLOW}sudo update-grub${WHITE}"
fi
fi
## CPU governor check ##
echo -e "\n 5 Checking CPU governors"
if (grep -vh "performance" /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null);
then
echo -e "\tCPU governors NOT set to performance\t${NOTGOOD}"
echo -e "\tchange CPU governor to performance"
echo -e "\t${YELLOW}systemctl enable cpupower.service --now${WHITE}"
else
echo -e "\tCPU governors set to performance\t${GOOD}"
fi
if [ $RebootMsg = true ];
then
echo -e "\n${BLUE} system reboot is recommended to ensure configuration changes are loaded${WHITE}"
fi
echo -e "\n --- scan completed ---"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment