From 5106c7725cf623f27a9bb73347cfb01d71448a8b Mon Sep 17 00:00:00 2001 From: wiedehopf Date: Wed, 10 Apr 2024 20:32:02 +0200 Subject: [PATCH] better wait for collectd exit before graphs1090 writeback (#173) --- rootfs/etc/s6-overlay/scripts/collectd | 9 ++-- rootfs/tar1090-install.sh | 69 +------------------------- 2 files changed, 8 insertions(+), 70 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/collectd b/rootfs/etc/s6-overlay/scripts/collectd index 86a2250..99d3431 100755 --- a/rootfs/etc/s6-overlay/scripts/collectd +++ b/rootfs/etc/s6-overlay/scripts/collectd @@ -35,12 +35,15 @@ done /usr/sbin/collectd -t -T -f -C /etc/collectd/collectd.conf > /dev/null 2>&1 -trap 'echo "sending SIGTERM to collectd";pkill collectd' SIGTERM SIGINT SIGHUP SIGQUIT +# pkill -P $$ will only kill children of the script, not the script itself +trap 'pkill -P $$' SIGTERM SIGINT SIGHUP SIGQUIT +# for this scheme to work, the program is started in the background -# background execution + wait is necessary for trap to work -.- #shellcheck disable=SC2016 s6wrap --quiet --prepend=collectd --timestamps --args /usr/sbin/collectd -C /etc/collectd/collectd.conf -f & -wait || true + +# the first wait exits due to the signal which is trapped, the 2nd wait actually waits for collectd to exit +wait || wait || true diff --git a/rootfs/tar1090-install.sh b/rootfs/tar1090-install.sh index cec7d30..552601f 100755 --- a/rootfs/tar1090-install.sh +++ b/rootfs/tar1090-install.sh @@ -363,72 +363,7 @@ do done < <(echo "$instances") -if [[ $lighttpd == yes ]]; then - if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep -i duplicate >/dev/null; then - mv -f /etc/lighttpd/conf-available/89-dump1090-fa.conf.dpkg-dist /etc/lighttpd/conf-available/89-dump1090-fa.conf &>/dev/null || true - fi - - if ! grep -qs -E -e '^[^#]*"mod_alias"' /etc/lighttpd/lighttpd.conf /etc/lighttp/conf-enabled/* /etc/lighttpd/external.conf; then - echo 'server.modules += ( "mod_alias" )' > /etc/lighttpd/conf-available/07-mod_alias.conf - ln -s -f /etc/lighttpd/conf-available/07-mod_alias.conf /etc/lighttpd/conf-enabled/07-mod_alias.conf - else - rm -f /etc/lighttpd/conf-enabled/07-mod_alias.conf - fi - - rm -f /etc/lighttpd/conf-available/87-mod_setenv.conf /etc/lighttpd/conf-enabled/87-mod_setenv.conf - while read -r FILE; do - sed -i -e 's/^server.modules.*mod_setenv.*/#\0/' "$FILE" - sed -i -e 's/^server.stat-cache-engine.*disable.*/#\0/' "$FILE" - done < <(find /etc/lighttpd/conf-available/* | grep -v setenv) - - # add mod_setenv to lighttpd modules, check if it's one too much - echo 'server.modules += ( "mod_setenv" )' > /etc/lighttpd/conf-available/07-mod_setenv.conf - echo 'server.stat-cache-engine = "disable"' > /etc/lighttpd/conf-available/47-stat-cache.conf - - ln -s -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf - ln -s -f /etc/lighttpd/conf-available/47-stat-cache.conf /etc/lighttpd/conf-enabled/47-stat-cache.conf - - if (( $(cat /etc/lighttpd/conf-enabled/* | grep -c -E -e '^server.stat-cache-engine *\= *"disable")') > 1 )); then - rm -f /etc/lighttpd/conf-enabled/47-stat-cache.conf - fi - if (( $(cat /etc/lighttpd/conf-enabled/* | grep -c -E -e '^server.modules.?\+=.?\(.?"mod_setenv".?\)') > 1 )); then - rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf - fi - - if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep mod_setenv >/dev/null; then - rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf - fi - if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep stat-cache >/dev/null; then - rm -f /etc/lighttpd/conf-enabled/47-stat-cache.conf - fi - - #lighttpd -tt -f /etc/lighttpd/lighttpd.conf && echo success || true - if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep mod_setenv >/dev/null - then - rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf - fi - #lighttpd -tt -f /etc/lighttpd/lighttpd.conf && echo success || true - if ! lighttpd -tt -f /etc/lighttpd/lighttpd.conf &>/dev/null; then - echo ---------------- - echo "Lighttpd error, tar1090 will probably not work correctly:" - lighttpd -tt -f /etc/lighttpd/lighttpd.conf - fi - - if grep -qs -e '^compress.cache-dir' /etc/lighttpd/lighttpd.conf; then - echo ----- - echo "Disabling compress.cache-dir in /etc/lighttpd/lighttpd.conf due to often causing full disk issues as there is no automatic cleanup mechanism. Add a leading space to the compress.cache-dir line if you don't want tar1090 to mess with it in the future." - echo ----- - sed -i -e 's$^compress.cache-dir.*$#\0 # disabled by tar1090, often causes full disk due to not having a cleanup mechanism$' /etc/lighttpd/lighttpd.conf - elif ! grep -qs -e 'disabled by tar1090' /etc/lighttpd/lighttpd.conf; then - sed -i -e 's$^compress.cache-dir.*$# CAUTION, enabling cache-dir and filetype json will cause full disk when using tar1090\n\0$' /etc/lighttpd/lighttpd.conf - fi - if grep -qs -e '^deflate.cache-dir' /etc/lighttpd/lighttpd.conf; then - echo ----- - echo "Disabling deflate.cache-dir in /etc/lighttpd/lighttpd.conf due to often causing full disk issues as there is no automatic cleanup mechanism. Add a leading space to the deflate.cache-dir line if you don't want tar1090 to mess with it in the future." - echo ----- - sed -i -e 's$^deflate.cache-dir.*$#\0 # disabled by tar1090, often causes full disk due to not having a cleanup mechanism$' /etc/lighttpd/lighttpd.conf - elif ! grep -qs -e 'disabled by tar1090' /etc/lighttpd/lighttpd.conf; then - sed -i -e 's$^deflate.cache-dir.*$# CAUTION, enabling cache-dir and filetype json will cause full disk when using tar1090\n\0$' /etc/lighttpd/lighttpd.conf - fi +if [[ $lighttpd == yes ]] || [[ $nginx == yes ]]; then + true fi