add install scripts and move secrets to uncommited file

This commit is contained in:
grizzly 2025-07-12 12:19:35 -04:00
parent 963907fcf4
commit 2fbec4da69
6 changed files with 60 additions and 0 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
secrets
*.csv

View file

@ -1,3 +1,4 @@
#!/usr/bin/sh
# Collects and logs data from the OpenShipData API and the OSM API
#
source ./secrets
@ -21,3 +22,21 @@ province=$(echo "$osm_response" | jq --raw-output .address.province)
country=$(echo "$osm_response" | jq --raw-output .address.country)
echo "La ville la plus proche est $town dans la province de $province, $country"
curl -s -d "Donnees collectes" $NTFY_ENDPOINT
# store values in file
if ! [ -e "$DATA_FILE" ] ; then
touch $DATA_FILE
echo "timestamp,latitude,longitude,bearing,speed,town,province,country" >> $DATA_FILE
fi
if ! [ -w "$DATA_FILE" ] ; then
echo "$DATA_FILE is not writeable"
exit 1
fi
timestamp=$(date)
echo "\"$timestamp\",$lat,$lon,$bearing,$speed,\"$town\",\"$province\",\"$country\"" >> $DATA_FILE
exit 0

19
install.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
echo $SCRIPT_DIR
cp lighthouse.service.default lighthouse.service
sed -i 's|WORKING_DIR|'"$SCRIPT_DIR"'|g' lighthouse.service
cp ./lighthouse.service /etc/systemd/system/.
cp ./lighthouse.timer /etc/systemd/system/.
systemctl daemon-reload
systemctl enable lighthouse.service
systemctl enable lighthouse.timer
systemctl start lighthouse.timer
echo "All done."

View file

@ -0,0 +1,10 @@
[Unit]
Description=Lighthouse vessel tracker and notification
After=network.target
[Service]
WorkingDirectory=WORKING_DIR
ExecStart=WORKING_DIR/collector.sh
[Install]
WantedBy=default.target

9
lighthouse.timer Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=Run the Lighthouse collector every 10 minutes
[Timer]
OnCalendar=*:0/15
Persistent=true
[Install]
WantedBy=basic.target

View file

@ -1,3 +1,5 @@
#!/bin/bash
MMSI=#MMSI of the ship to track
KEY=#OpenShipData API key
DATA_FILE=# output file location
NTFY_ENDPOINT=# address of ntfy endpoint with topic name