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

Add Localization options for Mastodon and Discord notifications #10

Merged
merged 80 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
d9f3c95
add `MASTODON_LINK_AISCATCHER` support
kx1t Jun 12, 2024
84af104
Updated `MASTODON_LINK_AISCATCHER`with the link that @jvde-github adv…
kx1t Jun 12, 2024
933d32d
run `masto_expire` less often
kx1t Jun 12, 2024
d2a0830
bug fix
kx1t Jun 12, 2024
e38a84c
bug fix
kx1t Jun 12, 2024
10cac71
logging improvement
kx1t Jun 12, 2024
ecb5363
add AIS-Catcher link to Discord template
kx1t Jun 12, 2024
00dba25
optimize Dockerfile for size
kx1t Jun 12, 2024
7a74481
optimize Dockerfile
kx1t Jun 12, 2024
9399b63
bug fix
kx1t Jun 12, 2024
39819cd
fix
kx1t Jun 12, 2024
e9e1d7d
initial add of localization of notifications
kx1t Jun 12, 2024
4103ce0
bug fix
kx1t Jun 12, 2024
ab373d8
bug fix
kx1t Jun 12, 2024
7e62ad4
updates to l10n
kx1t Jun 12, 2024
d0c9f5c
minor fix
kx1t Jun 12, 2024
87fe633
update force_notify
kx1t Jun 12, 2024
5db187c
add placeholders for addl languages
kx1t Jun 12, 2024
e26d8b0
Update README.md
kx1t Jun 12, 2024
d621be3
Create discord.template-eses.db
kx1t Jun 12, 2024
f7cd4c5
Rename discord.template-eses.db to discord.template-eses
kx1t Jun 12, 2024
0af3cf6
Create discord.template-dede
kx1t Jun 12, 2024
e8fce3e
Update discord.template-eses
kx1t Jun 12, 2024
dccb397
Update masto-l10n-eses.db
kx1t Jun 12, 2024
8b6d0c4
Update shipstatus-eses.db
kx1t Jun 12, 2024
f1c43a6
Update shiptype-eses.db
kx1t Jun 12, 2024
8a99b3d
Update save_databases
kx1t Jun 12, 2024
a5ee85b
Update send_discord
kx1t Jun 12, 2024
42de63b
Update 10-container-init
kx1t Jun 12, 2024
44fcf99
Update 40-check-ais-notify
kx1t Jun 12, 2024
7b2e7e7
Update 60-check-mastodon
kx1t Jun 12, 2024
17d0939
Update 80-tropoalert-init
kx1t Jun 12, 2024
9c533b1
Update ais-collect
kx1t Jun 12, 2024
afdeae3
Update cleanup
kx1t Jun 12, 2024
963be4d
Update notifier-framework
kx1t Jun 12, 2024
5458fa0
Update tropo-alert
kx1t Jun 12, 2024
0340718
Update masto-l10n-nlnl.db
kx1t Jun 12, 2024
5032b84
Update masto-l10n-eses.db
kx1t Jun 12, 2024
788cb8e
Update 10-container-init
kx1t Jun 12, 2024
d1c38a7
Update shipstatus-eses.db
kx1t Jun 12, 2024
aae51cf
Update shiptype-frfr.db
kx1t Jun 13, 2024
7da374a
Update masto-l10n-frfr.db
kx1t Jun 13, 2024
b16b59e
Update shipstatus-frfr.db
kx1t Jun 13, 2024
20a7356
Update discord.template-frfr
kx1t Jun 13, 2024
903a0e0
Update discord.template-dede
kx1t Jun 13, 2024
20fd3d7
Update masto-l10n-dede.db
kx1t Jun 13, 2024
a8f1d49
Update shipstatus-dede.db
kx1t Jun 13, 2024
99731c8
Update shiptype-dede.db
kx1t Jun 13, 2024
4ff76a6
Update masto-l10n-frfr.db
kx1t Jun 13, 2024
1b68b41
Update masto-l10n-frfr.db
kx1t Jun 13, 2024
a68ec2e
Update shiptype-frfr.db
kx1t Jun 13, 2024
0ca4636
Update masto-l10n-frfr.db
kx1t Jun 13, 2024
8895f4a
Rename discord.template-dede to discord.template-de_DE
kx1t Jun 13, 2024
3f5f7e5
Rename discord.template-enus to discord.template-en_US
kx1t Jun 13, 2024
b5ab6b8
Rename discord.template-eses to discord.template-es_ES
kx1t Jun 13, 2024
e1fcd50
Rename discord.template-frfr to discord.template-fr_FR
kx1t Jun 13, 2024
e2303a8
Rename discord.template-nlnl to discord.template-nl_NL
kx1t Jun 13, 2024
ea98234
Rename masto-l10n-dede.db to masto-l10n-de_DE.db
kx1t Jun 13, 2024
c3c6891
Rename masto-l10n-enus.db to masto-l10n-en_US.db
kx1t Jun 13, 2024
1422969
Rename masto-l10n-eses.db to masto-l10n-es_ES.db
kx1t Jun 13, 2024
74152be
Rename masto-l10n-frfr.db to masto-l10n-fr_FR.db
kx1t Jun 13, 2024
fc7a87c
Rename masto-l10n-nlnl.db to masto-l10n-nl_NL.db
kx1t Jun 13, 2024
4c4ab6a
Rename shipstatus-dede.db to shipstatus-de_DE.db
kx1t Jun 13, 2024
f68604b
Rename shipstatus-enus.db to shipstatus-en_US.db
kx1t Jun 13, 2024
00047e6
Rename shipstatus-eses.db to shipstatus-es_ES.db
kx1t Jun 13, 2024
b30d1f6
Rename shipstatus-frfr.db to shipstatus-fr_FR.db
kx1t Jun 13, 2024
9323d35
Rename shipstatus-nlnl.db to shipstatus-nl_NL.db
kx1t Jun 13, 2024
c372763
Rename shiptype-dede.db to shiptype-de_DE.db
kx1t Jun 13, 2024
388f735
Rename shiptype-enus.db to shiptype-en_US.db
kx1t Jun 13, 2024
804338c
Rename shiptype-eses.db to shiptype-es_ES.db
kx1t Jun 13, 2024
3e0095f
Rename shiptype-frfr.db to shiptype-fr_FR.db
kx1t Jun 13, 2024
411f537
Rename shiptype-nlnl.db to shiptype-nl_NL.db
kx1t Jun 13, 2024
ee5f04c
Update 10-container-init
kx1t Jun 13, 2024
baebabb
Update send_discord
kx1t Jun 13, 2024
e586f77
Update send_mastodon
kx1t Jun 13, 2024
26848e6
set Mastodon post language to value corresponding to `$LANGUAGE`
kx1t Jun 13, 2024
fac2e87
Update send_mastodon
kx1t Jun 13, 2024
36019f1
Update README.md
kx1t Jun 13, 2024
d9e365a
Update 70-set-strings
kx1t Jun 13, 2024
451ea6e
Update 70-set-strings
kx1t Jun 13, 2024
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
47 changes: 23 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base AS build

RUN set -x && \
SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"]
RUN \
--mount=type=bind,source=./,target=/ghrepo/ \
apt-get update -y && \
apt-get install -q -o Dpkg::Options::="--force-confnew" -y \
git gcc && \
mkdir -p /src && \
cd /src && \
cp -f /ghrepo/src/distance.c . && \
gcc -static distance.c -o distance -lm -Ofast && \
# Add Container Version:
cd / && \
git clone --depth=1 --single-branch https://github.com/sdr-enthusiasts/docker-vesselalert.git && \
cd /docker-vesselalert/src && \
gcc -static distance.c -o distance -lm -Ofast
branch="##BRANCH##" && \
[[ "${branch:0:1}" == "#" ]] && branch="main" || true && \
git clone --depth=1 -b $branch https://github.com/sdr-enthusiasts/docker-vesselalert.git && \
cd docker-vesselalert && \
echo "$(TZ=UTC date +%Y%m%d-%H%M%S)_$(git rev-parse --short HEAD)_$(git branch --show-current)" > /.CONTAINER_VERSION

FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base

Expand All @@ -16,16 +25,15 @@ ENV MASTODON_MIN_DIST=0
ENV PATH="$PATH:/usr/share/vesselalert:/tools"
LABEL org.opencontainers.image.source = "https://github.com/sdr-enthusiasts/docker-vesselalert"

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

RUN set -x && \
#
SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"]
# hadolint ignore=DL3008,SC2086,SC2039,SC2068
RUN \
--mount=type=bind,from=build,source=/,target=/build \
# define required packages
TEMP_PACKAGES=() && \
KEPT_PACKAGES=() && \
KEPT_PACKAGES+=(bc) && \
KEPT_PACKAGES+=(jq) && \
KEPT_PACKAGES+=(git) && \
KEPT_PACKAGES+=(nano) && \
KEPT_PACKAGES+=(curl) && \
#
Expand All @@ -35,6 +43,10 @@ RUN set -x && \
"${KEPT_PACKAGES[@]}" \
"${TEMP_PACKAGES[@]}" \
&& \
# add files from the build container:
mkdir -p /usr/share/vesselalert && \
cp -f /build/src/distance /usr/share/vesselalert/distance && \
cp -f /build/.CONTAINER_VERSION /.CONTAINER_VERSION && \
# Do some other stuff
echo "alias dir=\"ls -alsv\"" >> /root/.bashrc && \
echo "alias nano=\"nano -l\"" >> /root/.bashrc && \
Expand All @@ -43,26 +55,13 @@ RUN set -x && \
if [[ "${#TEMP_PACKAGES[@]}" -gt 0 ]]; then \
apt-get remove -y "${TEMP_PACKAGES[@]}"; \
fi && \
apt-get autoremove -y && \
apt-get autoremove -q -o APT::Autoremove::RecommendsImportant=0 -o APT::Autoremove::SuggestsImportant=0 -y && \
apt-get clean -q -y && \
#
# set CONTAINER_VERSION:
rm -rf /src/* /tmp/* /var/lib/apt/lists/*

COPY rootfs/ /

COPY --from=build /docker-vesselalert/src/distance /usr/share/vesselalert/distance

# Add Container Version
RUN set -x && \
pushd /tmp && \
branch="##BRANCH##" && \
[[ "${branch:0:1}" == "#" ]] && branch="main" || true && \
git clone --depth=1 -b $branch https://github.com/sdr-enthusiasts/docker-vesselalert.git && \
cd docker-vesselalert && \
echo "$(TZ=UTC date +%Y%m%d-%H%M%S)_$(git rev-parse --short HEAD)_$(git branch --show-current)" > /.CONTAINER_VERSION && \
popd && \
rm -rf /tmp/*


# Add healthcheck
# HEALTHCHECK --start-period=60s --interval=600s --timeout=60s CMD /healthcheck/healthcheck.sh
56 changes: 41 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

[![Discord](https://img.shields.io/discord/734090820684349521)](https://discord.gg/sTf9uYF)

## Table of Contents

- [sdr-enthusiasts/docker-vesselalert](#sdr-enthusiastsdocker-vesselalert)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Multi Architecture Support](#multi-architecture-support)
- [Configuring Mastodon: create an application and get an `access token`](#configuring-mastodon-create-an-application-and-get-an-access-token)
- [Up-and-Running with Docker Compose](#up-and-running-with-docker-compose)
- [Runtime Environment Variables](#runtime-environment-variables)
- [General parameters](#general-parameters)
- [Tropo Alert parameters](#tropo-alert-parameters)
- [Mastodon notifications related parameters](#mastodon-notifications-related-parameters)
- [Discord notifications related parameters](#discord-notifications-related-parameters)
- [Expert Parameters (only change/set if you know what you're doing)](#expert-parameters-only-changeset-if-you-know-what-youre-doing)
- [Adding screenshots to your notifications](#adding-screenshots-to-your-notifications)
- [Logging](#logging)
- [Modifications of Ship Status and Ship Type descriptions](#modifications-of-ship-status-and-ship-type-descriptions)
- [Acknowledgements](#acknowledgements)
- [Getting Help](#getting-help)
- [Summary of License Terms](#summary-of-license-terms)
- [VesselAlert](#vesselalert)
- [Tropo Alert Feature](#tropo-alert-feature)

## Introduction

Docker container providing social media notification for Vessels that are received with @jvde-github's excellent [AIS-Catcher](https://github.com/jvde-github/AIS-catcher) package.
Expand All @@ -13,17 +37,17 @@ Currently, posts to [Mastodon](https://airwaves.social) and Discord are supporte

We expect you to have the following:

* An installed and working version of the [AIS-Catcher](https://github.com/jvde-github/AIS-catcher) package with the Web Functionality installed and accessible to this container. This means that you need to be using [v0.42](https://github.com/jvde-github/AIS-catcher/releases/tag/v0.42) or later, and that you must configure the Web Server as per the [documentation](https://github.com/jvde-github/AIS-catcher/blob/main/README.md). We advise to put the Web Server on a fixed and known port number as you will have to configure a link to this for VesselAlert to work. Note -- the version of AIS-Catcher in the official ShipXplorer distribution is too old. You must install a newer version (or switch to the [containerized version](https://github.com/sdr-enthusiasts/docker-shipxplorer), which includes an up-to-date version of AIS-Catcher).
* Docker must be installed on your system. If you don't know how to do that, please read [here](https://github.com/sdr-enthusiasts/docker-install).
* Some basic knowledge on how to use Linux and how to configure docker containers with `docker-compose`.
- An installed and working version of the [AIS-Catcher](https://github.com/jvde-github/AIS-catcher) package with the Web Functionality installed and accessible to this container. This means that you need to be using [v0.42](https://github.com/jvde-github/AIS-catcher/releases/tag/v0.42) or later, and that you must configure the Web Server as per the [documentation](https://github.com/jvde-github/AIS-catcher/blob/main/README.md). We advise to put the Web Server on a fixed and known port number as you will have to configure a link to this for VesselAlert to work. Note -- the version of AIS-Catcher in the official ShipXplorer distribution is too old. You must install a newer version (or switch to the [containerized version](https://github.com/sdr-enthusiasts/docker-shipxplorer), which includes an up-to-date version of AIS-Catcher).
- Docker must be installed on your system. If you don't know how to do that, please read [here](https://github.com/sdr-enthusiasts/docker-install).
- Some basic knowledge on how to use Linux and how to configure docker containers with `docker-compose`.

## Multi Architecture Support

Currently, this image should pull and run on the following architectures:

* `arm32v7`, `armv7l`, `armhf`: ARMv7 32-bit (Odroid HC1/HC2/XU4, RPi 2/3/4 32-bit)
* `arm64`, `aarch64`: ARMv8 64-bit (RPi 4 64-bit OSes)
* `amd64`, `x86_64`: X86 64-bit Linux (Linux PC)
- `arm32v7`, `armv7l`, `armhf`: ARMv7 32-bit (Odroid HC1/HC2/XU4, RPi 2/3/4 32-bit)
- `arm64`, `aarch64`: ARMv8 64-bit (RPi 4 64-bit OSes)
- `amd64`, `x86_64`: X86 64-bit Linux (Linux PC)

Other architectures (Windows, Mac, armel) are not currently supported, but feel free to see if the container builds and runs for these.

Expand All @@ -50,6 +74,7 @@ There are a series of available environment variables:
| `NOTIFICATION_MAPURL` | If set to a URL, a link `$NOTIFICATION_MAPURL/mmsi=$mmsi` will be added to the notification. If the value is non-empty but doesn't start with "http" (e.g., if it's set to `on`, `$AIS-URL/mmsi=$mmsi` will be used. | empty | no |
| `NOTIFY_ONLY_NEW_ON_STARTUP` | If set to any non-empty value, when restarting the container, it will not notify for any vessels in its first run, and consider these vessels "already notified". This is to avoid spamming the notification service at initial startup when many non-notified vessels are discovered | empty | no |
| `NOTIFICATION_THROTTLE` | If set to any non-empty value, notifications will pause for 15 seconds for every 10 notifications in a run | empty | no |
| `LANGUAGE` | Set to make notifications in one of these supported languages: `en_US` (US English); `es_ES` (Spanish); `nl_NL` (Dutch); `fr_FR` (French); `de_DE` (German). If omitted, it will default to `en_US` | `en_US` | no |

### Tropo Alert parameters

Expand All @@ -74,6 +99,7 @@ For predictions on Tropo conditions for your area, please visit the [DX Info Cen
| `MASTODON_NOTIFY_EVERY` | Minimum amount of time (in seconds) between two notifications for the same vessel. | `86400` (1 day) | no |
| `MASTODON_POST_VISIBILITY` | `visibility` setting for the Mastodon notification. Valid values are `public`, `unlisted`, and `private`. | `unlisted` | no |
| `MASTODON_CUSTOM_FIELD` | Custom field attached to the end of the Mastodon notification. Please keep it short and clear-text only. | empty | no |
| `MASTODON_LINK_AISCATCHER` | If set to `on`, the Mastodon notification will include a link to the vessel on aiscatcher.org. (Set to `off`/`false`/`no`/`0` to disable) | on | no |
| `MASTODON_LINK_SHIPXPLORER` | If set to `on`, the Mastodon notification will include a link to the vessel on ShipXplorer | empty | no |
| `MASTODON_LINK_MARINETRAFFIC` | If set to `on`, the Mastodon notification will include a link to the vessel on MarineTraffic | empty | no |
| `MASTODON_LINK_VESSELFINDER` | If set to `on`, the Mastodon notification will include a link to the vessel on VesselFinder | empty | no |
Expand Down Expand Up @@ -111,27 +137,27 @@ Please note that you must use the screenshot container's `aiscatcher` tag and br

## Logging

* All processes are logged to the container's stdout, and can be viewed with `docker logs [-f] container`.
- All processes are logged to the container's stdout, and can be viewed with `docker logs [-f] container`.

## Modifications of Ship Status and Ship Type descriptions

In your `opt/ais/data` directory (if you followed the volume mappings as recommended), there are two files:

* `shipstatus.db` contains the descriptions of the Ship Status for each status ID number
* `shiptype.db` contains the descriptions of the Ship Type for each type number
- `shipstatus.db` contains the descriptions of the Ship Status for each status ID number
- `shiptype.db` contains the descriptions of the Ship Type for each type number

You can change those with a text editor. Lines that start with "#" are ignored, and you can hashtag words in the description.

## Acknowledgements

Without the help, advice, testing, and kicking the tires of these people, things wouldn't have happened:

* [@jvde-github](https://github.com/jvde-github) for his advice and help. He's also the author of [AIS-Catcher](https://github.com/jvde-github/AIS-catcher), which is a prerequisite for this container to work
* [@kevinelliott](https://github.com/kevinelliott) for his help during the design phase of the project, and to bounce ideas of
* [@dziban303](https://github.com/dziban303) for his help testing the early releases and providing feedback
* [@JohnEx](https://github.com/Johnex) for his ideas, research, testing, and feedback
* [@Tedder](https://github.com/tedder) who created the [original screenshot container](https://github.com/tedder/browser-screenshot-service) when we needed it for Planefence
* The engineers at AirNav who helped me understand things through their ShipXplorer project, and who provided the initial trigger for me to create this container
- [@jvde-github](https://github.com/jvde-github) for his advice and help. He's also the author of [AIS-Catcher](https://github.com/jvde-github/AIS-catcher), which is a prerequisite for this container to work
- [@kevinelliott](https://github.com/kevinelliott) for his help during the design phase of the project, and to bounce ideas of
- [@dziban303](https://github.com/dziban303) for his help testing the early releases and providing feedback
- [@JohnEx](https://github.com/Johnex) for his ideas, research, testing, and feedback
- [@Tedder](https://github.com/tedder) who created the [original screenshot container](https://github.com/tedder/browser-screenshot-service) when we needed it for Planefence
- The engineers at AirNav who helped me understand things through their ShipXplorer project, and who provided the initial trigger for me to create this container

## Getting Help

Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/10-container-init
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/command/with-contenv bash
# shellcheck shell=bash disable=SC1091
source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)

"${s6wrap[@]}" echo "[INFO] Starting VesselAlert version $(cat /.CONTAINER_VERSION)"
"${s6wrap[@]}" echo "[INFO] Notification Language is ${LANGUAGE:-en_US}"

# Put databases in place but don't overwrite any existing ones as they may have been changed by the user
mkdir -p /data/imagecache/screenshots/
Expand Down
1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/40-check-ais-notify
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#---------------------------------------------------------------------------------------------

source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)

"${s6wrap[@]}" echo "[INFO] Started as an s6 init script"

Expand Down
1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/60-check-mastodon
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#---------------------------------------------------------------------------------------------

source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)

"${s6wrap[@]}" echo "[INFO] Checking Mastodon server and access token"

Expand Down
19 changes: 10 additions & 9 deletions rootfs/etc/s6-overlay/scripts/70-set-strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/command/with-contenv bash
#shellcheck shell=bash disable=SC2015,SC1091,SC1090,SC2034
#shellcheck shell=bash disable=SC2015,SC1091,SC1090,SC2034,SC2154

#---------------------------------------------------------------------------------------------
# Copyright (C) 2022-2023, Ramon F. Kolb (kx1t)
Expand All @@ -18,10 +18,11 @@
#---------------------------------------------------------------------------------------------

source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)

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

LANGUAGE="${LANGUAGE:-en_us}"

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

touch "${VESSELDBFILE}"
Expand All @@ -36,9 +37,9 @@ fi
unset SHIPTYPE
declare -A SHIPTYPE

if [[ -f /data/shiptype.db ]]
if [[ -f "/data/shiptype-$LANGUAGE.db" ]]
then
source "/data/shiptype.db"
source "/data/shiptype-$LANGUAGE.db"
"${s6wrap[@]}" echo "[INFO] SHIPTYPE database loaded from file"
else
#SHIPTYPE[0]="Not Available"
Expand Down Expand Up @@ -142,13 +143,13 @@ else
#SHIPTYPE[98]="#Other Reserved"
SHIPTYPE[99]="#Other"

"${s6wrap[@]}" echo "[INFO] SHIPTYPE database loaded from internal list as shiptype.db file was not found"
"${s6wrap[@]}" echo "[INFO] SHIPTYPE database loaded from internal list as shiptype-$LANGUAGE.db file was not found"
fi
unset SHIPSTATUS
declare -A SHIPSTATUS
if [[ -f /data/shipstatus.db ]]
if [[ -f "/data/shipstatus-$LANGUAGE.db" ]]
then
source "/data/shipstatus.db"
source "/data/shipstatus-$LANGUAGE.db"
"${s6wrap[@]}" echo "[INFO] SHIPSTATUS database loaded from file"
else
SHIPSTATUS[0]="#under_way_using_engine"
Expand All @@ -168,7 +169,7 @@ else
SHIPSTATUS[14]="#AIS-SART #MOB-AIS #EPIRB-AIS"
#SHIPSTATUS[15]="undefined = default (also used by AIS-SART, MOB-AIS and EPIRB-AIS under test)"

"${s6wrap[@]}" echo "[INFO] SHIPSTATUS database loaded from internal list as shipstatus.db file was not found"
"${s6wrap[@]}" echo "[INFO] SHIPSTATUS database loaded from internal list as shipstatus-$LANGUAGE.db file was not found"
fi

unset COUNTRY
Expand Down Expand Up @@ -408,7 +409,7 @@ else
COUNTRY[ZM]="Zambia"
COUNTRY[ZW]="Zimbabwe"

"${s6wrap[@]}" echo "[INFO] COUNTRY names database loaded from internal list as country.db file was not found"
"${s6wrap[@]}" echo "[INFO] COUNTRY names database loaded from internal list as country-$LANGUAGE.db file was not found"
fi

# Make sure the other arrays have been declared if they don't already exist:
Expand Down
1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/80-tropoalert-init
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/command/with-contenv bash
# shellcheck shell=bash disable=SC1091
source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)

if ! chk_enabled "${TROPOALERT:-enabled}"; then
"${s6wrap[@]}" echo "[INFO] TropoAlert is not enabled; if you want to notify when ships are received at long distance, then start container with TROPOALERT=true"
Expand Down
3 changes: 1 addition & 2 deletions rootfs/etc/s6-overlay/scripts/ais-collect
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#---------------------------------------------------------------------------------------------

source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)

"${s6wrap[@]}" echo "[INFO] Started as an s6 service"
[[ -n "$DEBUG" ]] && "${s6wrap[@]}" echo "[INFO] DEBUG=ON" || "${s6wrap[@]}" echo "[INFO] DEBUG=OFF"
Expand Down Expand Up @@ -144,4 +143,4 @@ do
sleep $CHECK_INTERVAL

done
"${s6wrap[@]}" echo "[INFO] restarting $0 to clean up memory"
"${s6wrap[@]}" echo "[INFO] restarting $0 to clean up memory"
14 changes: 8 additions & 6 deletions rootfs/etc/s6-overlay/scripts/cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@
#---------------------------------------------------------------------------------------------

source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)

renice -n 20 -p $$ >/dev/null 2>/dev/null

CLEANUP_EVERY=1800 # every 30 minutes
CLEANUP_EVERY=1800 # 30 minutes in seconds
PHOTOS_RETENTION=20160 # 2 weeks in minutes
SCREENSHOT_RETENTION=60 # 1 hour
SCREENSHOT_RETENTION=60 # 1 hour in minutes
#LOCKFILE_RETENTION=15 # 15 minutes
MMSI_RETENTION=1209600 # 2 weeks in seconds
COUNTRY_BKUP_RETENTION=20160 # 2 weeks in minutes
DISCTMPL_BKUP_RETENTION=20160 # 2 weeks in minutes
SHIPSTATUS_BKUP_RETENTION=20160 # 2 weeks in minutes
SHIPTYPE_BKUP_RETENTION=20160 # 2 weeks in minutes
VESSELDB_BKUP_RETENTION=20160 # 2 weeks in minutes
MASTODON_CLEANUP_EVERY=43200 # 12 hours in seconds

VESSELDBFILE="${VESSELDBFILE:-/data/vessel.db}"
VESSELDBLOCK="${VESSELDBLOCK:-/run/vesseldb.lock}"

DBLOCK_MAXWAIT=600 # don't wait more than 600 secs for the dblock to be removed

[[ ! -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..."

Expand Down Expand Up @@ -107,11 +109,11 @@ rm -f "$VESSELDBLOCK"

# clean up Mastodon toots:

if [[ -n "$MASTODON_ACCESS_TOKEN" ]]; then
if [[ -n "$MASTODON_ACCESS_TOKEN" ]] && (( $(date +%s) - $(</run/.last_mastodon_cleanup) > MASTODON_CLEANUP_EVERY )); then
/usr/share/vesselalert/masto_expire delete || true
fi


"${s6wrap[@]}" echo "[INFO] Cleanup finished. Next cleanup run at $(date -d @$(( $(date +%s) + CLEANUP_EVERY )) ). "
"${s6wrap[@]}" echo -n "[INFO] Cleanup finished. Next cleanup run at $(date -d @$(( $(date +%s) + CLEANUP_EVERY )) )"
[[ -n "$MASTODON_ACCESS_TOKEN" ]] && echo ". Next Mastodon cleanup run at $(date -d @"$(( $(</run/.last_mastodon_cleanup) + MASTODON_CLEANUP_EVERY ))")" || echo ""

sleep "${CLEANUP_EVERY}"
Loading
Loading