Skip to content

Commit

Permalink
pull in changes from main (#11)
Browse files Browse the repository at this point in the history
* Add aiscatcher link to notifications, slow down `masto_expire` runs to once every 12 hours, Dockerfile optimizations (#9)

* add `MASTODON_LINK_AISCATCHER` support

* Updated `MASTODON_LINK_AISCATCHER`with the link that @jvde-github advised to use

* run `masto_expire` less often

* bug fix

* bug fix

* logging improvement

* add AIS-Catcher link to Discord template

* optimize Dockerfile for size

* optimize Dockerfile

* bug fix

* fix

* Add Localization options for Mastodon and Discord notifications (#10)

* add `MASTODON_LINK_AISCATCHER` support

* Updated `MASTODON_LINK_AISCATCHER`with the link that @jvde-github advised to use

* run `masto_expire` less often

* bug fix

* bug fix

* logging improvement

* add AIS-Catcher link to Discord template

* optimize Dockerfile for size

* optimize Dockerfile

* bug fix

* fix

* initial add of localization of notifications

* bug fix

* bug fix

* updates to l10n

* minor fix

* update force_notify

* add placeholders for addl languages

* Update README.md

* Create discord.template-eses.db

* Rename discord.template-eses.db to discord.template-eses

* Create discord.template-dede

* Update discord.template-eses

* Update masto-l10n-eses.db

* Update shipstatus-eses.db

* Update shiptype-eses.db

* Update save_databases

* Update send_discord

* Update 10-container-init

* Update 40-check-ais-notify

* Update 60-check-mastodon

* Update 80-tropoalert-init

* Update ais-collect

* Update cleanup

* Update notifier-framework

* Update tropo-alert

* Update masto-l10n-nlnl.db

* Update masto-l10n-eses.db

* Update 10-container-init

* Update shipstatus-eses.db

* Update shiptype-frfr.db

Translations by Phil

* Update masto-l10n-frfr.db

Translations by Phil

* Update shipstatus-frfr.db

Translations by Phil

* Update discord.template-frfr

* Update discord.template-dede

* Update masto-l10n-dede.db

* Update shipstatus-dede.db

* Update shiptype-dede.db

* Update masto-l10n-frfr.db

* Update masto-l10n-frfr.db

* Update shiptype-frfr.db

* Update masto-l10n-frfr.db

* Rename discord.template-dede to discord.template-de_DE

* Rename discord.template-enus to discord.template-en_US

* Rename discord.template-eses to discord.template-es_ES

* Rename discord.template-frfr to discord.template-fr_FR

* Rename discord.template-nlnl to discord.template-nl_NL

* Rename masto-l10n-dede.db to masto-l10n-de_DE.db

* Rename masto-l10n-enus.db to masto-l10n-en_US.db

* Rename masto-l10n-eses.db to masto-l10n-es_ES.db

* Rename masto-l10n-frfr.db to masto-l10n-fr_FR.db

* Rename masto-l10n-nlnl.db to masto-l10n-nl_NL.db

* Rename shipstatus-dede.db to shipstatus-de_DE.db

* Rename shipstatus-enus.db to shipstatus-en_US.db

* Rename shipstatus-eses.db to shipstatus-es_ES.db

* Rename shipstatus-frfr.db to shipstatus-fr_FR.db

* Rename shipstatus-nlnl.db to shipstatus-nl_NL.db

* Rename shiptype-dede.db to shiptype-de_DE.db

* Rename shiptype-enus.db to shiptype-en_US.db

* Rename shiptype-eses.db to shiptype-es_ES.db

* Rename shiptype-frfr.db to shiptype-fr_FR.db

* Rename shiptype-nlnl.db to shiptype-nl_NL.db

* Update 10-container-init

* Update send_discord

* Update send_mastodon

* set Mastodon post language to value corresponding to `$LANGUAGE`

* Update send_mastodon

* Update README.md

* Update 70-set-strings

* Update 70-set-strings

* Update docker-compose.yml

* minor layout and text updates

* fix very small logging mislabeling

* minor cleanup

* cleanup

* minor bug fix

* l10n improvement
  • Loading branch information
kx1t authored Jun 14, 2024
1 parent b013cef commit a568449
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
vesselalert:
image: ghcr.io/sdr-enthusiasts/docker-vesselalert
Expand Down Expand Up @@ -31,6 +30,7 @@ services:
- MIN_MSG_COUNT=10
- MAX_MSG_AGE=86400
- DEBUG=
- LANGUAGE=en_US
tmpfs:
- /tmp
volumes:
Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/70-set-strings
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ source /scripts/common

"${s6wrap[@]}" echo "[INFO] Loading Vessel and Status Descriptions"

LANGUAGE="${LANGUAGE:-en_us}"
LANGUAGE="${LANGUAGE:-en_US}"

[[ -z "${VESSELDBFILE}" ]] && VESSELDBFILE="/data/vessel.db" || true

Expand Down
11 changes: 10 additions & 1 deletion rootfs/etc/s6-overlay/scripts/cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ DBLOCK_MAXWAIT=600 # don't wait more than 600 secs for the dblock to be remov
[[ ! -f /run/.last_mastodon_cleanup ]] && date +%s > /run/.last_mastodon_cleanup || true

"${s6wrap[@]}" echo "[INFO] Starting Cleanup"
[[ -f $VESSELDBLOCK ]] && "${s6wrap[@]}" echo "[INFO] Waiting for vessel.db to become unlocked..."
if [[ -f $VESSELDBLOCK ]]; then
"${s6wrap[@]}" echo "[INFO] Waiting for vessel.db to become unlocked..."
is_locked=true
else
is_locked=false
fi

lockstarttime="$(date +%s)"
while [[ -f $VESSELDBLOCK ]]
Expand All @@ -55,6 +60,10 @@ do
fi
done

if [[ "$is_locked" == true ]]; then
"${s6wrap[@]}" echo "[INFO] Vessel.db is now unlocked - continuing cleanup"
fi

# Now lock the process for myself:
touch "$VESSELDBLOCK"

Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/notifier-framework
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

source /scripts/common

"${s6wrap[@]}" echo "[INFO] Starting cleanup run"
"${s6wrap[@]}" echo "[INFO] Notification Framework run"

renice -n 10 -p $$ >/dev/null 2>&1

Expand Down
2 changes: 1 addition & 1 deletion rootfs/opt/data/discord.template-de_DE
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
"footer":
{
"text": "VesselAlert von kx1t"
"text": "VesselAlert © 2023, 2024 kx1t"
},
"url": "https://www.vesselalert.com"
##SCRSHT--
Expand Down
2 changes: 1 addition & 1 deletion rootfs/opt/data/discord.template-en_US
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
"footer":
{
"text": "VesselAlert by kx1t"
"text": "VesselAlert © 2023, 2024 kx1t"
},
"url": "https://www.vesselalert.com"
##SCRSHT--
Expand Down
2 changes: 1 addition & 1 deletion rootfs/opt/data/discord.template-es_ES
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
"footer":
{
"text": "VesselAlert by kx1t"
"text": "VesselAlert © 2023, 2024 kx1t"
},
"url": "https://www.vesselalert.com"
##SCRSHT--
Expand Down
2 changes: 1 addition & 1 deletion rootfs/opt/data/discord.template-fr_FR
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
"footer":
{
"text": "VesselAlert par kx1t"
"text": "VesselAlert © 2023, 2024 kx1t"
},
"url": "https://www.vesselalert.com"
##SCRSHT--
Expand Down
2 changes: 1 addition & 1 deletion rootfs/opt/data/discord.template-nl_NL
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
"footer":
{
"text": "VesselAlert by kx1t"
"text": "VesselAlert © 2023, 2024 kx1t"
},
"url": "https://www.vesselalert.com"
##SCRSHT--
Expand Down
4 changes: 2 additions & 2 deletions rootfs/opt/data/masto-l10n-en_US.db
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MASTO_TERM[SHIP]="Ship"
MASTO_TERM[NEW]="#NEW #FIRST Observation"
MASTO_TERM[ONTHEMOVE]="#OnTheMove"
MASTO_TERM[MOVING]="on the move"
MASTO_TERM[SHIPNAME]="Name"
MASTO_TERM[SHIPNAME]="Vessel Name"
MASTO_TERM[CALLSIGN]="Callsign"
MASTO_TERM[SHIPTYPE]="Type"
MASTO_TERM[FLAG]="Flag"
Expand All @@ -37,4 +37,4 @@ MASTO_TERM[ISSEENON]="is seen on"
MASTO_TERM[AGAIN]="Again:"
MASTO_TERM[NEW2]="New:"
MASTO_TERM[DIST_SINCE_LAST]="moved %.1f nm since last notification"
MASTO_TERM[DISTANCE]="Distance from receiver"
MASTO_TERM[DISTANCE]="Distance from receiver"
2 changes: 1 addition & 1 deletion rootfs/opt/data/masto-l10n-es_ES.db
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ MASTO_TERM[ISSEENON]="fue visto a la hora"
MASTO_TERM[AGAIN]="Nuevamente:"
MASTO_TERM[NEW2]="Nuevo:"
MASTO_TERM[DIST_SINCE_LAST]="se ha transladado %.1f nm desde la última notificación"
MASTO_TERM[DISTANCE]="Distancia del receptor"
MASTO_TERM[DISTANCE]="Distancia del receptor"
2 changes: 1 addition & 1 deletion rootfs/opt/data/shiptype-en_US.db
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SHIPTYPE[33]="#Dredging"
SHIPTYPE[34]="#Diving"
SHIPTYPE[35]="#Military #Mil #Navy"
SHIPTYPE[36]="#Sailing"
SHIPTYPE[37]="#Pleasure Craft"
SHIPTYPE[37]="#Pleasure_Craft"
# SHIPTYPE[38]="Reserved"
# SHIPTYPE[39]="Reserved"
SHIPTYPE[40]="#HiSpeed"
Expand Down
55 changes: 26 additions & 29 deletions rootfs/usr/share/vesselalert/send_mastodon
Original file line number Diff line number Diff line change
Expand Up @@ -78,40 +78,37 @@ unset mast_str
if [[ -n "$notify_tropo" ]]; then
mast_str="#${MASTO_TERM[TROPOMAXDIST]} = $(printf "%.1f" "${VESSELS[$1:distance]}") nm\n"
fi
mast_str+="#VesselAlert #Ship #Vessel #AIS"
if [[ "${MASTO_TERM[SHIP]}" != "Ship" ]]; then mast_str+=" #${MASTO_TERM[SHIP]}"; fi
[[ -z "${VESSELS[$1:notification:last]}" ]] && mast_str+=" ${MASTO_TERM[NEW]}"
#shellcheck disable=SC2154
[[ "${notify_distance}" == "true" ]] && mast_str+=" #${MASTO_TERM[ONTHEMOVE]}"

mast_str+="#VesselAlert"
[[ "${MASTO_TERM[SHIP]}" != "Ship" ]] && mast_str+=" #${MASTO_TERM[SHIP]}" || true
[[ -z "${VESSELS[$1:notification:last]}" ]] && mast_str+=" ${MASTO_TERM[NEW]}" || true
[[ "${notify_distance}" == "true" ]] && mast_str+=" #${MASTO_TERM[ONTHEMOVE]}" || true
mast_str+="\n"
[[ -n "${VESSELS[$1:shipname]}" ]] && mast_str+="${MASTO_TERM[SHIPNAME]}: #${VESSELS[$1:shipname]} "
[[ -n "${VESSELS[$1:mmsi]}" ]] && mast_str+="#MMSI: #${VESSELS[$1:mmsi]}\n"
[[ -n "${VESSELS[$1:callsign]}" ]] && mast_str+="${MASTO_TERM[CALLSIGN]}: #${VESSELS[$1:callsign]} "
[[ -n "${VESSELS[$1:shiptype]}" ]] && [[ -n "${SHIPTYPE[${VESSELS[$1:shiptype]}]}" ]] && mast_str+="${MASTO_TERM[SHIPTYPE]}: ${SHIPTYPE[${VESSELS[$1:shiptype]}]}"
[[ -n "${VESSELS[$1:shipname]}" ]] && mast_str+="${MASTO_TERM[SHIPNAME]}: #${VESSELS[$1:shipname]} " || true
[[ -n "${VESSELS[$1:mmsi]}" ]] && mast_str+="#MMSI: #${VESSELS[$1:mmsi]}\n" || true
[[ -n "${VESSELS[$1:callsign]}" ]] && mast_str+="${MASTO_TERM[CALLSIGN]}: #${VESSELS[$1:callsign]} " || true
[[ -n "${VESSELS[$1:shiptype]}" ]] && [[ -n "${SHIPTYPE[${VESSELS[$1:shiptype]}]}" ]] && mast_str+="${MASTO_TERM[SHIPTYPE]}: ${SHIPTYPE[${VESSELS[$1:shiptype]}]}" || true
mast_str+="\n"

[[ -n "${VESSELS[$1:country]}" ]] && mast_str+="#${MASTO_TERM[FLAG]}: #${COUNTRY[${VESSELS[$1:country]}]} "
[[ -n "${VESSELS[$1:country]}" ]] && mast_str+="#${MASTO_TERM[FLAG]}: #${COUNTRY[${VESSELS[$1:country]}]} " || true
mast_str+="${MASTO_TERM[MSGS_RECVD]}: ${VESSELS[$1:count]}\n"
mast_str+="${MASTO_TERM[SEEN_ON]}: $(date -d @$(( $(date +%s) - ${VESSELS[$1:last_signal]} )) +"%d-%b-%Y %H:%M:%S %Z")\n"

[[ -n "${VESSELS[$1:status]}" ]] && [[ -n "${SHIPSTATUS[${VESSELS[$1:status]}]}" ]] && mast_str+="${MASTO_TERM[STATUS]}: ${SHIPSTATUS[${VESSELS[$1:status]}]}\n"
[[ -n "${VESSELS[$1:speed]}" ]] && [[ "${VESSELS[$1:speed]}" != "0" ]] && [[ "${VESSELS[$1:speed]}" != "null" ]] && mast_str+="${MASTO_TERM[SPEED]}: $(printf "%.1f" "${VESSELS[$1:speed]}") kts "
[[ -n "${VESSELS[$1:heading]}" ]] && [[ "${VESSELS[$1:heading]}" != "0" ]] && [[ "${VESSELS[$1:heading]}" != "null" ]]&& mast_str+="${MASTO_TERM[HEADING]}: ${VESSELS[$1:heading]} deg "
[[ -n "${VESSELS[$1:destination]}" ]] && mast_str+="${MASTO_TERM[DESTINATION]}: ${VESSELS[$1:destination]}\n"

if [[ -n "${VESSELS[$1:lat]}" ]] && [[ -n "${VESSELS[$1:lon]}" ]] && [[ -n "$LAT" ]] && [[ -n "$LON" ]]; then
distance="$(bc -l <<< "scale=1; $(distance "${VESSELS[$1:lat]}" "${VESSELS[$1:lon]}" "$LAT" "$LON") / 1")"
mast_str+="${MASTO_TERM[DISTANCE]}: $distance nm\n"
fi

[[ -n "${VESSELS[$1:status]}" ]] && [[ -n "${SHIPSTATUS[${VESSELS[$1:status]}]}" ]] && mast_str+="${MASTO_TERM[STATUS]}: ${SHIPSTATUS[${VESSELS[$1:status]}]}\n" || true
[[ -n "${VESSELS[$1:speed]}" ]] && [[ "${VESSELS[$1:speed]}" != "0" ]] && [[ "${VESSELS[$1:speed]}" != "null" ]] && mast_str+="${MASTO_TERM[SPEED]}: $(printf "%.1f" "${VESSELS[$1:speed]}") kts " || true
[[ -n "${VESSELS[$1:heading]}" ]] && [[ "${VESSELS[$1:heading]}" != "0" ]] && [[ "${VESSELS[$1:heading]}" != "null" ]] && mast_str+="${MASTO_TERM[HEADING]}: ${VESSELS[$1:heading]} deg " || true
[[ -n "${VESSELS[$1:destination]}" ]] && mast_str+="${MASTO_TERM[DESTINATION]}: ${VESSELS[$1:destination]}\n" || true
mast_str+="\n"

mast_str+="${MASTO_TERM[SIGNAL]} #RSSI: $(printf "%.1f dBFS" "${VESSELS[$1:level]}")\n"
[[ -n "${links}" ]] && mast_str+="${links}\n"
[[ -n "${NOTIFICATION_MAPURL}" ]] && [[ "${NOTIFICATION_MAPURL:0:4}" != "http" ]] && mast_str+="\n${MASTO_TERM[LOCATION]}: ${AIS_URL}?mmsi=${VESSELS[$1:mmsi]}"
[[ -n "${NOTIFICATION_MAPURL}" ]] && [[ "${NOTIFICATION_MAPURL:0:4}" == "http" ]] && mast_str+="\n${MASTO_TERM[LOCATION]}: ${NOTIFICATION_MAPURL}?mmsi=${VESSELS[$1:mmsi]}"
[[ -n "${links}" ]] && mast_str+="${links}\n" || true
[[ -n "${NOTIFICATION_MAPURL}" ]] && [[ "${NOTIFICATION_MAPURL:0:4}" != "http" ]] && mast_str+="\n${MASTO_TERM[LOCATION]}: ${AIS_URL}?mmsi=${VESSELS[$1:mmsi]}" || true
[[ -n "${NOTIFICATION_MAPURL}" ]] && [[ "${NOTIFICATION_MAPURL:0:4}" == "http" ]] && mast_str+="\n${MASTO_TERM[LOCATION]}: ${NOTIFICATION_MAPURL}?mmsi=${VESSELS[$1:mmsi]}" || true

[[ -n "$MASTODON_CUSTOM_FIELD" ]] && mast_str+="\n$MASTODON_CUSTOM_FIELD" || true

[[ -n "$MASTODON_CUSTOM_FIELD" ]] && mast_str+="\n$MASTODON_CUSTOM_FIELD"
mast_str+="\n#Ship #Vessel #AIS"
mast_str+="\n#VesselAlert © 2023, 2024 kx1t"

#shellcheck disable=SC2001
mast_str="$(sed -e 's|\\n|\n|g' <<< "$mast_str")"
Expand All @@ -123,7 +120,7 @@ if [[ -f "$IMAGECACHE/${VESSELS[$1:mmsi]}.jpg" ]]
then
response="$(curl -s -H "Authorization: Bearer ${MASTODON_ACCESS_TOKEN}" -H "Content-Type: multipart/form-data" -X POST "${MASTODON_SERVER}/api/v1/media" --form file="@$IMAGECACHE/${VESSELS[$1:mmsi]}.jpg")"
[[ "$(jq '.id' <<< "${response}" | xargs)" != "null" ]] && mast_id="$(jq '.id' <<< "${response}" | xargs)" || mast_id=""
[[ -n "${mast_id}" ]] && media_id="-F media_ids[]=${mast_id} "
[[ -n "${mast_id}" ]] && media_id="-F media_ids[]=${mast_id} " || true
"${s6wrap[@]}" echo "[INFO] image for ${VESSELS[$1:mmsi]} (${VESSELS[$1:shipname]}) uploaded to Mastodon"
else
"${s6wrap[@]}" echo "[WARNING] no image available for ${VESSELS[$1:mmsi]} (${VESSELS[$1:shipname]})"
Expand All @@ -134,7 +131,7 @@ if [[ -f "${IMAGECACHE}/screenshots/${VESSELS[$1:mmsi]}.jpg" ]]
then
response="$(curl -s -H "Authorization: Bearer ${MASTODON_ACCESS_TOKEN}" -H "Content-Type: multipart/form-data" -X POST "${MASTODON_SERVER}/api/v1/media" --form file="@${IMAGECACHE}/screenshots/${VESSELS[$1:mmsi]}.jpg")"
[[ "$(jq '.id' <<< "${response}" | xargs)" != "null" ]] && mast_id="$(jq '.id' <<< "${response}" | xargs)" || mast_id=""
[[ -n "${mast_id}" ]] && media_id+="-F media_ids[]=${mast_id} "
[[ -n "${mast_id}" ]] && media_id+="-F media_ids[]=${mast_id} " || true
fi

# Now send the toot:
Expand All @@ -145,10 +142,10 @@ response="$(curl -H "Authorization: Bearer ${MASTODON_ACCESS_TOKEN}" -s "${MASTO
if [[ "$(jq '.error' <<< "${response}"|xargs)" == "null" ]]
then
"${s6wrap[@]}" echo "[INFO] Mastodon post for ${VESSELS[$1:mmsi]} (${VESSELS[$1:shipname]}) generated successfully with visibility ${MASTODON_POST_VISIBILITY}. Mastodon post available at: $(jq '.url' <<< "${response}"|xargs). "
[[ -z "${VESSELS[$1:notification:last]}" ]] && "${s6wrap[@]}" echo -n "[INFO] #NEW "
[[ -z "${VESSELS[$1:notification:last]}" ]] && "${s6wrap[@]}" echo -n "[INFO] #NEW " || true
#shellcheck disable=SC2154
[[ "${notify_timing}" == "true" ]] && [[ -n "${VESSELS[$1:notification:last]}" ]] && echo -n "#OLD "
[[ "${notify_distance}" == "true" ]] && echo -n "#ONTHEMOVE"
[[ "${notify_timing}" == "true" ]] && [[ -n "${VESSELS[$1:notification:last]}" ]] && echo -n "#OLD " || true
[[ "${notify_distance}" == "true" ]] && echo -n "#ONTHEMOVE" || true
echo ""

# Update the Assoc Array with the latest values:
Expand Down

0 comments on commit a568449

Please sign in to comment.