add install scripts and move secrets to uncommited file
This commit is contained in:
parent
963907fcf4
commit
2fbec4da69
6 changed files with 60 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
secrets
|
secrets
|
||||||
|
*.csv
|
||||||
|
|
|
||||||
19
collector.sh
19
collector.sh
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/sh
|
||||||
# Collects and logs data from the OpenShipData API and the OSM API
|
# Collects and logs data from the OpenShipData API and the OSM API
|
||||||
#
|
#
|
||||||
source ./secrets
|
source ./secrets
|
||||||
|
|
@ -21,3 +22,21 @@ province=$(echo "$osm_response" | jq --raw-output .address.province)
|
||||||
country=$(echo "$osm_response" | jq --raw-output .address.country)
|
country=$(echo "$osm_response" | jq --raw-output .address.country)
|
||||||
|
|
||||||
echo "La ville la plus proche est $town dans la province de $province, $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
19
install.sh
Executable 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."
|
||||||
10
lighthouse.service.default
Normal file
10
lighthouse.service.default
Normal 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
9
lighthouse.timer
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Run the Lighthouse collector every 10 minutes
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*:0/15
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
MMSI=#MMSI of the ship to track
|
MMSI=#MMSI of the ship to track
|
||||||
KEY=#OpenShipData API key
|
KEY=#OpenShipData API key
|
||||||
|
DATA_FILE=# output file location
|
||||||
|
NTFY_ENDPOINT=# address of ntfy endpoint with topic name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue