diff --git a/crowsnest b/crowsnest index 1454fa0f..39669681 100755 --- a/crowsnest +++ b/crowsnest @@ -41,7 +41,7 @@ if [ "$#" -eq 0 ]; then fi ## Parse Args -while getopts ":vhc:d" arg; do +while getopts ":vhc:s:d" arg; do case "${arg}" in v ) echo -e "\ncrowsnest Version: $(self_version)\n" @@ -55,6 +55,15 @@ while getopts ":vhc:d" arg; do check_cfg "${OPTARG}" export CROWSNEST_CFG="${OPTARG}" ;; + s ) + if [[ "$(awk '{print $1}' /proc/uptime | cut -d '.' -f 1)" -lt "120" ]]; then + if [[ "${OPTARG}" ]]; then + sleep "${OPTARG}" + else + sleep 5 + fi + fi + ;; d ) set -x ;; diff --git a/libs/messages.sh b/libs/messages.sh index 0e9607b5..2fc725e2 100755 --- a/libs/messages.sh +++ b/libs/messages.sh @@ -34,7 +34,8 @@ function help_msg { echo -e "\t crowsnest [Options]" echo -e "\n\t\t-h Prints this help." echo -e "\n\t\t-v Prints Version of crowsnest." - echo -e "\n\t\t-c \n\t\t\tPath to your webcam.conf\n" + echo -e "\n\t\t-c \n\t\t\tPath to your webcam.conf" + echo -e "\n\t\t-s \n\t\t\tDelay start \(in seconds\) after boot\n" } function deprecated_msg_1 { diff --git a/tools/install.sh b/tools/install.sh index ce0c4f77..07c109b6 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -123,6 +123,12 @@ main() { status_msg "Install environment file ..." "1" fi + if [[ "$(is_speederpad)" = "1" ]]; then + msg "\nSpeederpad detected!" + msg "Add startup delay to environment file ...\n" + add_sleep_to_crowsnest_env + fi + if install_logrotate_conf; then status_msg "Install logrotate configuration ..." "0" else diff --git a/tools/libs/core.sh b/tools/libs/core.sh index 53dddf8a..c50ce442 100755 --- a/tools/libs/core.sh +++ b/tools/libs/core.sh @@ -66,6 +66,15 @@ is_ubuntu_arm() { fi } +is_speederpad() { + if grep -q "Ubuntu 20.04." /etc/os-release && + [[ "$(uname -rm)" = "4.9.191 aarch64" ]]; then + echo "1" + else + echo "0" + fi +} + test_load_module() { if modprobe -n "${1}" &> /dev/null; then echo 1 @@ -189,6 +198,15 @@ install_service_file() { grep -q "${BASE_USER}" "${target_dir}/crowsnest.service" || return 1 } +add_sleep_to_crowsnest_env() { + local service_file + env_file="${CROWSNEST_ENV_PATH}/crowsnest.env" + + if [[ -f "${env_file}" ]]; then + sed -i 's/\(CROWSNEST_ARGS="[^"]*\)"/\1 -s"/' "${env_file}" + fi +} + install_env_file() { local env_file env_target env_file="${PWD}/resources/crowsnest.env"