diff --git a/docker-compose.yml b/docker-compose.yml index dbb553d..212ef17 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: vesselalert: image: ghcr.io/sdr-enthusiasts/docker-vesselalert @@ -31,6 +30,7 @@ services: - MIN_MSG_COUNT=10 - MAX_MSG_AGE=86400 - DEBUG= + - LANGUAGE=en_US tmpfs: - /tmp volumes: diff --git a/rootfs/etc/s6-overlay/scripts/70-set-strings b/rootfs/etc/s6-overlay/scripts/70-set-strings index 12e3dbd..204cd55 100755 --- a/rootfs/etc/s6-overlay/scripts/70-set-strings +++ b/rootfs/etc/s6-overlay/scripts/70-set-strings @@ -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 diff --git a/rootfs/etc/s6-overlay/scripts/cleanup b/rootfs/etc/s6-overlay/scripts/cleanup index f7f8664..4cfa6e6 100755 --- a/rootfs/etc/s6-overlay/scripts/cleanup +++ b/rootfs/etc/s6-overlay/scripts/cleanup @@ -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 ]] @@ -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" diff --git a/rootfs/etc/s6-overlay/scripts/notifier-framework b/rootfs/etc/s6-overlay/scripts/notifier-framework index 4523ed0..cdca4d5 100755 --- a/rootfs/etc/s6-overlay/scripts/notifier-framework +++ b/rootfs/etc/s6-overlay/scripts/notifier-framework @@ -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 diff --git a/rootfs/opt/data/discord.template-de_DE b/rootfs/opt/data/discord.template-de_DE index dfd9c5a..2d065ea 100644 --- a/rootfs/opt/data/discord.template-de_DE +++ b/rootfs/opt/data/discord.template-de_DE @@ -83,7 +83,7 @@ }, "footer": { - "text": "VesselAlert von kx1t" + "text": "VesselAlert © 2023, 2024 kx1t" }, "url": "https://www.vesselalert.com" ##SCRSHT-- diff --git a/rootfs/opt/data/discord.template-en_US b/rootfs/opt/data/discord.template-en_US index 593bfdd..08d7c70 100644 --- a/rootfs/opt/data/discord.template-en_US +++ b/rootfs/opt/data/discord.template-en_US @@ -83,7 +83,7 @@ }, "footer": { - "text": "VesselAlert by kx1t" + "text": "VesselAlert © 2023, 2024 kx1t" }, "url": "https://www.vesselalert.com" ##SCRSHT-- diff --git a/rootfs/opt/data/discord.template-es_ES b/rootfs/opt/data/discord.template-es_ES index c0024e0..c266ae4 100644 --- a/rootfs/opt/data/discord.template-es_ES +++ b/rootfs/opt/data/discord.template-es_ES @@ -83,7 +83,7 @@ }, "footer": { - "text": "VesselAlert by kx1t" + "text": "VesselAlert © 2023, 2024 kx1t" }, "url": "https://www.vesselalert.com" ##SCRSHT-- diff --git a/rootfs/opt/data/discord.template-fr_FR b/rootfs/opt/data/discord.template-fr_FR index 40b5a77..ef15f21 100644 --- a/rootfs/opt/data/discord.template-fr_FR +++ b/rootfs/opt/data/discord.template-fr_FR @@ -83,7 +83,7 @@ }, "footer": { - "text": "VesselAlert par kx1t" + "text": "VesselAlert © 2023, 2024 kx1t" }, "url": "https://www.vesselalert.com" ##SCRSHT-- diff --git a/rootfs/opt/data/discord.template-nl_NL b/rootfs/opt/data/discord.template-nl_NL index 5827435..ebc0192 100644 --- a/rootfs/opt/data/discord.template-nl_NL +++ b/rootfs/opt/data/discord.template-nl_NL @@ -83,7 +83,7 @@ }, "footer": { - "text": "VesselAlert by kx1t" + "text": "VesselAlert © 2023, 2024 kx1t" }, "url": "https://www.vesselalert.com" ##SCRSHT-- diff --git a/rootfs/opt/data/masto-l10n-en_US.db b/rootfs/opt/data/masto-l10n-en_US.db index f2170ac..fde639a 100644 --- a/rootfs/opt/data/masto-l10n-en_US.db +++ b/rootfs/opt/data/masto-l10n-en_US.db @@ -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" @@ -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" \ No newline at end of file +MASTO_TERM[DISTANCE]="Distance from receiver" diff --git a/rootfs/opt/data/masto-l10n-es_ES.db b/rootfs/opt/data/masto-l10n-es_ES.db index 163cde0..3495f92 100644 --- a/rootfs/opt/data/masto-l10n-es_ES.db +++ b/rootfs/opt/data/masto-l10n-es_ES.db @@ -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" \ No newline at end of file +MASTO_TERM[DISTANCE]="Distancia del receptor" diff --git a/rootfs/opt/data/shiptype-en_US.db b/rootfs/opt/data/shiptype-en_US.db index 3cd0887..30ecb76 100644 --- a/rootfs/opt/data/shiptype-en_US.db +++ b/rootfs/opt/data/shiptype-en_US.db @@ -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" diff --git a/rootfs/usr/share/vesselalert/send_mastodon b/rootfs/usr/share/vesselalert/send_mastodon index bedc499..0096d61 100755 --- a/rootfs/usr/share/vesselalert/send_mastodon +++ b/rootfs/usr/share/vesselalert/send_mastodon @@ -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")" @@ -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]})" @@ -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: @@ -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: