From 59e3f8aac12ff25125b7fda1c2f8fd4b1c36a4dc Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Wed, 17 Oct 2018 22:17:34 -0500 Subject: [PATCH 1/7] Mac folder, config updater script, updated readmes. --- .DS_Store | Bin 6148 -> 8196 bytes GetShellWitoutMonitorOnLinux.md | 47 +++++++++-- README.md | 35 +++++--- mac_linux_archive/update-rpi-mac-linux.sh | 97 ++++++++++++++++++++++ 4 files changed, 162 insertions(+), 17 deletions(-) create mode 100755 mac_linux_archive/update-rpi-mac-linux.sh diff --git a/.DS_Store b/.DS_Store index ad3d1f64d179c06c9343837bf0549eb3f12b7263..567b773d94b99ac317704e42aed77405de26ec6b 100644 GIT binary patch literal 8196 zcmeHLU2GIp6h5adFf&j(MUc)4bkn9%wMe%uZIB(1;h zP^wj4G^z0k6{0Vim>7H_!V`(`Vl@6dC<;n=@WBUt@zH2B@!Wf72`v;7joQSy$=q}2 zo^$R!=bP`&>{$T7o`Mkrr~?3rE+*Bb)ZL~rJ-cpc6~PQsBKZUOV1o$;MB(5q*5O2m zK!`wyK!`wyK#0IXK!Cp4tV#2H_k}j>Lj*zu{+9@__d}E}CgXve7Lva@sN*F7$ts%W zjmA_5aGz)(|`?k4BEcx2r~B5k{A@{q3e z&kR>zxY&L7eX_3c7rb&4w~4Mqxi}QP3nlO%1v=y*0~0h`1T$UoazS*Tq;t0A`K_&2 zu%fbR(c&eNBrTPyrKgh-f6m zn0fAO877(RAF>?7E%mqs$ME<%NuiKsS&~y~-Q;9@dwWZ?t+RcqB|5peJ=PN4)YUOH zB}=QDV%z!-WRD)3JU;c@DFHqPZ$Eluv)gG7?;X>&y<)FOyW;h7+E>eI%gR!%?+Ins zu$6J0q;^CU7e%D~T80tAm=9b@AxV6CeY2(v zdX%fG2Zk*h6lL%*J!sXV5Ln=`HbvWO>uJ+g4OzH#b}8CWQKYOs8BA{3s%XP>wz8C> zSBovdbi7;B#@WuhbkEs354-Vl7j^Y>^_zc>ZMF&gxJidT0;t8C=llTUn!qfN;p2ZLF9G=Gy z@giQrPw_MS8o$G9BF>63iTlNUxyS1?s-bA_aCV8r!P%`Cza5DqkL^?v|0#*TT_%`& z&&pNn8k;w?b#3jw@r36*)0@e~86_ygsZ^#4f2gzg$ylI8?o-yz$MLBI1d}J5u5N~ z+=wx3!w%er+li6g*o(WcA9v#bv2qOe<2a^JCsrQjtjyt2Jch?{irD!QzD(SF1z!!= z`6j-F@8X#`T&Rfcg+9)|3XhAj4wnW zMBr~AfK`cPqK6ik?={A1?I>Lb=wgl8O$*6gsN>~0NnVbV49anC8zocb6A$FHkTgT> WU;iWEAN~;=e*eSoKPUDA@BRcdqI7}) delta 160 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUEV6q~50D9Qwq2aDx1lrt1F#4{u^6m2YA z&N$gXhGp`7fek{2Its?7hP65h)#l~~ItnJnW|J2RhD>%7Ke(|$k!3ME2Ztat&=4RH l;06+|Aj3BnerKM{FXITZ9b`NUhz42(vK}n9Ii6<@GXM?&8-4%) diff --git a/GetShellWitoutMonitorOnLinux.md b/GetShellWitoutMonitorOnLinux.md index 72c7c41..5f6f491 100644 --- a/GetShellWitoutMonitorOnLinux.md +++ b/GetShellWitoutMonitorOnLinux.md @@ -1,10 +1,43 @@ # Seting up the Pi without a monitor using a Mac or Linux -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). -Here are a few ways to accomplish this -* [Gist (text file) showing example steps and discussion thread about issues, etc](https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a) -* [Script to setup the Pi for connecting over USB](https://github.com/BigNate1234/rpi-USBSSH) - * (I.e. First write the OS image to the SD card, then this script will make the changes to the card so you can boot it and access it over the USB cable. - * **Assumes the SD card for the Pi is mounted at /Volumes/boot , and that you can use `sh`/`bash`**. This _should_ be the default for a Mac; if using something else, modify the script accordingly. +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). -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. + +**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/update-rpi-mac-linux.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 configure. + +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/update-rpi-mac-linux.sh + chmod +x update-rpi-mac-linux.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: + `./update-rpi-mac-linux.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. diff --git a/README.md b/README.md index 5dcdc03..9e9013f 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Download and install: ## Create your archive ### Hosting on Windows -Set up a share on a Windows machine to host the archive. These instructions assume that you created a share named "SailfishCam" on the server "Nautilus". It is recommended that you create a new user. Grant the user you'll be using read/write access to the share. These instructions will assume that the user you've created is named "sailfish" and that the password for this user is "pa$$w0rd". +Set up a share on a Windows (or macOS using Sharing, or Linux using Samba) machine to host the archive. These instructions assume that you created a share named "SailfishCam" on the server "Nautilus". It is recommended that you create a new user. Grant the user you'll be using read/write access to the share. These instructions will assume that the user you've created is named "sailfish" and that the password for this user is "pa$$w0rd". Get the IP address of the archive machine. You'll need this later, so write it down, somewhere. You can do this by opening a command prompt on the archive machine and typing ipconfig. Get the IP address from the line labeled "IPv4 Address". These instructions will assume that the IP address of the archive server is 192.168.0.41. @@ -75,22 +75,31 @@ There are four phases to setting up the Pi: > Note: you don't need to uncompress the zip file you downloaded. ### Get a shell on the Pi -> Regardless of which way you use to access the Pi (Keyboard+HDMI or USB networking), **before you boot the Pi for for the first time with the MicroSD inserted**, edit the /boot/cmdline.txt file on the MicroSD to delete the parameter "init=/usr/lib/raspi-config/init_resize.sh". +> Regardless of which way you use to access the Pi (Keyboard+HDMI or USB networking), **before you boot the Pi for for the first time with the MicroSD inserted**, verify that the /boot/cmdline.txt file on the MicroSD does not contain the parameter "init=/usr/lib/raspi-config/init_resize.sh". Delete it if present. -If you have a monitor with an hdmi input, a mini hdmi to hdmi cable, a usb keyboard and a micro usb power cable you can hook up the devices to the Pi and configure it directly. +##### Use a monitor/keyboard/mouse +If you have a monitor with an HDMI input, a Mini HDMI to HDMI cable, a usb keyboard and a micro usb power cable you can hook up the devices to the Pi and configure it directly. 1. Insert the MicroSD card into the Pi. 1. Connect the keyboard, and monitor to the Pi. 1. Connect the power supply to the Pi using the port labeld "PWR" on the circuitboard. 1. When you're prompted for the password for the user "pi" use "raspberry" without the quotes. 1. Now skip to section below titled "Get the scripts onto the Pi". -If you don't have a keyboard/HDMI setup to boot the Pi and edit/transfer files directly, you'll probably want to connect to the Pi over USB. -* If you're using Windows, follow [these instructions](GetShellWithoutMonitorOnWindows.md), then skip down to the section titled "Get the scripts onto the Pi". -* If you're using Linux or a Mac, follow [these instructions](GetShellWitoutMonitorOnLinux.md), then proceed to the next section. +##### Windows (Setup USB Networking) + +If you don't have a keyboard/HDMI setup to boot the Pi and edit/transfer files directly, you'll probably want to connect to the Pi over Wifi or USB networking. +* Follow [these instructions](GetShellWithoutMonitorOnWindows.md), then skip down to the section titled "Get the scripts onto the Pi". + +##### macOS or Linux (Setup Wifi or USB Networking) +* Follow [these instructions](GetShellWitoutMonitorOnLinux.md), then proceed to the next section. -### Get the scripts onto the Pi -Now that you have a shell on the Pi you can turn the Pi into a smart USB drive. +### Set up Wifi on the Pi (manually) + +If you don't yet have Wifi running from the previous section, use these instructions to get it set up. Otherwise, skip to **Set up the USB Storage Functionality**. + +Now that you have an `ssh` shell on the Pi over USB networking, you can set up Wifi and continue with setup. + 1. Enter the following commands: ``` sudo -i @@ -114,7 +123,13 @@ Now that you have a shell on the Pi you can turn the Pi into a smart USB drive. ifconfig wlan0 ``` 1. Verify that there's an IP address on your subnet assigned. If you don't see the IP address wait for a couple of seconds and re-run the command. -1. Try to ping your archive server from the Pi. + +### Set up the USB Storage Functionality + +Now that you have Wifi up and running, it's time to set up the USB Storage and scripts that will manage the dashcam and (optionally) music storage. + +1. SSH to the Pi and run `sudo -i` +1. Try to ping your archive server from the Pi. In this example the server is named `nautilus`. ``` ping -c 3 nautilus ``` @@ -122,7 +137,7 @@ Now that you have a shell on the Pi you can turn the Pi into a smart USB drive. ``` ping 192.168.0.41 ``` -1. If you can't ping the archive server by IP address from the Pi you should go do whatever you need to on your network to fix that. If you can't reach the archive server by name from the Pi but you can by IP address then use its IP address, below, in place of its name. +1. If you can't ping the archive server by IP address from the Pi, you should go do whatever you need to on your network to fix that. If you can't reach the archive server by name, from the Pi but you can by IP address, then use its IP address, below, in place of its name. 1. Run these commands, subsituting your values. The last line is the percent of the drive you want to allocate for dashcam storage. The remaining percentage will be allocated for music. ``` export archiveserver=Nautilus diff --git a/mac_linux_archive/update-rpi-mac-linux.sh b/mac_linux_archive/update-rpi-mac-linux.sh new file mode 100755 index 0000000..7f0121d --- /dev/null +++ b/mac_linux_archive/update-rpi-mac-linux.sh @@ -0,0 +1,97 @@ +#!/bin/bash +#|| @license +#|| | This program is free software; you can redistribute it and/or +#|| | modify it under the terms of the GNU Lesser General Public +#|| | License as published by the Free Software Foundation; version +#|| | 2.1 of the License. +#|| | +#|| | 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 +#|| | Lesser General Public License for more details. +#|| | +#|| | You should have received a copy of the GNU Lesser General Public +#|| | License along with this library; if not, write to the Free Software +#|| | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#|| # + +# Script repurposed fromhttps://github.com/BigNate1234/rpi-USBSSH +# +# This script will modify the cmdline.txt file on a freshly flashed Raspbian Stretch/Lite +# It readies it for SSH, USB OTG, USB networking, and Wifi +# +# Run it in a terminal in the "boot" directory of the flashed MicroSD card +# Ex: +# cd /Volumes/boot (or wherever the boot folder is mounted) +# chmod+x update-rpi-mac-linux.sh (if not executable already) +# ./update-rpi-mac-linux.sh +# +# Put the card in your Pi, and reboot! + +# Creates the ssh file if needed, since Raspbian now disables +# ssh by default if the file isn't present + +if [ ! -r "cmdline.txt" ]; then + echo 'STOP: Run this script in the "boot" directory where cmdline.txt is located.' + exit 1 +fi + +if [ ! -n "${SSID+x}" ] || [ ! -n "${WIFIPASS+x}" ] +then + echo 'STOP: You need to specify your wifi name and password first. Run: ' + echo " " + echo ' export SSID=your_ssid' + echo ' export WIFIPASS=your_wifi_password' + echo " " + echo "Be sure to replace the values with your SSID (network name) and password." + exit 1 +fi + +if [ ! -f ssh ]; then + touch ssh +fi + +# Append the dwc2 module if not set (USB OTG) + +dt=$(cat config.txt | grep "dtoverlay=dwc2") +if [ "$dt" != "dtoverlay=dwc2" ]; then + echo "dtoverlay=dwc2" >> config.txt +fi + +# Append the g_ether module if not set (USB networking) + +mod=$(cat cmdline.txt | grep -o "modules-load=dwc2,g_ether") +if [ "$mod" != "modules-load=dwc2,g_ether" ]; then + sed -i '' '$ s/$/ modules-load=dwc2,g_ether/' cmdline.txt + # Only appends to end of line, not newline +fi + +# Remove the automatic filesystem expansion action +# This is specific to the teslausb project; normally the +# Raspbian image will automatically expand the filesystem to include the +# entire SD card. + +mod=$(cat cmdline.txt | grep -o "init=/usr/lib/raspi-config/init_resize.sh") +if [ "$mod" = "init=/usr/lib/raspi-config/init_resize.sh" ]; then + sed -i'.bak' -e 's/ init=\/usr\/lib\/raspi-config\/init_resize.sh//g' cmdline.txt +fi + +# Sets up wifi credentials so wifi will be +# auto configured on first boot + + +cat << EOF >> wpa_supplicant.conf +ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev +update_config=1 + +network={ + ssid=$SSID + psk=$WIFIPASS + key_mgmt=WPA-PSK +} +EOF + +cd +echo "" +echo '-- Files updated and ready for Wifi and SSH over USB --' +echo "" From 9aa5d0114d747e594f73e4b8fc2dbe7e7fcb4418 Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Wed, 17 Oct 2018 22:23:35 -0500 Subject: [PATCH 2/7] Section headings update for clarity --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9e9013f..e64df37 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ There are four phases to setting up the Pi: ### Get a shell on the Pi > Regardless of which way you use to access the Pi (Keyboard+HDMI or USB networking), **before you boot the Pi for for the first time with the MicroSD inserted**, verify that the /boot/cmdline.txt file on the MicroSD does not contain the parameter "init=/usr/lib/raspi-config/init_resize.sh". Delete it if present. -##### Use a monitor/keyboard/mouse +#### Use a monitor/keyboard/mouse If you have a monitor with an HDMI input, a Mini HDMI to HDMI cable, a usb keyboard and a micro usb power cable you can hook up the devices to the Pi and configure it directly. 1. Insert the MicroSD card into the Pi. 1. Connect the keyboard, and monitor to the Pi. @@ -85,13 +85,13 @@ If you have a monitor with an HDMI input, a Mini HDMI to HDMI cable, a usb keybo 1. When you're prompted for the password for the user "pi" use "raspberry" without the quotes. 1. Now skip to section below titled "Get the scripts onto the Pi". -##### Windows (Setup USB Networking) +#### Windows (Setup USB Networking) If you don't have a keyboard/HDMI setup to boot the Pi and edit/transfer files directly, you'll probably want to connect to the Pi over Wifi or USB networking. -* Follow [these instructions](GetShellWithoutMonitorOnWindows.md), then skip down to the section titled "Get the scripts onto the Pi". +* Follow [these instructions](GetShellWithoutMonitorOnWindows.md), then skip down to the section titled **Set up Set up Wifi on the Pi (manually)y**. -##### macOS or Linux (Setup Wifi or USB Networking) -* Follow [these instructions](GetShellWitoutMonitorOnLinux.md), then proceed to the next section. +#### macOS or Linux (Setup Wifi or USB Networking) +* Follow [these instructions](GetShellWitoutMonitorOnLinux.md), then proceed to the section **Set up the USB Storage Functionality**. ### Set up Wifi on the Pi (manually) From e917829a9fb4872be23368d057eae315d33b0959 Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Thu, 18 Oct 2018 07:32:08 -0500 Subject: [PATCH 3/7] Quotes in updater script, Readme updates, remount script. --- .DS_Store | Bin 8196 -> 0 bytes ...nLinux.md => GetShellWithoutMonitorOnLinux.md | 0 README.md | 7 ++++++- mac_linux_archive/update-rpi-mac-linux.sh | 11 ++++++++--- windows_archive/archive-teslacam-clips | 2 +- windows_archive/remountfs_rw | 9 +++++++++ windows_archive/setup-teslausb | 7 +++++++ 7 files changed, 31 insertions(+), 5 deletions(-) delete mode 100644 .DS_Store rename GetShellWitoutMonitorOnLinux.md => GetShellWithoutMonitorOnLinux.md (100%) create mode 100644 windows_archive/remountfs_rw diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 567b773d94b99ac317704e42aed77405de26ec6b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHLU2GIp6h5adFf&j(MUc)4bkn9%wMe%uZIB(1;h zP^wj4G^z0k6{0Vim>7H_!V`(`Vl@6dC<;n=@WBUt@zH2B@!Wf72`v;7joQSy$=q}2 zo^$R!=bP`&>{$T7o`Mkrr~?3rE+*Bb)ZL~rJ-cpc6~PQsBKZUOV1o$;MB(5q*5O2m zK!`wyK!`wyK#0IXK!Cp4tV#2H_k}j>Lj*zu{+9@__d}E}CgXve7Lva@sN*F7$ts%W zjmA_5aGz)(|`?k4BEcx2r~B5k{A@{q3e z&kR>zxY&L7eX_3c7rb&4w~4Mqxi}QP3nlO%1v=y*0~0h`1T$UoazS*Tq;t0A`K_&2 zu%fbR(c&eNBrTPyrKgh-f6m zn0fAO877(RAF>?7E%mqs$ME<%NuiKsS&~y~-Q;9@dwWZ?t+RcqB|5peJ=PN4)YUOH zB}=QDV%z!-WRD)3JU;c@DFHqPZ$Eluv)gG7?;X>&y<)FOyW;h7+E>eI%gR!%?+Ins zu$6J0q;^CU7e%D~T80tAm=9b@AxV6CeY2(v zdX%fG2Zk*h6lL%*J!sXV5Ln=`HbvWO>uJ+g4OzH#b}8CWQKYOs8BA{3s%XP>wz8C> zSBovdbi7;B#@WuhbkEs354-Vl7j^Y>^_zc>ZMF&gxJidT0;t8C=llTUn!qfN;p2ZLF9G=Gy z@giQrPw_MS8o$G9BF>63iTlNUxyS1?s-bA_aCV8r!P%`Cza5DqkL^?v|0#*TT_%`& z&&pNn8k;w?b#3jw@r36*)0@e~86_ygsZ^#4f2gzg$ylI8?o-yz$MLBI1d}J5u5N~ z+=wx3!w%er+li6g*o(WcA9v#bv2qOe<2a^JCsrQjtjyt2Jch?{irD!QzD(SF1z!!= z`6j-F@8X#`T&Rfcg+9)|3XhAj4wnW zMBr~AfK`cPqK6ik?={A1?I>Lb=wgl8O$*6gsN>~0NnVbV49anC8zocb6A$FHkTgT> WU;iWEAN~;=e*eSoKPUDA@BRcdqI7}) diff --git a/GetShellWitoutMonitorOnLinux.md b/GetShellWithoutMonitorOnLinux.md similarity index 100% rename from GetShellWitoutMonitorOnLinux.md rename to GetShellWithoutMonitorOnLinux.md diff --git a/README.md b/README.md index e64df37..40e9161 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ If you don't have a keyboard/HDMI setup to boot the Pi and edit/transfer files d * Follow [these instructions](GetShellWithoutMonitorOnWindows.md), then skip down to the section titled **Set up Set up Wifi on the Pi (manually)y**. #### macOS or Linux (Setup Wifi or USB Networking) -* Follow [these instructions](GetShellWitoutMonitorOnLinux.md), then proceed to the section **Set up the USB Storage Functionality**. +* Follow [these instructions](GetShellWithoutMonitorOnLinux.md), then proceed to the section **Set up the USB Storage Functionality**. ### Set up Wifi on the Pi (manually) @@ -168,6 +168,9 @@ Now that you have Wifi up and running, it's time to set up the USB Storage and s ``` reboot ``` + +After reboot, the Pi hostname will become `teslausb`, so future `ssh` sessions will be `ssh pi@teslausb.local`. + ### Get the Pi set up for your Tesla. If you set up the Pi with a keyboard and a monitor disconnect it and connect it to a PC. If you're using a cable be sure to use the port labeled "usb" on the circuitboard. 1. Wait for the Pi to show up on the PC as a USB drive. @@ -189,4 +192,6 @@ sudo -i mount / -o remount,rw mount /boot -o remount,rw ``` +A script has been provided as `/root/remountfs_rw` to run the mount commands for you more easily. + Then make whatever changes you need to. The next time the system boots the partitions will once again be read-only. diff --git a/mac_linux_archive/update-rpi-mac-linux.sh b/mac_linux_archive/update-rpi-mac-linux.sh index 7f0121d..5658def 100755 --- a/mac_linux_archive/update-rpi-mac-linux.sh +++ b/mac_linux_archive/update-rpi-mac-linux.sh @@ -15,7 +15,7 @@ #|| | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #|| # -# Script repurposed fromhttps://github.com/BigNate1234/rpi-USBSSH +# Script repurposed from https://github.com/BigNate1234/rpi-USBSSH # # This script will modify the cmdline.txt file on a freshly flashed Raspbian Stretch/Lite # It readies it for SSH, USB OTG, USB networking, and Wifi @@ -79,18 +79,23 @@ fi # Sets up wifi credentials so wifi will be # auto configured on first boot +if [ -r "wpa_supplicant.conf" ] +then + rm wpa_supplicant.conf +fi cat << EOF >> wpa_supplicant.conf ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ - ssid=$SSID - psk=$WIFIPASS + ssid="$SSID" + psk="$WIFIPASS" key_mgmt=WPA-PSK } EOF + cd echo "" echo '-- Files updated and ready for Wifi and SSH over USB --' diff --git a/windows_archive/archive-teslacam-clips b/windows_archive/archive-teslacam-clips index 681392c..3d3fdf7 100644 --- a/windows_archive/archive-teslacam-clips +++ b/windows_archive/archive-teslacam-clips @@ -81,7 +81,7 @@ function move_clips_to_archive () { done log "Moved $move_count file(s)." - if [ -r "/root/.teslaCamPushoverCredentials" ] + if [ -r "/root/.teslaCamPushoverCredentials" ] && [ $move_count > 0 ] then log "Sending Pushover message for copied files." /root/bin/send-pushover.sh $move_count diff --git a/windows_archive/remountfs_rw b/windows_archive/remountfs_rw new file mode 100644 index 0000000..9638b11 --- /dev/null +++ b/windows_archive/remountfs_rw @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Remounting / as read/write" +mount / -o remount,rw +echo "Remounting /boot as read/write" +mount /boot -o remount,rw +echo "Done. Make any changes needed, and reboot the Pi when ready." +echo "Filesystems / and /boot will be mounted as read only after reboot." + diff --git a/windows_archive/setup-teslausb b/windows_archive/setup-teslausb index 045360c..3925e35 100644 --- a/windows_archive/setup-teslausb +++ b/windows_archive/setup-teslausb @@ -133,8 +133,15 @@ function configure_archive_scripts () { chmod +x archive-teslacam-clips popd echo "Configured the archive scripts." + + pushd /root + wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/remountfs_rw + chmod +x remountfs_rw + popd + echo "Downloaded script to remount filesystems read/write if needed (/root/remountfs_rw)." } + function configure_pushover_scripts() { if [ ${user_enabled_pushover} = "true" ] then From 3e687106e109ff246bc8abb06bb6fedc400b8b60 Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Thu, 18 Oct 2018 07:35:45 -0500 Subject: [PATCH 4/7] Some typos in the Mac and Linux readme. --- GetShellWithoutMonitorOnLinux.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GetShellWithoutMonitorOnLinux.md b/GetShellWithoutMonitorOnLinux.md index 5f6f491..9bb6061 100644 --- a/GetShellWithoutMonitorOnLinux.md +++ b/GetShellWithoutMonitorOnLinux.md @@ -1,4 +1,4 @@ -# Seting up the Pi without a monitor using a Mac or Linux +# 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). @@ -8,7 +8,7 @@ Basically what you're doing is using the Pi's capability to emulate a network co ## Use the update script to setup Wifi and USB networking -A [script](https://raw.githubusercontent.com/cimryan/teslausb/master/mac_linux_archive/update-rpi-mac-linux.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 configure. +A [script](https://raw.githubusercontent.com/cimryan/teslausb/master/mac_linux_archive/update-rpi-mac-linux.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. From 06327023bfa2a724f572af2d2b7da7e0db2efd21 Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Thu, 18 Oct 2018 07:37:34 -0500 Subject: [PATCH 5/7] Small clarifying text on deleting filesystem expansion parameter. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 40e9161..3bd517b 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ There are four phases to setting up the Pi: > Note: you don't need to uncompress the zip file you downloaded. ### Get a shell on the Pi -> Regardless of which way you use to access the Pi (Keyboard+HDMI or USB networking), **before you boot the Pi for for the first time with the MicroSD inserted**, verify that the /boot/cmdline.txt file on the MicroSD does not contain the parameter "init=/usr/lib/raspi-config/init_resize.sh". Delete it if present. +> Regardless of which way you use to access the Pi (Keyboard+HDMI or USB networking), **before you boot the Pi for for the first time with the MicroSD inserted**, verify that the /boot/cmdline.txt file on the MicroSD does not contain the parameter "init=/usr/lib/raspi-config/init_resize.sh". Delete that entire string if present. #### Use a monitor/keyboard/mouse If you have a monitor with an HDMI input, a Mini HDMI to HDMI cable, a usb keyboard and a micro usb power cable you can hook up the devices to the Pi and configure it directly. From 2d821a2d106c4ca6c08e703cc1757d00c567a166 Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Thu, 18 Oct 2018 07:39:12 -0500 Subject: [PATCH 6/7] Updated usb to USB. Capital letters. --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3bd517b..55b5b49 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# teslausb +# teslaUSB ## Meta -This repo contains steps and scripts originally from [this thread on Reddit]( https://www.reddit.com/r/teslamotors/comments/9m9gyk/build_a_smart_usb_drive_for_your_tesla_dash_cam/) +This repo contains steps and scripts originally from [this thread on Reddit]( https://www.reddit.com/r/teslamotors/comments/9m9gyk/build_a_smart_USB_drive_for_your_tesla_dash_cam/) Many people in that thread suggested that the scripts be hosted on Github but the author didn't seem interested in making that happen. I've hosted the scripts here with his/her permission. @@ -78,7 +78,7 @@ There are four phases to setting up the Pi: > Regardless of which way you use to access the Pi (Keyboard+HDMI or USB networking), **before you boot the Pi for for the first time with the MicroSD inserted**, verify that the /boot/cmdline.txt file on the MicroSD does not contain the parameter "init=/usr/lib/raspi-config/init_resize.sh". Delete that entire string if present. #### Use a monitor/keyboard/mouse -If you have a monitor with an HDMI input, a Mini HDMI to HDMI cable, a usb keyboard and a micro usb power cable you can hook up the devices to the Pi and configure it directly. +If you have a monitor with an HDMI input, a Mini HDMI to HDMI cable, a USB keyboard and a Micro USB power cable you can hook up the devices to the Pi and configure it directly. 1. Insert the MicroSD card into the Pi. 1. Connect the keyboard, and monitor to the Pi. 1. Connect the power supply to the Pi using the port labeld "PWR" on the circuitboard. @@ -160,19 +160,19 @@ Now that you have Wifi up and running, it's time to set up the USB Storage and s ``` 1. Run these commands: ``` - wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/setup-teslausb - chmod +x setup-teslausb - ./setup-teslausb + wget https://raw.githubusercontent.com/cimryan/teslaUSB/master/windows_archive/setup-teslaUSB + chmod +x setup-teslaUSB + ./setup-teslaUSB ``` 1. Run this command: ``` reboot ``` -After reboot, the Pi hostname will become `teslausb`, so future `ssh` sessions will be `ssh pi@teslausb.local`. +After reboot, the Pi hostname will become `teslaUSB`, so future `ssh` sessions will be `ssh pi@teslaUSB.local`. ### Get the Pi set up for your Tesla. -If you set up the Pi with a keyboard and a monitor disconnect it and connect it to a PC. If you're using a cable be sure to use the port labeled "usb" on the circuitboard. +If you set up the Pi with a keyboard and a monitor disconnect it and connect it to a PC. If you're using a cable be sure to use the port labeled "USB" on the circuitboard. 1. Wait for the Pi to show up on the PC as a USB drive. 1. Create a directory named TeslaCam at the root of the drive labeled CAM. 1. Copy any music you'd like to the drive labeled MUSIC. @@ -187,7 +187,7 @@ The setup process configures the Pi with read-only file systems for the operatin To make changes to the system partitions: ``` -ssh pi@teslausb. +ssh pi@teslaUSB. sudo -i mount / -o remount,rw mount /boot -o remount,rw From a6c0c17fd85c07d7ea3dd1b5840e3514f25343ba Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Thu, 18 Oct 2018 07:43:51 -0500 Subject: [PATCH 7/7] Added some echo commands to updater script for readability. --- mac_linux_archive/update-rpi-mac-linux.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mac_linux_archive/update-rpi-mac-linux.sh b/mac_linux_archive/update-rpi-mac-linux.sh index 5658def..570e48e 100755 --- a/mac_linux_archive/update-rpi-mac-linux.sh +++ b/mac_linux_archive/update-rpi-mac-linux.sh @@ -52,14 +52,14 @@ if [ ! -f ssh ]; then fi # Append the dwc2 module if not set (USB OTG) - +echo "Verifying dwc2 module is set in config.txt." dt=$(cat config.txt | grep "dtoverlay=dwc2") if [ "$dt" != "dtoverlay=dwc2" ]; then echo "dtoverlay=dwc2" >> config.txt fi # Append the g_ether module if not set (USB networking) - +echo "Verifying the g_ether module (USB networking) is set in cmdline.txt." mod=$(cat cmdline.txt | grep -o "modules-load=dwc2,g_ether") if [ "$mod" != "modules-load=dwc2,g_ether" ]; then sed -i '' '$ s/$/ modules-load=dwc2,g_ether/' cmdline.txt @@ -71,6 +71,7 @@ fi # Raspbian image will automatically expand the filesystem to include the # entire SD card. +echo "Removing the command to auto-expand the root filesystem." mod=$(cat cmdline.txt | grep -o "init=/usr/lib/raspi-config/init_resize.sh") if [ "$mod" = "init=/usr/lib/raspi-config/init_resize.sh" ]; then sed -i'.bak' -e 's/ init=\/usr\/lib\/raspi-config\/init_resize.sh//g' cmdline.txt @@ -79,6 +80,7 @@ fi # Sets up wifi credentials so wifi will be # auto configured on first boot +echo "Adding Wifi setup file (wpa_supplicant.conf)." if [ -r "wpa_supplicant.conf" ] then rm wpa_supplicant.conf @@ -95,8 +97,6 @@ network={ } EOF - -cd echo "" echo '-- Files updated and ready for Wifi and SSH over USB --' echo ""