Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(packaging): allow whitespace prefix in include directive detection #34

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ test *args='':
./.venv/bin/python3 -m robot.run --outputdir output {{args}} tests

build-test:
docker build -t {{IMAGE}} -f ./test-images/{{IMAGE_SRC}}/Dockerfile .
docker build --load -t {{IMAGE}} -f ./test-images/{{IMAGE_SRC}}/Dockerfile .
20 changes: 7 additions & 13 deletions src/packaging/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ fi
# In Yocto, monit looks at the /etc/monit.d/ directory
# instead of /etc/monit/conf.d/, so let's add the other directory to as well (for normalization)
if [ -f "$MONITRC" ]; then

# Some debian packages (maybe a Raspberry Pi APT mirror, monit 5.33.0) includes a buggy
# default monitrc configuration where the line 'include /etc/monit/conf.d/*' causes the service not to start.
# So delete the line as it will be replaced with a similar line afterwards
sed -i 's|^include /etc/monit/conf.d/\*$||g' "$MONITRC"
sed -i 's| *include /etc/monit/conf.d/.*$||g' "$MONITRC"

if ! grep -q "include /etc/monit/conf.d/" "$MONITRC"; then
echo "Adding /etc/monit/conf.d/ to the monit config ($MONITRC)" >&2
echo 'include /etc/monit/conf.d/' >> "$MONITRC"
echo 'include /etc/monit/conf.d/*.conf' >> "$MONITRC"
fi
fi

Expand All @@ -48,13 +44,11 @@ add_config_if_valid() {
name=$(basename "$CONF_FILE")
fi

if monit -c "$MONITRC" -t >/dev/null 2>&1; then
ln -sf "$CONF_FILE" "/etc/monit/conf.d/$name"
if ! monit -c "$MONITRC" -t; then
echo "Warning: Excluding $name as the monit version does not support the syntax used in it"
rm -f "/etc/monit/conf.d/$name"
return 1
fi
ln -sf "$CONF_FILE" "/etc/monit/conf.d/$name"
if ! monit -c "$MONITRC" -t; then
echo "Warning: Excluding $name as the monit version does not support the syntax used in it"
rm -f "/etc/monit/conf.d/$name"
return 1
fi
return 0
}
Expand Down
313 changes: 0 additions & 313 deletions tests/data/monitrc

This file was deleted.

7 changes: 3 additions & 4 deletions tests/monit.robot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Test Setup Test Setup
*** Test Cases ***

monit configuration is valid
Execute Command monit -t
Execute Command monit -c /etc/monit/monitrc -t

Reconnect on cloud connection loss (by stopping mosquitto)
Decrease monit intervals
Expand Down Expand Up @@ -48,11 +48,10 @@ Test Setup

Decrease monit intervals
[Documentation] Change default cycles to reduce the test execution times
Transfer To Device ${CURDIR}/data/monitrc /etc/monit/monitrc
Execute Command chown root:root /etc/monit/monitrc && chmod 700 /etc/monit/monitrc
Execute Command cmd=sed -i 's/set daemon .*/set daemon 5/g' /etc/monit/monitrc
Execute Command cmd=sed -i 's/every 120 cycles/every 5 cycles/g' /etc/monit/conf.d/tedge-monitoring.conf
Execute Command cmd=sed -i 's/if status != 0 for 10 cycles/if status != 0 for 2 cycles/g' /etc/monit/conf.d/tedge-monitoring.conf
Execute Command systemctl restart monit
Execute Command cmd=systemctl restart monit

Assert File Count
[Arguments] ${path} ${count}
Expand Down
Loading