Skip to content

Commit

Permalink
Merge pull request #26 from sdr-enthusiasts/fixes
Browse files Browse the repository at this point in the history
Quiet logs, s6-wrap and fix mariadb internal startup
  • Loading branch information
fredclausen authored Nov 1, 2023
2 parents a99142c + 339f5d3 commit 7a3d784
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 153 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ ENV BASESTATIONPORT="30003" \
MYSQLPORT=3306 \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
TZ=UTC \
WEBUSER=flightairmap
WEBUSER=flightairmap \
QUIET_FAM=true

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand Down
184 changes: 58 additions & 126 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions rootfs/etc/s6-overlay/scripts/02-firstrun
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi
if [ -z "${MYSQLHOSTNAME}" ]; then
# Check if the flightairmap database exists
# Start mysqld without permissions
/usr/sbin/mysqld --skip-networking --console --log-error='' --skip-grant-tables --silent-startup &
/usr/sbin/mysqld --skip-networking --console --log-error='' --skip-grant-tables --silent-startup --user=root &
# Wait for mysqld to init
while :
do
Expand Down Expand Up @@ -84,7 +84,7 @@ if [ -z "${MYSQLHOSTNAME}" ]; then
MYSQLPASSWORD="$(pwgen -cns 30 999 | tail -1)"

mysqladmin shutdown
/usr/sbin/mysqld --console --log-error='' --silent-startup &
/usr/sbin/mysqld --console --log-error='' --silent-startup --user=root &
# Wait for mysqld to init
echo "Waiting for database..."
while :
Expand Down
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/scripts/03-settings
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/command/with-contenv /bin/bash
#shellcheck shell=bash

#shellcheck disable=SC1091
source /scripts/common

NOCOLOR='\033[0m'
Expand Down
10 changes: 7 additions & 3 deletions rootfs/etc/s6-overlay/scripts/daemon-acars
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/command/with-contenv sh
# shellcheck shell=sh
#!/command/with-contenv bash
# shellcheck shell=bash

s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-acars.php 2>&1 | awk '{print "[daemon-acars] " $0}'
# shellcheck disable=SC1091,SC2086,SC2016
source /scripts/common

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)
"${s6wrap[@]}" s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-acars.php
31 changes: 28 additions & 3 deletions rootfs/etc/s6-overlay/scripts/daemon-spotter
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
#!/command/with-contenv sh
# shellcheck shell=sh
#!/command/with-contenv bash
# shellcheck shell=bash

s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-spotter.php 2>&1 | awk '{print "[daemon-spotter] " $0}'
# shellcheck disable=SC1091,SC2086,SC2016
source /scripts/common

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)
if chk_enabled $QUIET_FAM; then
# shellcheck disable=SC1091,SC2086,SC2016
"${s6wrap[@]}" s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-spotter.php 2>&1 | \
stdbuf -oL awk '! /\\o\//' | \
stdbuf -oL awk '! /DATA : /' | \
stdbuf -oL awk '! /New flight.../' | \
stdbuf -oL awk '! /New aircraft hex/' | \
stdbuf -oL awk '! /in archive DB/' | \
stdbuf -oL awk '! /already in DB/' | \
stdbuf -oL awk '! /Getting schedule info/' | \
stdbuf -oL awk '! /old values and update latest data/' | \
stdbuf -oL awk '! /Check if aircraft is already in DB/' | \
stdbuf -oL awk '! /get arrival\/departure airport/' | \
stdbuf -oL awk '! /Deleting Live Spotter/' | \
stdbuf -oL awk '! /Calculated Speed/' | \
stdbuf -oL awk '! /Calculated Altitude/' | \
stdbuf -oL awk '! /Calculated Heading/' | \
stdbuf -oL awk '{print $0}'
else
# shellcheck disable=SC1091,SC2086,SC2016
"${s6wrap[@]}" s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-spotter.php
fi
13 changes: 9 additions & 4 deletions rootfs/etc/s6-overlay/scripts/mysql
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/command/with-contenv sh
# shellcheck shell=sh
#!/command/with-contenv bash
# shellcheck shell=bash

# shellcheck disable=SC1091,SC2086,SC2016
source /scripts/common

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)

# if using local database
if [ -z "${MYSQLHOSTNAME}" ]; then
/usr/sbin/mysqld --console --log-error='' 2>&1 | awk '{print "[mariadb] " $0}'
"${s6wrap[@]}" /usr/sbin/mysqld --console --log-error='' --user=root
else
sleep 3600
"${s6wrap[@]}" sleep 3600
fi
10 changes: 7 additions & 3 deletions rootfs/etc/s6-overlay/scripts/nginx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/command/with-contenv sh
# shellcheck shell=sh
#!/command/with-contenv bash
# shellcheck shell=bash

/usr/sbin/nginx 2>&1 | awk '{print "[nginx] " $0}'
# shellcheck disable=SC1091,SC2086,SC2016
source /scripts/common

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)
"${s6wrap[@]}" /usr/sbin/nginx -g 'daemon off;'
10 changes: 7 additions & 3 deletions rootfs/etc/s6-overlay/scripts/php-fpm
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/command/with-contenv sh
# shellcheck shell=sh
#!/command/with-contenv bash
# shellcheck shell=bash

/usr/sbin/php-fpm7.4 --nodaemonize 2>&1 | awk '{print "[php-fpm] " $0}'
# shellcheck disable=SC1091,SC2086,SC2016
source /scripts/common

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)
"${s6wrap[@]}" /usr/sbin/php-fpm7.4 --nodaemonize
13 changes: 9 additions & 4 deletions rootfs/etc/s6-overlay/scripts/socat
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/command/with-contenv sh
# shellcheck shell=sh
#!/command/with-contenv bash
# shellcheck shell=bash

# shellcheck disable=SC1091,SC2086,SC2016
source /scripts/common

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)

if [ -z "${BASESTATIONHOST}" ]; then
sleep 3600
"${s6wrap[@]}" sleep 3600
else
# shellcheck disable=SC2153
socat -d -d TCP-LISTEN:30003,fork TCP:"${BASESTATIONHOST}":"${BASESTATIONPORT}"
"${s6wrap[@]}" socat -d -d TCP-LISTEN:30003,fork TCP:"${BASESTATIONHOST}":"${BASESTATIONPORT}"
fi
12 changes: 8 additions & 4 deletions rootfs/etc/s6-overlay/scripts/update_db
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/command/with-contenv sh
# shellcheck shell=sh
#!/command/with-contenv bash
# shellcheck shell=bash

sleep 1h
s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/update_db.php 2>&1 | awk '{print "[update_db] " $0}'
# shellcheck disable=SC1091,SC2086,SC2016
source /scripts/common

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)
"${s6wrap[@]}" sleep 1h
"${s6wrap[@]}" s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/update_db.php

0 comments on commit 7a3d784

Please sign in to comment.