-
-
Save fniephaus/84dc1e065b2694cf9beafed5920f8cfe to your computer and use it in GitHub Desktop.
helper functions for squeak.sh launcher script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONF_FILE="/etc/security/limits.d/squeak.conf" | |
# Ensure that Linux kernel is newer than 2.6.12 which is required for the heartbeat thread | |
ensure_kernel() { | |
local kernel_release="$(uname -r)" | |
local re='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' | |
local major=$(echo "${kernel_release}" | sed -e "s#${re}#\1#") | |
local minor=$(echo "${kernel_release}" | sed -e "s#${re}#\2#") | |
local patch=$(echo "${kernel_release}" | sed -e "s#${re}#\3#") | |
# 2.6.12 | |
local min_major="2" | |
local min_minor="6" | |
local min_patch="12" | |
if [[ "${major}" -lt "${min_major}" ]] || \ | |
[[ "${major}" -le "${min_major}" && "${major}" -lt "${min_minor}" ]] || \ | |
[[ "${major}" -le "${min_major}" && "${major}" -le "${min_minor}" && "${patch}" -lt "${min_patch}" ]]; then | |
showerror "Linux kernel ($(uname -r)) needs to be newer than ${min_major}.${min_minor}.${min_patch}." | |
exit 1 | |
fi | |
} | |
# Ensure that the $CONF_FILE configuration file exists and help to create one | |
ensure_conf_file() { | |
local user_input | |
if ! [[ -f "${CONF_FILE}" ]]; then | |
read -p "${CONF_FILE} is missing. Do you want to create one? | |
This operation requires sudo permissions. (y/N): " user_input | |
if [[ "${user_input}" = "y" ]]; then | |
echo "You may be asked to enter your password..." | |
sudo tee -a "${CONF_FILE}" > /dev/null <<END | |
* hard rtprio 2 | |
* soft rtprio 2 | |
END | |
echo "Done! Please log out and log back in before you try again." | |
else | |
echo "Operation cancelled." | |
fi | |
exit 0 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment