documentation and config updates pre-release

This commit is contained in:
kx1t
2021-03-08 13:55:30 -05:00
parent 730fc7591b
commit 766abfc268
7 changed files with 135 additions and 617 deletions

View File

@@ -1,98 +0,0 @@
# Installing or Upgrading Planefence to the latest dev version.
## Install a new instance
Note - this guide assumes that `/home/pi` is your home directory. If it is not (for example, Ubuntu builds use `/home/ubuntu` as their default account), please change all occurrences of `/home/pi` to your home directory path.
The guide also assumes you run on a `armhf` or `arm64` machine. If not, see the section "Building my own container" below and then follow the rest of the guide.
Last, the guide assumes that you have `docker` and `docker-compose` installed. If you don't, please follow the relevant sections of [this guide](https://mikenye.gitbook.io/ads-b/setting-up-the-host-system/install-docker).
### Getting ready
Some of these things you may already have done. You can skip those steps. We erred on the side of completeness.
1. Create a landing directory for Planefence:
```
sudo mkdir -p /opt/planefence && sudo chmod a+rwx /opt/planefence && cd /opt/planefence
```
2. Get the template Docker-compose.yml file
```
curl -s https://raw.githubusercontent.com/kx1t/docker-planefence/dev/docker-compose.yml > docker-compose.yml
```
Now, there are a few possibilities:
1. You are already running a container with `tar1090`, `dump1090[-fa]`, or `readsb` on the same machine with docker-compose and want to add PlaneFence to this
2. You are running `tar1090`, `dump1090[-fa]`, or `readsb` elsewhere, either dockerized or stand-alone. This includes the use case where you are running the feeder software stand-alone on the same machine
3. You don't run `tar1090`, `dump1090[-fa]`, or `readsb` anywhere else and you need to install an instance of this software on your local machine.
### Situation 1 - Adding Planefence to an existing, local, containerized setup of `tar1090`, `dump1090[-fa]`, or `readsb`
- Extract from `docker-compose.yml` the entire `planefence:` section under `services:`. Open your existing `docker-compose.yml` and add this section there. Note -- YML is very sensitive to indents. Make sure that they line up in the target file the same way as they were in the file you copied from.
### Situation 2- You are running your feeder elsewhere
- Edit the `docker-compose.yml` file attached and remove or comment out the following:
```
#volumes:
# readsbpb_rrd:
# readsbpb_autogain:
```
- Remove or comment out the entire `readsb:` section from line 42 through the end of the file
- On your other setup, MAKE SURE (!!) that you generate SBS formatted data on port 30003. How to do this varies by setup and goes beyond this manual, but please reach out for help if needed!
- When you start editing `planefence.config` (wait until you get to this, following the guide step by step), pay extra attention to this parameter `PF_SOCK30003HOST=`
### Situation 3 - Adding a feeder from scratch
- It is assumed that you understand what this entails. If you don't -- please read [Mikenye's excellent Gitbook](https://mikenye.gitbook.io/ads-b/) on the topic!
- The example here adds a `readsb-protobuf` container. Setup for `dump1090[-fa]` or `tar1090` is very similar
- `readsb-protobuf` will need a `.env` file. We will tell you how to EASILY create one after you are done fully configuring PlaneFence.
### Planefence Configuration
#### Initial docker configuration
In the `docker-compose.yml` file, you should configure the following:
- IMPORTANT: The image, by default, points at the release image. For the DEV version, change this: `image: kx1t/planefence:arm-test-pr`
- IMPORTANT: Update `TZ=America/New_York` to whatever is appropriate for you. Note that this variable is case sensitive
- There are 2 volumes defined. My suggestion is NOT to change these (except for updating `/home/pi/.planefence` -> `/home/ubuntu/planefence` if required). However, if you have to, you can map the HTML directory to some other location. ONLY change what is to the LEFT of the colon.
- You can exit the editor and start the container (`docker-compose up -d`). The first time you do this, it can take a minute or so.
#### Planefence Settings Configuration
- When you start the container for the first time, it will create a few directories with setup files. You MUST edit these setup files before things will work! You can check if the system recognized you've made edits by typing `docker logs planefence` - if you haven't set up the system, it *will* complain.
- MANDATORY: First -- copy the template config file in place: `sudo cp ~/.planefence/planefence.config-RENAME-and-EDIT-me ~/.planefence/planefence.config`
- ALTERNATIVE - if you have used PlaneFence in the past and created a `.env` file, you can use this file as a basis for your `planefence.config` file. You can copy it with `sudo cp /opt/planefence/.env ~/.planefence/planefence.config`. However, there are many new features and setting described in the planefence.config-RENAME-and-EDIT-me file. You should take notice and copy these in!
- MANDATORY: `sudo nano ~/.planefence/planefence.config` Go through all parameters - their function is explained in this file. Edit to your liking and save/exit using `ctrl-x`. THIS IS THE MOST IMPORTANT AND MANDATORY CONFIG FILE TO EDIT !!!
- OPTIONAL: `sudo nano ~/.planefence/plane-ignore.txt`. In this file, you can add things that PlaneFence will ignore. If there are specific planes that fly too often over your home, add them here. Use 1 line per entry, and the entry can be a ICAO, flight number, etc. You can even use regular expressions if you want. Be careful -- we use this file as an input to a "grep" filter. If you put something that is broad (`.*` for example), then ALL PLANES will be filtered out.
- OPTIONAL: `sudo nano ~/.planefence/airlinecodes.txt`. This file maps the first 3 characters of the flight number to the names of the airlines. We scraped this list from a Wikipedia page, and it is by no means complete. Feel free to add more to them -- please add an issue at https://github.com/kx1t/planefence/issues so we can add your changes to the default file.
- OPTIONAL: `sudo nano ~/.planefence/.twurlrc`. You can add your back-up TWURLRC file here, if you want.
- OPTIONAL: `sudo nano ~/.planefence/plane-alert-db.txt`. This is the list of tracking aircraft of Plane-Alert. It is prefilled with the planes of a number of "interesting" political players. Feel free to add your own, delete what you don't want to see, etc. Just follow the same format.
#### Applying your setup
- If you are using the "Adding a feeder from scratch" configuration above, it will want a `.env` file. You can provide it simply with a copy of your planefence.config file: `cp ~/.planefence/planefence.config /opt/planefence/.env`. (You can ignore this if you didn't follow the "Adding a feeder from scratch" setup.)
- Now, you can restart the Planefence container and the new setup should automatically be applied: `pushd /opt/planefence && docker-compose up -d && popd`
## What does it look like when it's running?
- Planefence dev build: http://ramonk.net:8081
- Plane-alert dev build: http://ramonk.net:8081/plane-alert
## Seeing my own setup and troubleshooting
- Be patient. Many of the files won't get initialized until the first "event" happens: a plane is in PlaneFence range or is detected by Plane-Alert
- Check, check, double-check. Did you configure the correct container in `docker-compose.yml`? cat
- Check the logs: `docker logs -f planefence`
- Check the website: http://myip:8081 should update every 80 seconds (starting about 80 seconds after the initial startup). The top of the website shows a last-updated time and the number of messages received from the feeder station.
- Plane-alert will appear at http://myip:8081/plane-alert
- Twitter setup is complex. [Here](https://github.com/kx1t/docker-planefence#setting-up-tweeting)'s a description on what to do.
- If you have a soundcard and microphone, adding NoiseCapt is as easy as hooking up the hardware and running another container. You can add this to your existing `docker-compose.yml` file, or run it on a different machine on the same subnet. Instructions are [here](https://github.com/kx1t/docker-noisecapt/blob/main/README.md).
## Building my own container
This section is for those who don't trust my container building skills (honestly, I wouldn't trust myself!) or who run on an architecture that is different than `armhf` (Raspberry Pi 3B+/4 with Raspberry OS 32 bits) or `arm64` (Raspberry Pi 4 with Ubuntu 64 bits). In that case, you may have to create your own container using these steps. This assumes that you have `git` installed. If you don't, please install it first using `sudo apt-get install git`.
```
sudo mkdir -p /opt/planefence
sudo chmod a+rwx /opt/planefence
cd /opt/planefence
git clone https://github.com/kx1t/docker-planefence
cd docker-planefence
docker build --compress --pull -t kx1t/planefence:arm-test-pr .
```
This should create a container ready to use on your local system.
## Getting help
- If you need further support, please join the #planefence channel at the [SDR Enthusiasts Discord Server](https://discord.gg/VDT25xNZzV). If you need immediate help, please add "@ramonk" to your message.
That's all!

48
README-planetweet.md Normal file
View File

@@ -0,0 +1,48 @@
# Send a Tweet for each new plane in PlaneFence
This utility enables tweeting of new events. It consists of a BASH shell script that monitors today's planes as written by PlaneFence, and sends out a tweet for every new plane using [Twurl](https://github.com/twitter/twurl).
There are two major parts to install this. Each of these parts is described below.
- You must apply for your own Twitter Developer Account and create an app.
- You must follow the instructions below to configure PlaneFence to use the credentials that Twitter provides you during this sign-up process.
## Prerequisites
This is part of the [kx1t/docker-planefence] docker container. Nothing in this document will make sense outside the context of this container.
## Signing up for a Twitter Development Account and getting Twitter Credentials
You'll need a registered Twitter application. If you've never registered a Twitter application before, do the following:
- If you need help, [here's a webpage](https://elfsight.com/blog/2020/03/how-to-get-twitter-api-key/) with an excellent graphical walk-through of what you need to do. In short, this is the same as doing the following:
- Go to https://developer.twitter.com/en/apps and sign in to your Twitter account. Click "Create an app".
- If you've previously registered a Twitter application, it should be listed at https://apps.twitter.com/.
- Once you've registered an application, make sure to set your application's Access Level to "Read, Write and Access Direct Messages". If you don't, PlaneFence's tweets *will* fail.
- A mobile phone number must be associated with your account in order to obtain write privileges. If your carrier is not supported by Twitter and you are unable to add a number, contact Twitter using https://support.twitter.com/forms/platform, selecting the last checkbox. Some users have reported success adding their number using the mobile site, https://mobile.twitter.com/settings, which seems to bypass the carrier check at the moment.
- Copy your `Consumer API keys` to a secure spot. Don't lose them - you will need them in the next step.
Now, you're ready to authorize PlaneFence to send out tweets. Give the following command from the host machine's command line, while PlaneFence is running and follow the instructions:
```
docker exec -it planefence /root/config_tweeting.sh
```
- Last, don't forget to edit `~/.planefence/planefence.config` and set `PF_TWEET=ON`. Note -- this parameter ONLY concerns general PlaneFence tweeting and doesn't affect Plane-Alert tweeting (see below).
- If you also want Plane-Alert to send Twitter DM's, please read the instructions in `~/.planefence/planefence.config` on how to enable this. Configuring Twitter as described above is a prerequisite for Plane-Alert tweets to work, however if you don't want to send any general PlaneFence tweets, you can leave `PF_TWEET=OFF`
# Summary of License Terms
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

151
README.md
View File

@@ -24,107 +24,78 @@ In order for you to use it, here are some assumptions or prerequisites:
- You are able to access the software and install additional components.
- You know how to deploy Docker images to your machine. If you don't -- it's actually quite simple and makes installation of new components really easy. I advise you to read [Mikenye's excellent Gitbook](https://mikenye.gitbook.io/ads-b/) on the topic, which will show you step by step what to do.
- You use `docker-compose`. It's not hard to simply do `docker run` from a script, but this README has been written assuming `docker-compose`. If you don't have it, feel free to `apt-get install` it :)
- If you need further support, please join the #planefence channel at the [SDR Enthusiasts Discord Server](https://discord.gg/VDT25xNZzV). If you need immediate help, please add "@ramonk" to your message.
- If you need further support, please join the #planefence channel at the [SDR Enthusiasts Discord Server](https://discord.gg/VDT25xNZzV). If you need immediate help, please add "@ramonk" to your message.
## Deploying `docker-planefence`
## Install PlaneFence - Prerequisites
The following instructions assume that you are working on a Raspberry Pi and that you already have the `docker` application installed. If you need help with this, instructions can be found [here](https://mikenye.gitbook.io/ads-b/setting-up-the-host-system/install-docker).
Note - this guide assumes that `/home/pi` is your home directory. If it is not (for example, Ubuntu builds use `/home/ubuntu` as their default account), please change all occurrences of `/home/pi` to your home directory path.
There are 2 ways of deploying planefence -- as a stand-alone deployment where you still need to deploy a feeder station, or as part of an already existing dockerized installation of your feeder.
This guide assumes that you have `docker` and `docker-compose` installed. If you don't, please follow the relevant sections of [this guide](https://mikenye.gitbook.io/ads-b/setting-up-the-host-system/install-docker).
### Installing stand-alone
There is a sample `docker-compose` file and a sample `.env` file that contain all the deployment parameters you need. In addition, we need to prep a directory that will be linked to the directory ("volume") with the web and data files. This ensures that you can access them from the host machine, and that they will be super persistent across builds, so no information will get lost.
Last, we are going to assume that you have a version of `tar1090`, `dump1090[-fa]`, or `readsb` running somewhere in reach of your Planefence machine, potentially even as a container on the same machine. --> It is important to enable SBS data on port 30003 on that instance. PlaneFence will use this to get its data. Again, Mikenye's Gitbook will help you install a container with this, if needed.
Follow these commands:
### Getting ready
If you are adding this to an existing collection of docker containers on your machine, you can add the information from this project to your existing `docker-compose.yml`. If not, you should create a project directory (`sudo mkdir -p /opt/planefence && sudo chmod a+rwx /opt/planefence && cd /opt/planefence`) and make a new `docker-compose.yml` there.
Get the template Docker-compose.yml file from here:
```
sudo mkdir -d /opt/planefence/Volumes/html
mkdir -d ~/.planefence
sudo chown -R ${USER}: /opt/planefence
wget -O /opt/planefence/docker-compose.yml https://raw.githubusercontent.com/kx1t/docker-planefence/main/docker-compose.yml
wget -O /opt/planefence/.env https://raw.githubusercontent.com/kx1t/docker-planefence/main/.env-example
curl -s https://raw.githubusercontent.com/kx1t/docker-planefence/dev/docker-compose.yml > docker-compose.yml
```
Now, and this is important, you MUST edit these two files before starting the docker container:
- `/opt/planefence/.env` contains all the variables about your station. You MUST SET THESE TO APPROPRIATE VALUES, otherwise things won't work. At a very minimum, you must adjust these: `FEEDER_ALT_FT`, `FEEDER_ALT_M`, `FEEDER_LAT`, `FEEDER_LONG`, `FEEDER_TZ`
- `/opt/planefence/docker-compose` contains a bunch of stuff regulating the docker container and how it communicates with the outside world. Specifically take note of these parameters and change them to your needs:
-- Under `services:` -> `planefence:`, there is a `ports` section. This has the syntax of `80:80`. The first number (left of the ":") indicates the port number the outside world sees. If you are already running a web server somewhere, you may want to change this to a different number. (Alternatively, you may forego the docker container's webservice altogether and use a web server on the host machine. See the description in the Advanced section below.)
-- If for any reason you didn't like the `/opt/planefence/Volumes/html/` directory and changed this in the command above, you should also change it in this file under `Services:` -> `Planefence:` -> `Volumes:`. Again, only change things LEFT of the ":".
Once this is done, you can start the complete docker using:
```pushd /opt/planefence && docker-compose up -d && popd```
### Planefence Configuration
#### Initial docker configuration
In the `docker-compose.yml` file, you should configure the following:
- IMPORTANT: The image, by default, points at the release image. For the DEV version, change this: `image: kx1t/planefence`
- IMPORTANT: Update `TZ=America/New_York` to whatever is appropriate for you. Note that this variable is case sensitive
- There are 2 volumes defined. My suggestion is NOT to change these (except for updating `/home/pi/.planefence` -> `/home/ubuntu/planefence` if required). However, if you have to, you can map the HTML directory to some other location. ONLY change what is to the LEFT of the colon.
- You can exit the editor and start the container (`docker-compose up -d`). The first time you do this, it can take a minute or so.
- Monitor the container (`docker logs -f planefence`). At first start-up, it should be complaining about not being configure. That is expected behavior.
Congratulations, that's all! Browse to `http://your.ip:8088` to see the website, or browse the data in `/opt/planefence/Volumes/html/*.csv` !
#### Planefence Settings Configuration
- When you start the container for the first time, it will create a few directories with setup files. You MUST edit these setup files before things will work! You can check if the system recognized you've made edits by typing `docker logs planefence` - if you haven't set up the system, it *will* complain.
- MANDATORY: First -- copy the template config file in place: `cp ~/.planefence/planefence.config-RENAME-and-EDIT-me ~/.planefence/planefence.config`
- ALTERNATIVE - if you have used PlaneFence in the past and created a `.env` file, you can use this file as a basis for your `planefence.config` file. You can copy it with `sudo cp /opt/planefence/.env ~/.planefence/planefence.config`. However, there are many new features and setting described in the planefence.config-RENAME-and-EDIT-me file. You should take notice and copy these in! There are some items (like the setup for the different feeders) that are not needed by `planefence.config`.
- MANDATORY: `sudo nano ~/.planefence/planefence.config` Go through all parameters - their function is explained in this file. Edit to your liking and save/exit using `ctrl-x`. THIS IS THE MOST IMPORTANT AND MANDATORY CONFIG FILE TO EDIT !!!
- OPTIONAL: `sudo nano ~/.planefence/plane-ignore.txt`. In this file, you can add things that PlaneFence will ignore. If there are specific planes that fly too often over your home, add them here. Use 1 line per entry, and the entry can be a ICAO, flight number, etc. You can even use regular expressions if you want. Be careful -- we use this file as an input to a "grep" filter. If you put something that is broad (`.*` for example), then ALL PLANES will be filtered out.
- OPTIONAL: `sudo nano ~/.planefence/airlinecodes.txt`. This file maps the first 3 characters of the flight number to the names of the airlines. We scraped this list from a Wikipedia page, and it is by no means complete. Feel free to add more to them -- please add an issue at https://github.com/kx1t/planefence/issues so we can add your changes to the default file.
- OPTIONAL: If you configured Twitter support before, `sudo nano ~/.planefence/.twurlrc`. You can add your back-up TWURLRC file here, if you want.
- OPTIONAL: Configure tweets to be sent. For details, see these instructions: https://github.com/kx1t/docker-planefence/README-planetweet.md
- OPTIONAL: `sudo nano ~/.planefence/plane-alert-db.txt`. This is the list of tracking aircraft of Plane-Alert. It is prefilled with the planes of a number of "interesting" political players. Feel free to add your own, delete what you don't want to see, etc. Just follow the same format.
- OPTIONAL: If you have multiple containers running on different web port, and you would like to consolidate them all under a single host name, then you should consider installing a "reverse web proxy". This can be done quickly and easily - see instructions [here](https://github.com/kx1t/docker-planefence/README-nginx-rev-proxy.md).
### Adding to a previously deployed readsb[-protobuf]/dump1090[-fa] docker container or external machine
These instructions assume that you deployed Mikenye's dockerized containers for adsb as described in his [Gitbook](https://mikenye.gitbook.io/ads-b/). If you built your own container, the text below should be enough for you to figure out how to update your docker-compose file to add Planefence
#### Applying your setup
- If you made a bunch of changes for the first time, you should restart the container. In the future, most updates to `~/.planefence/planefence.config` will be picked up automatically
- You can restart the Planefence container by doing: `pushd /opt/planefence && docker stop planefence && docker-compose up -d && popd` (replace `/opt/planefence` to whatever the directory is where your `docker-compose.yml` file is located
1. Make sure you are running readsb or dump1090[-fa] with the option `--net-sbs-port=30003`. In a non-dockerized installation, you can edit the applicable file in `/etc/default`: either `dump1090`, or `dump1090-fa`, or `readsb`. In Mikenye's dockerized version of `readsb`, add the following to `docker-compose.yml` in the `environment:` section: `- READSB_NET_SBS_OUTPUT_PORT=30003`.
2. Copy the relevant parts from the [`docker-compose.yml` sample file](https://raw.githubusercontent.com/kx1t/docker-planefence/main/docker-compose.yml) to your own `docker-compose.yml`. SPecifically, add `planefence:` to the `volumes:` section and add the entire `planefence:` section that is shown under `services:` in the sample file.
3. Add the variable from the [`.env` sample file](https://raw.githubusercontent.com/kx1t/docker-planefence/main/.env-example) to your existing `.env` file, or copy the file in its entirety (and edit it!) if it doesn't already exist.
4. Expose the port 30003 on the container that runs the feeder. This will automatically make that port available to the planefence container
5. If you are running your feeder on a different machine (or in a different group), you will need to do two things:
-- ensure that the feeder installation exposes SBS on port 30003
-- update your `.env` file for planefence and put the hostname or IP address of the machine that provides the SBS output in the `PF_SOCK30003HOST` parameter, for example `PF_SOCK30003HOST=192.168.0.25`.
## What does it look like when it's running?
- Planefence build example: https://planefence.ramonk.net
- Plane-alert build example: https://plane-alert.ramonk.net
## Seeing my own setup and troubleshooting
- Be patient. Many of the files won't get initialized until the first "event" happens: a plane is in PlaneFence range or is detected by Plane-Alert
- Check, check, double-check. Did you configure the correct container in `docker-compose.yml`? cat
- Check the logs: `docker logs -f planefence`
- Check the website: http://myip:8081 should update every 80 seconds (starting about 80 seconds after the initial startup). The top of the website shows a last-updated time and the number of messages received from the feeder station.
- Plane-alert will appear at http://myip:8081/plane-alert
- Twitter setup is complex. [Here](https://github.com/kx1t/docker-planefence#setting-up-tweeting)'s a description on what to do.
- If you have a soundcard and microphone, adding NoiseCapt is as easy as hooking up the hardware and running another container. You can add this to your existing `docker-compose.yml` file, or run it on a different machine on the same subnet. Instructions are [here](https://github.com/kx1t/docker-noisecapt/blob/main/README.md).
## Building my own container
This section is for those who don't trust my container building skills (honestly, I wouldn't trust myself!) or who run on an architecture that is different than `armhf` (Raspberry Pi 3B+/4 with Raspberry OS 32 bits),`arm64` (Raspberry Pi 4 with Ubuntu 64 bits), or `amd64` (Linux PC). In that case, you may have to create your own container using these steps. This assumes that you have `git` installed. If you don't, please install it first using `sudo apt-get install git`.
```
sudo mkdir -p /opt/planefence
sudo chmod a+rwx /opt/planefence
cd /opt/planefence
git clone https://github.com/kx1t/docker-planefence
cd docker-planefence
docker build --compress --pull -t kx1t/planefence:mycontainer .
```
This should create a container ready to use on your local system. Make sure to update your `docker-compose.yml` to point the image at `kx1t/planefence:mycontainer`
## Advanced configuration
## Getting help
- If you need further support, please join the #planefence channel at the [SDR Enthusiasts Discord Server](https://discord.gg/VDT25xNZzV). If you need immediate help, please add "@ramonk" to your message. Alternatively, you email me at kx1t@amsat.org.
### Setting up Tweeting
Planefence can send out a Tweet everytime an aircraft enters the fence. In order to do so, you need to apply for a Twitter Developer Account, create an application on your Twitter Dev account, get some keys, and run a bit of configuration. This is a one-time thing, so even it if sounds complicated, at least it needs to be done only once! Follow these steps:
1. Go to https://apps.twitter.com/app/new . Sign in with your Twitter account, apply for a developer account, and create a new app. A couple of hints:
-- If you need help, [here](https://elfsight.com/blog/2020/03/how-to-get-twitter-api-key/)'s a webpage with an excellent graphical walk-through of what you need to do.
-- Create a new application and provide some answers. Your application will be for "hobbyist" use, it's a "bot", and just provide a description of why you'd like to tweet about planes flying over your house.
-- Make sure you have a mobile phone number registered with your account. Without it, you can't get "write" (i.e., send Tweets) permissions. If your carrier is not supported by Twitter and you are unable to add a number, contact Twitter using https://support.twitter.com/forms/platform, selecting the last checkbox. Some users have reported success adding their number using the mobile site, https://mobile.twitter.com/settings, which seems to bypass the carrier check at the moment.
-- Request Read, Write, and Send Direct Messages access. If you don't, the logs will full up with errors ("Error processing your OAuth request: Read-only application cannot POST").
-- Keep the page with your Consumer API keys open - you will need them in the next step. Copy the Consumer API Key and Consumer API Key Secret somewhere -- it's a hassle if you lose them as you'll have to regenerate them and re-authorize the application.
2. Edit your /opt/planefence/.env file and make sure that PF_TWEET=ON
3. Restart the container (`docker-compose up -d`)
4. Remember your Twitter Consumer API Key and Consumer API Key Secret? You need them now!
5. Run this from your host system's command line: `docker exec -it planefence /root/config_tweeting.sh`
6. Follow the instructions. Make a BACK UP of your Cons Key / Secret and make a BACK UP of the config file.
7. Make a backup of your configuration file: `docker cp planefence:/root/.twurlrc .` -- you should save the `.twurlrc` file in a safe spot.
8. If you ever need to restore this file (for example, when you lose your config because you had to recreate the container), you can restore this configuration file by giving the "reverse" command: `docker cp .twurlrc planefence:/root/`
### External web service
If you want, you can use web server based on the host instead of using the web server inside the docker container. You'd do this on a machine that hosts several web pages, so you can map things like http://my.ip/tar1090 - http://my.ip/skyview - http://my.ip/planefence - etc.
To configure this:
1. remove the port mapping from `docker-compose.yml`. Note -- you cannot leave an empty `ports:` section in this file, you may have to remove (or comment out) that too. Also note - you can leave this in, but in that case your website will still be rendered to the port you originally set up.
2. Map a web directory to `/opt/planefence/Volumes/html/`. If your host is using `lighttpd`, [here](https://raw.githubusercontent.com/kx1t/docker-planefence/main/planefence/88-planefence-on-host.conf) is a handy lighttpd mod with some instructions on how you can do this.
### Build your own container
This repository contains a Dockerfile that can be used to build your own.
1. Pull the repository and issue the following command from the base directory of the repo:
`docker build --compress --pull --no-cache -t kx1t/planefence .`
2. Then simply restart the container with `pushd /opt/planefence && docker-compose up -d && popd`
# Acknowledgements, Attributions, and License
I would never have been able to do this without the huge contributions of [Mikenye](http://github.com/mikenye), [Fredclausen](http://github.com/fredclausen), and [Wiedehopf](http://github.com/wiedehopf). Thank you very much!
## Attributions
The package contains parts of, and modifications or derivatives to the following:
Dump1090.Socket30003 by Ted Sluis: https://github.com/tedsluis/dump1090.socket30003
These packages may incorporate other software and license terms.
## License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
![](https://github.com/kx1t/docker-planefence/raw/main/.img/planefence-screenshot.png)
That's all!
![](https://media.giphy.com/media/3oKHWikxKFJhjArSXm/giphy.gif)

View File

@@ -1,254 +0,0 @@
#!/bin/bash
# PLANE-ALERT - a Bash shell script to assess aircraft from a socket30003 render a HTML and CSV table with nearby aircraft
# based on socket30003
#
# Usage: ./plane-alert.sh <inputfile>
#
# Copyright 2021 Ramon F. Kolb - licensed under the terms and conditions
# of GPLv3. The terms and conditions of this license are included with the Github
# distribution of this package, and are also available here:
# https://github.com/kx1t/planefence/
#
# The package contains parts of, and modifications or derivatives to the following:
# Dump1090.Socket30003 by Ted Sluis: https://github.com/tedsluis/dump1090.socket30003
# These packages may incorporate other software and license terms.
#
# Summary of License Terms
# This program is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation, either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see https://www.gnu.org/licenses/.
# -----------------------------------------------------------------------------------
PLANEALERTDIR=/usr/share/plane-alert # the directory where this file and planefence.py are located
# -----------------------------------------------------------------------------------
#
# PLEASE EDIT PARAMETERS IN 'plane-alert.conf' BEFORE USING PLANE-ALERT !!!
#
# -----------------------------------------------------------------------------------
# Exit if there is no input file defined. The input file contains the socket30003 logs that we are searching in
[ "$1" == "" ] && { echo "No inputfile detected. Syntax: $0 <inputfile>"; exit 1; } || INFILE="$1"
# [ "$TESTING" == "true" ] && echo cmdline arg = \"$1\"
#
#
function cleanup
{
# do some final clean-up before exiting - this funciton is called by a trap on receiving the EXIT signal
#rm -f ${OUTFILE%.*}*.diff >/dev/null 2>/dev/null
rm -f ${OUTFILE%.*}*.old >/dev/null 2>/dev/null
rm -f $TMPDIR/plalert*.tmp >/dev/null 2>/dev/null
[ "$TESTING" == "true" ] && echo 11. Finished.
}
#
# Now make sure we call 'cleanup' upon exit:
trap cleanup EXIT
#
#
# -----------------------------------------------------------------------------------
# Let's see if there is a CONF file that defines some of the parameters
[ -f "$PLANEALERTDIR/plane-alert.conf" ] && source "$PLANEALERTDIR/plane-alert.conf"
# -----------------------------------------------------------------------------------
#
# Stop printing debug into to stdout:
TESTING=""
#
# Now let's start
#
#
# Get the file with planes to monitor.
# The file is in CSV format with this syntax:
# ICAO,TailNr,Owner,PlaneDescription
# for example:
# 42001,3CONM,GovernmentofEquatorialGuinea,DassaultFalcon900B
#
# We need to write this to a grep input file that consists simply of lines with "^icao"
sed -n '/^[\^#]/!p' $PLANEFILE `# ignore any lines that start with "#"` \
| awk 'BEGIN { FS = "," } ; { print "^", $1 }' `# add "^" to the beginning of each line and only print ICAO` \
| tr -d '[:blank:]' > $TMPDIR/plalertgrep.tmp `# strip any blank characters and write to file`
[ "$TESTING" == "true" ] && ( echo 1. $TMPDIR/plalertgrep.tmp contains $(cat $TMPDIR/plalertgrep.tmp|wc -l) lines )
# Now grep through the input file to see if we detect any planes
grep -f $TMPDIR/plalertgrep.tmp "$INFILE" `# Go through the input file and grep it agains plalertgrep.tmp` \
| sort -t',' -k1,1 -k5,5 -u `# Filter out only the unique combinations of fields 1 (ICAO) and 5 (date)` \
> $TMPDIR/plalert.out.tmp `# write the result to a tmp file`
[ "$TESTING" == "true" ] && echo 2. $TMPDIR/plalert.out.tmp contains $(cat $TMPDIR/plalert.out.tmp | wc -l) lines
# If there's nothing in $TMPDIR/plalert.out.tmp then write a standard file and exit as there's nothing to be done...
#if [ "$(cat $TMPDIR/plalert.out.tmp | wc -l)" == "0" ]
#then
# cp -f $PLANEALERTDIR/plane-alert.header.html $TMPDIR/plalert-index.tmp
# echo "No new planes from the alert file have been detected!<br />" >> $TMPDIR/plalert-index.tmp
# cat $PLANEALERTDIR/plane-alert.footer.html >> $TMPDIR/plalert-index.tmp
# #Now the basics have been written, we need to replace some of the variables in the template with real data:
# sed -i "s/##NAME##/$NAME/g" $TMPDIR/plalert-index.tmp
# sed -i "s|##ADSBLINK##|$ADSBLINK|g" $TMPDIR/plalert-index.tmp
# sed -i "s/##LASTUPDATE##/$LASTUPDATE/g" $TMPDIR/plalert-index.tmp
# sed -i "s/##ALERTLIST##/$ALERTLIST/g" $TMPDIR/plalert-index.tmp
# sed -i "s/##CONCATLIST##/$CONCATLIST/g" $TMPDIR/plalert-index.tmp
# sed -i "s/##VERSION##/$(if [[ -f /root/.buildtime ]]; then printf "Build: "; cat /root/.buildtime; fi)/g" $TMPDIR/plalert-index.tmp
# #Finally, put the temp index into its place:
# mv -f $TMPDIR/plalert-index.tmp $WEBDIR/index.html
# # And exit outa here!
# exit 0
#fi
# Create a backup of $OUTFILE so we can compare later on. Ignore any complaints if there's no original $OUTFILE
for a in ${OUTFILE%.*}*.csv
do
cp -f "$a" "$a".old >/dev/null 2>/dev/null
done
# Process the intermediate file:
while read -r line
do
[ "$TESTING" == "true" ] && echo 3. Parsing line $line
IFS=',' read -ra plalertplane <<< "$line" # load a single line into an array called $plalertplane
# Determine the real name of the output file and write it to $OUTWRITEFILE:
[ "$OUTAPPDATE" == "true" ] && OUTWRITEFILE="${OUTFILE%.*}"-"$(date -d "${plalertplane[4]}" +%Y-%m-%d)".csv || OUTWRITEFILE="$OUTFILE"
# Parse this into a single line with syntax ICAO,TailNr,Owner,PlaneDescription,date,time,lat,lon,callsign,adsbx_url
printf "%s,%s,%s,%s,%s,%s,https://globe.adsbexchange.com/?icao=%s&showTrace=%s&zoom=%s\n" \
"$(grep "^${plalertplane[0]}" $PLANEFILE | head -1 | tr -d '[:cntrl:]')" `# First instance of the entire string from the template` \
"${plalertplane[4]}" `# Date first heard` \
"${plalertplane[5]:0:8}" `# Time first heard` \
"${plalertplane[2]}" `# Latitude` \
"${plalertplane[3]}" `# Longitude` \
"${plalertplane[11]}" `# callsign` \
"${plalertplane[0]}" `# ICAO for insertion into ADSBExchange link`\
"$(date -d "${plalertplane[4]}" +%Y-%m-%d)" `# reformatted date for insertion into ADSBExchange link`\
"$MAPZOOM" `# zoom factor of the map`\
>> "$OUTWRITEFILE" `# Append this line to $OUTWRITEFILE`
[ -f "$OUTWRITEFILE".old ] && cat "$OUTWRITEFILE" "$OUTWRITEFILE".old > $TMPDIR/plalert2.out.tmp || mv -f "$OUTWRITEFILE" $TMPDIR/plalert2.out.tmp
sort -t',' -k5,5 -k1,1 -u -o "$OUTWRITEFILE" $TMPDIR/plalert2.out.tmp # sort by field 5=date and only keep unique entries. Use an intermediate file so we dont overwrite the file we are reading from
[ "$TESTING" == "true" ] && ( echo 5. $OUTWRITEFILE contains $(wc -l < $OUTWRITEFILE) lines with this: ; cat $OUTWRITEFILE )
done < $TMPDIR/plalert.out.tmp
# the log files are now done, but we want to figure out what is new
# so create some diff files
# first remove any left over diff files
rm -f ${OUTFILE%.*}*.diff >/dev/null 2>/dev/null
# now create the new diff files:
for a in ${OUTFILE%.*}*.csv
do
if [ -f "$a".old ]
then
diff "$a" "$a".old `# determine the difference between the current and the old $OUTWRITEFILE` \
| grep '^[<>]' `# get only the line that we really want; however, there are still some unwanted characters at the beginning` \
| sed -e 's/^[< ]*//' `# strip off the unwanted characters` \
>> "$a".diff `# write to a file with ONLY the new lines added so we can do extra stuff with them`
else
cp "$a" "$a".diff
fi
done
# -----------------------------------------------------------------------------------
# Next, let's do some stuff with the newly acquired aircraft of interest
# First, loop through the new planes and tweet them. Initialize $ERRORCOUNT to capture the number of Tweet failures:
ERRORCOUNT=0
while read -r line
do
IFS=',' read -ra plalertplane <<< "$line"
# check if we want to tweet them:
if [ "$TWITTER" == "true" ] && [ -f "$TWIDFILE" ]
then
# First build the text of the tweet: reminder:
# 0-ICAO,1-TailNr,2-Owner,3-PlaneDescription,4-date,5-time,6-lat,7-lon
# 8-callsign,9-adsbx_url
TWITTEXT="Aircraft of interest detected:\n"
TWITTEXT+="ICAO: ${plalertplane[0]} Tail: ${plalertplane[1]} Flight: ${plalertplane[8]}\n"
TWITTEXT+="Owner: ${plalertplane[2]}\n"
TWITTEXT+="Aircraft: ${plalertplane[3]}\n"
TWITTEXT+="First heard: ${plalertplane[4]} ${plalertplane[5]}\n"
TWITTEXT+="$(sed 's|/|\\/|g' <<< "${plalertplane[9]}")"
[ "$TESTING" == "true" ] && ( echo 6. TWITTEXT contains this: ; echo $TWITTEXT )
[ "$TESTING" == "true" ] && ( echo 7. Twitter IDs from $TWIDFILE )
# Now loop through the Twitter IDs in $TWIDFILE and tweet the message:
while IFS= read -r twitterid
do
# tweet and add the processed output to $result:
[[ "$TESTING" == "true" ]] && echo 8. Tweeting with the following data: recipient = \"$twitterid\" Tweet DM = \"$TWITTEXT\"
[[ "$twitterid" == "" ]] && continue
rawresult=$($TWURL -A 'Content-type: application/json' -X POST /1.1/direct_messages/events/new.json -d '{"event": {"type": "message_create", "message_create": {"target": {"recipient_id": "'"$twitterid"'"}, "message_data": {"text": "'"$TWITTEXT"'"}}}}')
processedresult=$(echo "$rawresult" | jq '.errors[].message' 2>/dev/null) # parse the output through JQ and if there's an error, provide the text to $result
if [[ "$processedresult" != "" ]]
then
echo "9. Tweet error: $rawresult"
echo "Diagnostics:"
echo "Error: $processedresult"
echo "Twitter ID: $twitterid"
echo "Text: $TWITTEXT"
(( ERRORCOUNT++ ))
else
echo "Plane-alert tweet for ${plalertplane[0]} sent successfully to $twitterid"
fi
done < "$TWIDFILE"
else
if [ "$TESTING" == "true" ]
then
echo 10. Skipped tweeting.
echo \$TWITTER is $TWITTER and must be \"true\"
[ -f "$TWURL" ] && echo $TWURL exists || echo $TWURL doesnt exist! Error!
[ -f "$TWIDFILE" ] && echo $TWIDFILE exists || echo $TWIDFILE doesnt exist! Error!
fi
fi
done < <(cat ${OUTFILE%.*}*.diff)
(( ERRORCOUNT > 0 )) && echo There were $ERRORCOUNT tweet errors.
# Now everything is in place, let's update the website
cp -f $PLANEALERTDIR/plane-alert.header.html $TMPDIR/plalert-index.tmp
cat ${OUTFILE%.*}*.csv | tac > $WEBDIR/$CONCATLIST
COUNTER=1
while read -r line
do
IFS=',' read -ra plalertplane <<< "$line"
if [[ "${plalertplane[0]}" != "" ]] && [[ "$(date -d "${plalertplane[4]} ${plalertplane[5]}" +%s)" -gt "$(date -d "$HISTTIME days ago" +%s)" ]]
then
printf "%s\n" "<tr>" >> $TMPDIR/plalert-index.tmp
printf " %s%s%s\n" "<td>" "$((COUNTER++))" "</td>" >> $TMPDIR/plalert-index.tmp # column: Number
printf " %s%s%s\n" "<td>" "${plalertplane[0]}" "</td>" >> $TMPDIR/plalert-index.tmp # column: ICAO
printf " %s%s%s\n" "<td>" "${plalertplane[1]}" "</td>" >> $TMPDIR/plalert-index.tmp # column: Tail
printf " %s%s%s\n" "<td>" "${plalertplane[2]}" "</td>" >> $TMPDIR/plalert-index.tmp # column: Owner
printf " %s%s%s\n" "<td>" "${plalertplane[3]}" "</td>" >> $TMPDIR/plalert-index.tmp # column: Plane Type
printf " %s%s%s\n" "<td>" "${plalertplane[4]} ${plalertplane[5]}" "</td>" >> $TMPDIR/plalert-index.tmp # column: Date Time
printf " %s%s%s\n" "<td>" "<a href=\"http://www.openstreetmap.org/?mlat=${plalertplane[6]}&mlon=${plalertplane[7]}&zoom=$MAPZOOM\" target=\"_blank\">${plalertplane[6]}N, ${plalertplane[7]}E</a>" "</td>" >> $TMPDIR/plalert-index.tmp # column: LatN, LonE
printf " %s%s%s\n" "<td>" "${plalertplane[8]}" "</td>" >> $TMPDIR/plalert-index.tmp # column: Flight No
printf " %s%s%s\n" "<td>" "<a href=\"${plalertplane[9]}\" target=\"_blank\">ADSBExchange link</a>" "</td>" >> $TMPDIR/plalert-index.tmp # column: ADSBX link
printf "%s\n" "</tr>" >> $TMPDIR/plalert-index.tmp
fi
done < $WEBDIR/$CONCATLIST
cat $PLANEALERTDIR/plane-alert.footer.html >> $TMPDIR/plalert-index.tmp
# Now the basics have been written, we need to replace some of the variables in the template with real data:
sed -i "s/##NAME##/$NAME/g" $TMPDIR/plalert-index.tmp
sed -i "s|##ADSBLINK##|$ADSBLINK|g" $TMPDIR/plalert-index.tmp
sed -i "s/##LASTUPDATE##/$LASTUPDATE/g" $TMPDIR/plalert-index.tmp
sed -i "s/##ALERTLIST##/$ALERTLIST/g" $TMPDIR/plalert-index.tmp
sed -i "s/##CONCATLIST##/$CONCATLIST/g" $TMPDIR/plalert-index.tmp
sed -i "s/##HISTTIME##/$HISTTIME/g" $TMPDIR/plalert-index.tmp
sed -i "s/##VERSION##/$(if [[ -f /root/.buildtime ]]; then printf "Build: "; cat /root/.buildtime; fi)/g" $TMPDIR/plalert-index.tmp
#Finally, put the temp index into its place:
mv -f $TMPDIR/plalert-index.tmp $WEBDIR/index.html

View File

@@ -1,96 +0,0 @@
# Send a Tweet for each new plane in PlaneFence
This utility enables tweeting of new events. It consists of a BASH shell script that monitors today's planes as written by PlaneFence, and sends out a tweet for every new plane using [Twurl](https://github.com/twitter/twurl).
There are two major parts to install this. Each of these parts is described below.
- You must apply for your own Twitter Developer Account and create an app.
- You must follow the instructions below to
## Prerequisites
This is part of the [kx1t/docker-planefence] docker container. Nothing in this document will make sense outside the context of this container.
## Signing up for a Twitter Development Account and getting Twitter Credentials
You'll need a registered Twitter application. If you've never registered a Twitter application before, do the following:
- If you need help, [here's a webpage](https://elfsight.com/blog/2020/03/how-to-get-twitter-api-key/) with an excellent graphical walk-through of what you need to do. In short, this is the same as doing the following:
- Go to https://developer.twitter.com/en/apps and sign in to your Twitter account. Click "Create an app".
<img src="https://raw.githubusercontent.com/kx1t/planefence4docker/master/.img/create_an_app.png" width=100>
- If you've previously registered a Twitter application, it should be listed at https://apps.twitter.com/.
- Once you've registered an application, make sure to set your application's Access Level to "Read, Write and Access direct messages", otherwise you'll receive an error that looks like this: `Error processing your OAuth request: Read-only application cannot POST`
- A mobile phone number must be associated with your account in order to obtain write privileges. If your carrier is not supported by Twitter and you are unable to add a number, contact Twitter using https://support.twitter.com/forms/platform, selecting the last checkbox. Some users have reported success adding their number using the mobile site, https://mobile.twitter.com/settings, which seems to bypass the carrier check at the moment.
- Keep the page with your `Consumer API keys` open - you will need them in the next step.
Now, you're ready to authorize a Twitter account with your application. To proceed, type the following command at the prompt and follow the instructions (replace the numbers with your `API Key` and `API Secret Key` from above):
```
twurl authorize --consumer-key 1234YourConsumerKey6789 --consumer-secret 9876YourConsumerSecret4321
```
This command will direct you to a URL where you can sign-in to Twitter, authorize the application, and then enter the returned (7 digit?) PIN back into the terminal. This is a LONG URL that you need to copy and paste into your browser
```
Go to https://api.twitter.com/oauth/authorize?oauth_consumer_key=xxxxx&oauth_nonce=yyyy&oauth_signature=pppp&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1589303820&oauth_token=qqqq&oauth_version=1.0 and paste in the supplied PIN
```
If all works fine, you should see a final message: `Authorization successful`.
## Installing and configuring PlaneTweet
Let's assume that you already have installed PlaneFence.
Just in case you have an older version, let's refresh your local copy with the new one.
This should NOT affect your configuration or changes that you already made to PlaneFence
Give the following commands:
```
cd ~/git/planefence
git pull
```
Now, we install PlaneTweet. Some of these commands may give an error if you previously created the directory. Ignore those errors:
```
sudo mkdir /usr/share/planefence
sudo chmod a+rwx /usr/share/planefence
cp scripts/planetweet.sh /usr/share/planefence
chmod a+rwx /usr/share/planefence/planetweet.sh
```
In case your default configuration doesn't use the directory structure of dump1090-fa, make the following change:
```
nano /usr/share/planefence/planetweet.sh
```
Look for `HTMLDIR=/usr/share/dump1090-fa/html/planefence` and change this to the location of your PlaneFence directory
Once you are done, you can exit with `CTRL-o` (to save) `CTRL-x` (to exit)
## Running PlaneTweet as a Service using Systemd
If you want to run PlaneTweet as a Service on your Raspberry Pi, to be autostarted whenever
your Raspberry Pi reboot, then do the following:
```
sudo cp /home/pi/git/planefence/systemd/planetweet.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable planetweet
sudo systemctl start planetweet
```
As with every Systemd Service, you can control PlaneTweet with the following commands, whenever you feel like it:
```
systemctl status planetweet # shows the status of PlaneTweet. You can check if it's still running
sudo systemctl stop planetweet # stops the PlaneTweet Service. It will restart upon reboot
sudo systemctl disable planetweet # stops the PlaneTweet Service from starting upon reboot
sudo systemctl start planetweet # starts the PlaneTweet Service after you stopped it
sudo systemctl restart planetweet # stops and then restarts the PlaneTweet Service
```
# Summary of License Terms
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

View File

@@ -1,64 +0,0 @@
# WARNING !!!
This version of PlaneFence contains updates that are specific to make it run inside a Docker Container.
If you do not want to run this inside docker, please go to https://github.com/kx1t/planefence
# PlaneFence
Collection of scripts using Socket30003 logs to create a list of aircraft that fly low over your location.
Copyright 2020 by Ramon F. Kolb - Licensed under GPL3.0 - see separate license file.
For an example, see http://planefence.ramonk.net
This documentation is for PlaneFence v3.12. For a summary of changes since v1, see at the end of this document. (There was no publicly released PlaneFence v2.)
## Attributions, inclusions, and prerequisites
1. You must have a Raspberry Pi with a working version of dump1090, dump1090-fa, dump1090-mutability, or the equivalent dump978 versions installed. If you don't have this, stop right here. It makes no sense to continue unless you understand the basic functions of the ADSB receiver for Raspberry Pi
2. The scripts in this repository rely on [dump1090.socket30003](https://github.com/tedsluis/dump1090.socket30003), used and distributed under the GPLv3.0 license.
3. The instructions below err on the side of completeness. It may look a bit overwhelming, but if you follow each step to the letter, you should be able to set this up in 30 minutes or less.
What does this mean for you? Follow the installation instructions and you should be good :)
# Seeing your PlaneFence page
Once the app is running, you can find the results at `http://<address_of_rpi>/planefence`. Give it a few minutes after installation!
Replace `<address_of_rpi>` with whatever the address is you normally use to get to the SkyAware or Dump1090 map.
For reference, see (http://planefence.ramonk.net).
# Optional - Tweeting Your Updates
(not yet implemented)
Once you have PlaneFence completely up and running, you can add an option to send a Tweet for every overflying plane.
The setup of this is a bit complicated as you will have to register your own Twitter Developer Account, and get a
App Key for your application.
Detailed installation instructions can be accessed here:
https://github.com/kx1t/planefence/blob/master/README-twitter.md
If you want to see an example of how this works, go here: https://twitter.com/PlaneBoston
# Known Issues
- Planes that are seen multiple times during consecutive runs, may show up multiple times
- The script hasn't been thoroughly tested. Please provide feedback and exerpts of /tmp/planefence.log that show the activites around the time the issues occurred.
- The code is a bit messy and at times, disorganized. However, it's overly documented and should be easy to understand and adapt.
# Summary of License Terms
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
# Release History
- v1: PlaneFence based on BASH and Python scripts. Iterates through all logs every time it is invoked
- v1: Using CRON to invoke script every 2 minutes
- v2: never publicly released
- v3.0: total rewrite of planefence.sh and major simplification of planefence.py
- v3.0: only iterates through the socket30003 log lines that weren't processed previously. Reduced execution time dramatically, from ~1 minute for 1M lines, to an average of ~5 seconds between two runs that are 2 minutes apart.
- v3.0: uses Systemd to run planefence as a daemon; removed need for cronjob.
- v3.11: clean-up, minor fixes, updated documentation, etc.
- v.3.12: added auto-install script

View File

@@ -70,7 +70,7 @@ if [[ "x$FEEDER_LAT" == "x" ]] || [[ "$FEEDER_LAT" == "90.12345" ]]
then
sleep 10s
echo "----------------------------------------------------------"
echo "!!! STOP !!!! You haven't configured PlaneFence !!!!"
echo "!!! STOP !!!! You haven't configured FEEDER_LON and/or FEEDER_LAT for PlaneFence !!!!"
echo "Planefence will not run unless you edit it configuration."
echo "You can do this by pressing CTRL-c now and typing:"
echo "sudo nano -l ~/.planefence/planefence.config"
@@ -102,18 +102,31 @@ sed -i 's|\(^\s*LOGFILE=\).*|\1'"$LOGFILE"'|' /usr/share/planefence/planefence.c
[[ "x$FEEDER_LONG" != "x" ]] && sed -i 's/\(^\s*LON=\).*/\1'"\"$FEEDER_LONG\""'/' /usr/share/planefence/planefence.conf || { echo "Error - \$FEEDER_LONG not defined"; while :; do sleep 2073600; done; }
[[ "x$PF_MAXALT" != "x" ]] && sed -i 's/\(^\s*MAXALT=\).*/\1'"\"$PF_MAXALT\""'/' /usr/share/planefence/planefence.conf
[[ "x$PF_MAXDIST" != "x" ]] && sed -i 's/\(^\s*DIST=\).*/\1'"\"$PF_MAXDIST\""'/' /usr/share/planefence/planefence.conf
[[ "x$PF_NAME" != "x" ]] && sed -i 's/\(^\s*MY=\).*/\1'"\"$PF_NAME\""'/' /usr/share/planefence/planefence.conf
[[ "x$PF_NAME" != "x" ]] && sed -i 's/\(^\s*MY=\).*/\1'"\"$PF_NAME\""'/' /usr/share/planefence/planefence.conf || sed -i 's/\(^\s*MY=\).*/\1\"My\"/' /usr/share/planefence/planefence.conf
[[ "x$PF_TRACKSVC" != "x" ]] && sed -i 's|\(^\s*TRACKSERVICE=\).*|\1'"\"$PF_TRACKSVC\""'|' /usr/share/planefence/planefence.conf
[[ "x$PF_MAPURL" != "x" ]] && sed -i 's|\(^\s*MYURL=\).*|\1'"\"$PF_MAPURL\""'|' /usr/share/planefence/planefence.conf
[[ "x$PF_NOISECAPT" != "x" ]] && sed -i 's|\(^\s*REMOTENOISE=\).*|\1'"\"$PF_NOISECAPT\""'|' /usr/share/planefence/planefence.conf
[[ "x$PF_MAPURL" != "x" ]] && sed -i 's|\(^\s*MYURL=\).*|\1'"\"$PF_MAPURL\""'|' /usr/share/planefence/planefence.conf || sed -i 's|\(^\s*MYURL=\).*|\1|' /usr/share/planefence/planefence.conf
[[ "x$PF_NOISECAPT" != "x" ]] && sed -i 's|\(^\s*REMOTENOISE=\).*|\1'"\"$PF_NOISECAPT\""'|' /usr/share/planefence/planefence.conf || sed -i 's|\(^\s*REMOTENOISE=\).*|\1|' /usr/share/planefence/planefence.conf
if [[ "x$PF_SOCK30003HOST" != "x" ]]
then
a=$(sed 's|\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)|\1\_\2\_\3\_\4|g' <<< "$PF_SOCK30003HOST")
sed -i 's|\(^\s*LOGFILEBASE=/run/socket30003/dump1090-\).*|\1'"$a"'-|' /usr/share/planefence/planefence.conf
sed -i 's/127_0_0_1/'"$a"'/' /usr/share/planefence/planeheat.sh
unset a
a=$(sed 's|\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)|\1\_\2\_\3\_\4|g' <<< "$PF_SOCK30003HOST")
sed -i 's|\(^\s*LOGFILEBASE=/run/socket30003/dump1090-\).*|\1'"$a"'-|' /usr/share/planefence/planefence.conf
sed -i 's/127_0_0_1/'"$a"'/' /usr/share/planefence/planeheat.sh
unset a
else
sleep 10s
echo "----------------------------------------------------------"
echo "!!! STOP !!!! You haven't configured PF_SOCK30003HOST for PlaneFence !!!!"
echo "Planefence will not run unless you edit it configuration."
echo "You can do this by pressing CTRL-c now and typing:"
echo "sudo nano -l ~/.planefence/planefence.config"
echo "Once done, restart the container and this message should disappear."
echo "----------------------------------------------------------"
while true
do
sleep 99999
done
fi
[[ "x$PF_IGNOREDUPES" != "x" ]] && sed -i 's|\(^\s*IGNOREDUPES=\).*|\1ON|' /usr/share/planefence/planefence.conf
[[ "x$PF_IGNOREDUPES" != "x" ]] && sed -i 's|\(^\s*IGNOREDUPES=\).*|\1ON|' /usr/share/planefence/planefence.conf || sed -i 's|\(^\s*IGNOREDUPES=\).*|\1OFF|' /usr/share/planefence/planefence.conf
# -----------------------------------------------------------------------------------
#
# same for planeheat.sh
@@ -152,7 +165,7 @@ then
sed -i 's/\(^\s*PLANETWEET=\).*/\1/' /usr/share/planefence/planefence.conf
else
sed -i 's|\(^\s*PLANETWEET=\).*|\1'"$(sed -n '/profiles:/{n;p;}' /root/.twurlrc | tr -d '[:blank:][=:=]')"'|' /usr/share/planefence/planefence.conf
[[ "x$PF_TWATTRIB" != "x" ]] && sed -i 's|\(^\s*ATTRIB=\).*|\1'"\"$PF_TWATTRIB\""'|' /usr/share/planefence/planefence.conf
[[ "x$PF_TWATTRIB" != "x" ]] && sed -i 's|\(^\s*ATTRIB=\).*|\1'"\"$PF_TWATTRIB\""'|' /usr/share/planefence/planefence.conf
fi
fi
# -----------------------------------------------------------------------------------
@@ -170,26 +183,24 @@ do
[[ "x$PF_MAPZOOM" != "x" ]] && sed -i 's|\(^\s*var map =.*], \)\(.*\)|\1'"$PF_MAPZOOM"');|' $i
done
#
# if it still doesn't exist, something went drastically wrong and we need to set $PF_PLANEALERT to OFF!
if [[ ! -f /usr/share/planefence/persist/plane-alert-db.txt ]] && [[ "$PF_PLANEALERT" == "ON" ]]
then
echo "Cannot find or create the plane-alert-db.txt file. Disabling Plane-Alert."
echo "Do this on the host to get a base file:"
echo "sudo curl -s https://raw.githubusercontent.com/kx1t/docker-planefence/plane-alert/plane-alert-db.txt >~/.planefence/plane-alert-db.txt"
echo "curl -s https://raw.githubusercontent.com/kx1t/docker-planefence/plane-alert/plane-alert-db.txt >~/.planefence/plane-alert-db.txt"
echo "and then restart this docker container"
PF_PLANEALERT="OFF"
fi
# make sure $PLANEALERT is set to ON in the planefence.conf file, so it will be invoked:
sed -i 's|\(^\s*PLANEALERT=\).*|\1'"\"ON\""'|' /usr/share/planefence/planefence.conf
[[ "$PF_PLANEALERT" == "ON" ]] && sed -i 's|\(^\s*PLANEALERT=\).*|\1'"\"ON\""'|' /usr/share/planefence/planefence.conf || sed -i 's|\(^\s*PLANEALERT=\).*|\1'"\"OFF\""'|' /usr/share/planefence/planefence.conf
# Now make sure that the file containing the twitter IDs is rewritten with 1 ID per line
[[ "x$PF_PA_TWID" != "x" ]] && tr , "\n" <<< "$PF_PA_TWID" > /usr/share/plane-alert/plane-alert.twitterid || rm -f /usr/share/plane-alert/plane-alert.twitterid
# and write the rest of the parameters into their place
[[ "x$PF_PA_TWID" != "x" ]] && sed -i 's|\(^\s*TWITTER=\).*|\1'"\"true\""'|' /usr/share/plane-alert/plane-alert.conf || sed -i 's|\(^\s*TWITTER=\).*|\1'"\"false\""'|' /usr/share/plane-alert/plane-alert.conf
[[ "x$PF_NAME" != "x" ]] && sed -i 's|\(^\s*NAME=\).*|\1'"\"$PF_NAME\""'|' /usr/share/plane-alert/plane-alert.conf
[[ "x$PF_NAME" != "x" ]] && sed -i 's|\(^\s*NAME=\).*|\1'"\"$PF_NAME\""'|' /usr/share/plane-alert/plane-alert.conf || sed -i 's|\(^\s*NAME=\).*|\1My|' /usr/share/plane-alert/plane-alert.conf
[[ "x$PF_MAPURL" != "x" ]] && sed -i 's|\(^\s*ADSBLINK=\).*|\1'"\"$PF_MAPURL\""'|' /usr/share/plane-alert/plane-alert.conf
[[ "x$PF_MAPZOOM" != "x" ]] && sed -i 's|\(^\s*MAPZOOM=\).*|\1'"\"$PF_MAPZOOM\""'|' /usr/share/plane-alert/plane-alert.conf