Separate files into those used for setup and those used at runtime.

Files used for both will go in the run tree.
This commit is contained in:
cimryan
2018-10-24 20:55:29 -07:00
parent ef10b2ec67
commit e875763e58
27 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
OPTIONAL: You can choose to integrate with [Pushover](https://pushover.net) to get a push notification to your phone when the copy process is done. Depending on your wireless network speed/connection, copying files may take some time, so a push notification can help confirm that the process finished. If no files were copied (i.e. all manually saved dashcam files were already copied, no notification will be sent.). The Pushover service is free for up to 7,500 messages per month, but the [iOS](https://pushover.net/clients/ios)/[Android](https://pushover.net/clients/android) apps do have a one time cost, after a free trial period. *This also assumes your Pi is connected to a network with internet access.*
1. Create a free account at Pushover.net, and install and log into the mobile Pushover app.
1. On the Pushover dashboard on the web, copy your **User key**.
1. [Create a new Application](https://pushover.net/apps/build) at Pushover.net. The description and icon don't matter, choose what you prefer.
1. Copy the **Application Key** for the application you just created. The User key + Application Key are basically a username/password combination to needed to send the push.
1. Run these commands, substituting your user key and app key in the appropriate places. No `"` are needed.
```
export pushover_enabled=true
export pushover_user_key=put_your_userkey_here
export pushover_app_key=put_your_appkey_here
```

View File

@@ -0,0 +1,43 @@
# Setting up the Pi without a monitor using a Mac or Linux
You can setup the Pi to connect to your Wifi network, and also provide the option to connect over USB networking (Rasberry Pi Zero W or other recent Pi's).
**What is USB networking?**
Basically what you're doing is using the Pi's capability to emulate a network connection over USB. So you need to get the Pi (the guest) set up to load the proper modules to do so, and then connect from your machine (the host) using a shell (like iTerm+SSH on macOS). It's an alternative to Wifi if needed.
## Use the update script to setup Wifi and USB networking
A [script](https://raw.githubusercontent.com/cimryan/teslausb/master/mac_linux_archive/setup-piForHeadlessConfig.sh is provided to automatically update your SD card so the first time you boot it on your Pi, USB networking and Wifi will automatically be configured.
If you prefer not to run the script, it's also a useful reference for the steps you'll need to take.
> It's important you do these steps **before you boot the Pi the first time with the SD card inserted**.
1. Ensure you've flashed your Raspbian image to your SD card.
1. If the `boot` folder isn't showing on your computer, eject and re-insert the SD card into your computer, **not the Raspberry Pi**.
1. Change to the directory where the SD card's `boot` folder (containing `cmdline.txt`) is located. On a Mac, this will be `/Volumes/boot`. On Linux the location may vary.
1. Run the following commands:
```
wget https://raw.githubusercontent.com/cimryan/teslausb/master/mac_linux_archive/setup-piForHeadlessConfig.sh
chmod +x setup-piForHeadlessConfig.sh
```
1. Set your SSID (Wifi network name) and WIFIPASS environment variables. The script will insert them into the `wpa_supplicant.conf` when creating it:
```
export SSID=your_ssid_here
export WIFIPASS=your_wifi_password_here
```
1. Run the script:
`./setup-piForHeadlessConfig.sh`
1. If all goes well, the script will report:
`-- Files updated and ready for Wifi and SSH over USB --`
1. Eject the SD card safely, insert into your Pi, and reboot. If the Pi is connected over USB to your host, and/or if the Wifi setup went correctly, you should be able to `ssh pi@raspberrypi.local`. The default password is `raspberry`.
> Note: If you receive an error indicating that the host id has changed, edit your computer's `~/.ssh/known_hosts` file. Find the line with the IP address of your Pi, or labeled "raspberrypi.local" and delete the entire line. You're especially likely to encounter this error if you're following these instructions for a second time.
## Manual/other resources
* [Gist (text file) showing example steps to setup USB networking](https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a)
If manually configuring the Pi vs using the update script, be sure to delete the `init=/usr/lib/raspi-config/init_resize.sh` parameter from cmdline.txt to prevent the os partition from being expanded to fill the drive.

View File

@@ -0,0 +1,39 @@
# Seting up the Pi without a monitor using Windows
1. Download and install: [Notepad++](https://notepad-plus-plus.org/) Alternatively, any other text editor which is capable of editing files with Unix-style line endings.
1. Optional: Watch [this video](https://www.youtube.com/watch?v=xj3MPmJhAPU) to get an idea of the process. The steps from the video are partially automated, below.
1. Remove the MicroSD card from your computer and reinsert it. Do not at any point during the setup of the USB drive allow Windows to format any partition on any drive.
1. Note that a new drive labeled "boot" has appeared on your computer. Note the drive letter of that drive.
1. Right-click on your Start menu icon and select "Windows PowerShell (Admin)".
1. Right-click the title bar of the window and select "Properties". Ensure that the "Use legacy console" checkbox is unchecked and activate the OK button. If it was checked before you unchecked it, close te PowerShell window and go back to step 3. If it wasn't, proceed onto the next step.
1. Run the following command:
> Note: You can paste into the PowerShell window by right-clicking. The text will appear at the position of the cursor, not necessarily at the position where you click.
```
Set-ExecutionPolicy -Scope CurrentUser Unrestricted
```
1. Enter Y when prompted, and press Enter.
1. Run the following commands:
```
cd ~
wget https://raw.githubusercontent.com/cimryan/teslausb/master/setup-piForHeadlessConfig.ps1 -OutFile setup-piForHeadlessConfig.ps1
./setup-piForHeadlessConfig.ps1 -Verbose
```
1. Enter the single letter of the "boot" drive and press Enter.
1. Enter the SSID of your WiFi network and press Enter.
1. Enter the Pre-Shared Key of your WiFi network and press Enter.
1. Eject the sd card.
1. Move the sd card to the Pi.
1. Connect a micro usb cable to the port labeled "USB" on the Raspberry Pi, and to the PC.
1. On the PC, press your Windows key, type Control Panel.
1. Open "Network and Sharing Center"
1. Click "Change adapter settings"
1. Wait for something labeled "USB Ethernet/RNDIS Gadget" to appear.
1. Enter this command in your PowerShell window:
```
ssh pi@raspberrypi.local
```
> Note: If you receive an error indicating that the host id has changed and you can't work around it you'll need to delete the ~\\.ssh\known_hosts file. You're especially likely to encounter this error if you're following these instructions for a second time.
1. If you get an "unknown host" error message install Bonjour: https://support.apple.com/kb/DL999 and go back to step 15.
1. You should be prompted for the password for the user "pi". Enter
```
raspberry
```

43
doc/SetupRSync.md Normal file
View File

@@ -0,0 +1,43 @@
# Introduction
This guide will show you how to utilize [rsync](https://rsync.samba.org/) to archive your saved TeslaCam footage on a remote storage server. In my case, I use this for a networked pi storage server.
This guide makes the following assumptions:
1. You are running your own ftp/rsync server that you have admin rights to, or can at least add a public key to its `~/.ssh/authorized_keys` file
1. The ftp/rsync server has rsync installed (raspbian automatically does)
2. You have **NOT** run the `setup-teslacam` script yet
# Step 1: Authentication
Similar to sftp, rsync by default utilizes ssh to connect to a remote server and transfer files. This guide will use a generated ssh keypair, hence the first assumption above.
1. On your teslausb pi, run `ssh-keygen` to generate an ssh key **for the ROOT user!** If you followed the previous steps, you should have already ran `sudo -i` to become the root user on the telsausb pi. If you didn't, run `sudo -i` and re-run `ssh-keygen`. You can be sure that it is generating for root if it asks to store the key in `/root/.ssh/` (versus something like `/home/pi/.ssh`).
1. Add the contents of the newly generated `/root/.ssh/id_rsa.pub` file from your teslausb pi to the storage server's `~/.ssh/authorized_keys` file. This will allow a nice and easy connection through rsync, no passwords needed!
1. Lastly, you will need to authorize the connection to the FTP/Rsync server and test that the key works, so try connecting to the server (through ssh), and **if it asks if you wish to continue connecting, make sure to type `yes`!** If you do not do this, rsync will fail to connect and thus fail to archive your clips.
# Step 2: Exports
To be able to configure the teslausb pi use rsync, you'll need to export a few things. On your teslausb pi, run:
```
export RSYNC_ENABLE=true
export RSYNC_USER=<ftp username>
export RSYNC_SERVER=<ftp IP/host>
export RSYNC_PATH=<destination path to save in>
```
Explanations for each:
* `RSYNC_ENABLE`: `true` for enabling rsync
* `RSYNC_USER`: The user on the FTP server
* `RSYNC_SERVER`: The IP address/hostname of the destination machine
* `RSYNC_PATH`: The path on the destination machine where the files will be saved
An example (of my) config is listed below:
```
export RSYNC_ENABLE=true
export RSYNC_USER=pi
export RSYNC_SERVER=192.168.1.254
export RSYNC_PATH=/mnt/PIHDD/TeslaCam/
```
***Note: RSYNC_ENABLE=true is going to disable the default archive server. Perhaps future releases will allow both to be defined and function at the same time, for redundancy, but for now just pick one that you'll want the most.***
You should be ready to run the setup script now, so return back to step 8 of the [Main Instructions](README.md).