Skip to content

Commit 2d53cc4

Browse files
authored
chore: add startup workaround for SpeederPad (#203)
1 parent 549f7d4 commit 2d53cc4

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

crowsnest

+10-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if [ "$#" -eq 0 ]; then
4141
fi
4242

4343
## Parse Args
44-
while getopts ":vhc:d" arg; do
44+
while getopts ":vhc:s:d" arg; do
4545
case "${arg}" in
4646
v )
4747
echo -e "\ncrowsnest Version: $(self_version)\n"
@@ -55,6 +55,15 @@ while getopts ":vhc:d" arg; do
5555
check_cfg "${OPTARG}"
5656
export CROWSNEST_CFG="${OPTARG}"
5757
;;
58+
s )
59+
if [[ "$(awk '{print $1}' /proc/uptime | cut -d '.' -f 1)" -lt "120" ]]; then
60+
if [[ "${OPTARG}" ]]; then
61+
sleep "${OPTARG}"
62+
else
63+
sleep 5
64+
fi
65+
fi
66+
;;
5867
d )
5968
set -x
6069
;;

libs/messages.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function help_msg {
3434
echo -e "\t crowsnest [Options]"
3535
echo -e "\n\t\t-h Prints this help."
3636
echo -e "\n\t\t-v Prints Version of crowsnest."
37-
echo -e "\n\t\t-c </path/to/configfile>\n\t\t\tPath to your webcam.conf\n"
37+
echo -e "\n\t\t-c </path/to/configfile>\n\t\t\tPath to your webcam.conf"
38+
echo -e "\n\t\t-s <sleep_seconds>\n\t\t\tDelay start \(in seconds\) after boot\n"
3839
}
3940

4041
function deprecated_msg_1 {

tools/install.sh

+6
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ main() {
123123
status_msg "Install environment file ..." "1"
124124
fi
125125

126+
if [[ "$(is_speederpad)" = "1" ]]; then
127+
msg "\nSpeederpad detected!"
128+
msg "Add startup delay to environment file ...\n"
129+
add_sleep_to_crowsnest_env
130+
fi
131+
126132
if install_logrotate_conf; then
127133
status_msg "Install logrotate configuration ..." "0"
128134
else

tools/libs/core.sh

+18
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ is_ubuntu_arm() {
6666
fi
6767
}
6868

69+
is_speederpad() {
70+
if grep -q "Ubuntu 20.04." /etc/os-release &&
71+
[[ "$(uname -rm)" = "4.9.191 aarch64" ]]; then
72+
echo "1"
73+
else
74+
echo "0"
75+
fi
76+
}
77+
6978
test_load_module() {
7079
if modprobe -n "${1}" &> /dev/null; then
7180
echo 1
@@ -189,6 +198,15 @@ install_service_file() {
189198
grep -q "${BASE_USER}" "${target_dir}/crowsnest.service" || return 1
190199
}
191200

201+
add_sleep_to_crowsnest_env() {
202+
local service_file
203+
env_file="${CROWSNEST_ENV_PATH}/crowsnest.env"
204+
205+
if [[ -f "${env_file}" ]]; then
206+
sed -i 's/\(CROWSNEST_ARGS="[^"]*\)"/\1 -s"/' "${env_file}"
207+
fi
208+
}
209+
192210
install_env_file() {
193211
local env_file env_target
194212
env_file="${PWD}/resources/crowsnest.env"

0 commit comments

Comments
 (0)