From c1dcf70f6021a48f3e36767ef80e16cf81a1688e Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> Date: Sat, 11 Nov 2023 13:33:33 +0100 Subject: [PATCH] chore: add startup delay to service for SpeederPad --- tools/install.sh | 6 ++++++ tools/libs/core.sh | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tools/install.sh b/tools/install.sh index ce0c4f77..c7ff3649 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -117,6 +117,12 @@ main() { status_msg "Install service file ..." "1" fi + if [[ "$(is_speederpad)" = "1" ]]; then + msg "\nSpeederpad detected!" + msg "Add startup delay to service file ...\n" + add_sleep_to_service_file + fi + if install_env_file; then status_msg "Install environment file ..." "0" else diff --git a/tools/libs/core.sh b/tools/libs/core.sh index 53dddf8a..dde6c7f8 100755 --- a/tools/libs/core.sh +++ b/tools/libs/core.sh @@ -66,6 +66,16 @@ is_ubuntu_arm() { fi } +is_speederpad() { + if [[ "$(is_ubuntu_arm)" = "1" ]] && + [[ "$(uname -rm)" = "4.9.191 aarch64" ]] && + grep -q "Ubuntu 20.04." /etc/os-release; then + echo "1" + else + echo "0" + fi +} + test_load_module() { if modprobe -n "${1}" &> /dev/null; then echo 1 @@ -189,6 +199,15 @@ install_service_file() { grep -q "${BASE_USER}" "${target_dir}/crowsnest.service" || return 1 } +add_sleep_to_service_file() { + local service_file + service_file="/etc/systemd/system/crowsnest.service" + + if [[ -f "${service_file}" ]]; then + echo "ExecStartPre=/bin/sleep 5" >> "${service_file}" + fi +} + install_env_file() { local env_file env_target env_file="${PWD}/resources/crowsnest.env"