From 4d0b010e8df7347fa14043c320240c0f6daf9411 Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Mon, 29 Oct 2018 15:06:46 -0700 Subject: [PATCH 1/9] removing since this is done in configure-archive and to make it more consistent with the others --- run/cifs_archive/verify-archive-configuration.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/run/cifs_archive/verify-archive-configuration.sh b/run/cifs_archive/verify-archive-configuration.sh index 5bbc131..b7d47e1 100644 --- a/run/cifs_archive/verify-archive-configuration.sh +++ b/run/cifs_archive/verify-archive-configuration.sh @@ -24,10 +24,6 @@ function check_archive_mountable () { mkdir "$test_mount_location" fi - local tmp_credentials_file_path="/tmp/teslaCamArchiveCredentials" - - /root/bin/write-archive-credentials-to.sh "$tmp_credentials_file_path" - local mount_failed=false mount -t cifs "//$archive_server_ip_address/$sharename" "$test_mount_location" -o "vers=${cifs_version},credentials=${tmp_credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777" || mount_failed=true From d91aff3ced40f191b9684e937b162f3153c94cb7 Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Mon, 29 Oct 2018 16:56:30 -0700 Subject: [PATCH 2/9] remove write archive dependency --- run/cifs_archive/configure-archive.sh | 4 ++-- run/cifs_archive/write-archive-credentials-to.sh | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 run/cifs_archive/write-archive-credentials-to.sh diff --git a/run/cifs_archive/configure-archive.sh b/run/cifs_archive/configure-archive.sh index eff994f..f6c4fe4 100644 --- a/run/cifs_archive/configure-archive.sh +++ b/run/cifs_archive/configure-archive.sh @@ -13,8 +13,8 @@ function configure_archive () { fi local credentials_file_path="/root/.teslaCamArchiveCredentials" - - /root/bin/write-archive-credentials-to.sh "$credentials_file_path" + echo "username=$shareuser" > "$credentials_file_path" + echo "password=$sharepassword" >> "$credentials_file_path" echo "//$archive_server_ip_address/$sharename $archive_path cifs vers=${cifs_version},credentials=${credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab diff --git a/run/cifs_archive/write-archive-credentials-to.sh b/run/cifs_archive/write-archive-credentials-to.sh deleted file mode 100644 index edce256..0000000 --- a/run/cifs_archive/write-archive-credentials-to.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -eu - -FILE_PATH="$1" - -echo "username=$shareuser" > "$FILE_PATH" -echo "password=$sharepassword" >> "$FILE_PATH" From e543363009b83931937eea45c799c7d85170eaa5 Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Mon, 29 Oct 2018 16:57:40 -0700 Subject: [PATCH 3/9] clean up the archive server set up routine --- setup/pi/setup-teslausb | 106 +++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/setup/pi/setup-teslausb b/setup/pi/setup-teslausb index d92ad4b..ee8a9dd 100644 --- a/setup/pi/setup-teslausb +++ b/setup/pi/setup-teslausb @@ -113,6 +113,43 @@ function check_pushover_enabled () { fi } +function check_archive_configs () { + + RSYNC_ENABLE="${RSYNC_ENABLE:-false}" + RCLONE_ENABLE="${RCLONE_ENABLE:-false}" + + if [ "$RSYNC_ENABLE" = true ] && [ "$RCLONE_ENABLE" = true ] + then + echo "STOP: Cannot enable rsync and rclone at the same time" + exit 1 + fi + + if [ "$RSYNC_ENABLE" = true ] + then + check_variable "RSYNC_USER" + check_variable "RSYNC_SERVER" + export archiveserver="$RSYNC_SERVER" + check_variable "RSYNC_PATH" + export archive_module="run/rsync_archive" + elif [ "$RCLONE_ENABLE" = true ] + then + check_variable "RCLONE_DRIVE" + check_variable "RCLONE_PATH" + # since it's a cloud hosted drive we'll just set this to google dns + export archiveserver="8.8.8.8" + export archive_module="run/rclone_archive" + else # Else for now, TODO allow both for more redundancy? + check_variable "sharename" + check_variable "shareuser" + check_variable "sharepassword" + + export cifs_version="${cifs_version:-3.0}" + export archive_module="run/cifs_archive" + fi + + check_variable "archiveserver" +} + function check_available_space () { setup_progress "Verifying that there is sufficient space available on the MicroSD card..." @@ -190,28 +227,23 @@ function configure_archive_scripts () { setup_progress "Configuring the archive scripts..." get_script /root/bin archiveloop run - - if [ $RSYNC_ENABLE = true ] - then - get_script /root/bin archive-clips.sh run/rsync_archive - get_script /root/bin connect-archive.sh run/rsync_archive - get_script /root/bin disconnect-archive.sh run/rsync_archive - elif [ $RCLONE_ENABLE = true ] - then - get_script /root/bin archive-clips.sh run/rclone_archive - get_script /root/bin connect-archive.sh run/rclone_archive - get_script /root/bin disconnect-archive.sh run/rclone_archive - else - get_script /root/bin archive-clips.sh run/cifs_archive - get_script /root/bin connect-archive.sh run/cifs_archive - get_script /root/bin disconnect-archive.sh run/cifs_archive - fi - get_script /root/bin remountfs_rw run setup_progress "Configured the archive scripts." } +function install_archive_scripts () { + check_variable "archive_module" + echo $archive_module + + local install_path="/root/bin" + get_script $install_path verify-archive-configuration.sh $archive_module + get_script $install_path configure-archive.sh $archive_module + get_script $install_path archive-clips.sh $archive_module + get_script $install_path connect-archive.sh $archive_module + get_script $install_path disconnect-archive.sh $archive_module +} + function configure_pushover_scripts() { get_script /root/bin send-pushover run } @@ -274,32 +306,8 @@ headless_setup_progress_flash 1 setup_progress "Verifying environment variables..." -RSYNC_ENABLE="${RSYNC_ENABLE:-false}" -RCLONE_ENABLE="${RCLONE_ENABLE:-false}" - -if [ "$RSYNC_ENABLE" = true ] -then - check_variable "RSYNC_USER" - check_variable "RSYNC_SERVER" - export archiveserver="$RSYNC_SERVER" - check_variable "RSYNC_PATH" -elif [ "$RCLONE_ENABLE" = true ] -then - check_variable "RCLONE_DRIVE" - check_variable "RCLONE_PATH" - # since it's a cloud hosted drive we'll just set this to google dns - export archiveserver="8.8.8.8" -else # Else for now, TODO allow both for more redundancy? - check_variable "sharename" - check_variable "shareuser" - check_variable "sharepassword" - - export cifs_version="${cifs_version:-3.0}" -fi - -check_variable "archiveserver" check_variable "campercent" - +check_archive_configs check_pushover_enabled # Flash for Stage 3 headless (grab scripts) @@ -312,19 +320,7 @@ then mkdir /root/bin fi -if [ "$RSYNC_ENABLE" = true ] -then - get_script /root/bin verify-archive-configuration.sh run/rsync_archive - get_script /root/bin configure-archive.sh run/rsync_archive -elif [ "$RCLONE_ENABLE" = true ] -then - get_script /root/bin verify-archive-configuration.sh run/rclone_archive - get_script /root/bin configure-archive.sh run/rclone_archive -else - get_script /root/bin verify-archive-configuration.sh run/cifs_archive - get_script /root/bin configure-archive.sh run/cifs_archive - get_script /root/bin write-archive-credentials-to.sh run/cifs_archive -fi +install_archive_scripts get_script /root/bin get-archiveserver-ip-address.sh run From c54c5c26c3a3a78d016c5a98a61379fe553a8113 Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Mon, 29 Oct 2018 18:52:53 -0700 Subject: [PATCH 4/9] fixing typo --- setup/pi/make-root-fs-readonly.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/pi/make-root-fs-readonly.sh b/setup/pi/make-root-fs-readonly.sh index fdf2ba6..aeafeb0 100644 --- a/setup/pi/make-root-fs-readonly.sh +++ b/setup/pi/make-root-fs-readonly.sh @@ -25,7 +25,7 @@ append_cmdline_txt_param ro # Move fake-hwclock.data to /mutable directory so it can be updated if ! findmnt --mountpoint /mutable then - echo "Mounting the multable partition..." + echo "Mounting the mutable partition..." mount /mutable echo "Mounted." fi From 0e016fb17621f370e76f861997a3622579225840 Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Mon, 29 Oct 2018 19:03:29 -0700 Subject: [PATCH 5/9] had a debug echo in there -- making it a log message instead --- setup/pi/setup-teslausb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/pi/setup-teslausb b/setup/pi/setup-teslausb index ee8a9dd..d8e889a 100644 --- a/setup/pi/setup-teslausb +++ b/setup/pi/setup-teslausb @@ -234,7 +234,7 @@ function configure_archive_scripts () { function install_archive_scripts () { check_variable "archive_module" - echo $archive_module + echo "Installing scripts for archive module: $archive_module" local install_path="/root/bin" get_script $install_path verify-archive-configuration.sh $archive_module From ef523f542d20f4565bf9a6fb4827d092565fa1e3 Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Mon, 29 Oct 2018 22:56:11 -0700 Subject: [PATCH 6/9] making changes to reflect upstream changes --- setup/pi/setup-teslausb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/pi/setup-teslausb b/setup/pi/setup-teslausb index d8e889a..b80034e 100644 --- a/setup/pi/setup-teslausb +++ b/setup/pi/setup-teslausb @@ -120,7 +120,7 @@ function check_archive_configs () { if [ "$RSYNC_ENABLE" = true ] && [ "$RCLONE_ENABLE" = true ] then - echo "STOP: Cannot enable rsync and rclone at the same time" + setup_progress "STOP: Cannot enable rsync and rclone at the same time" exit 1 fi @@ -234,7 +234,7 @@ function configure_archive_scripts () { function install_archive_scripts () { check_variable "archive_module" - echo "Installing scripts for archive module: $archive_module" + setup_progress "Installing scripts for archive module: $archive_module" local install_path="/root/bin" get_script $install_path verify-archive-configuration.sh $archive_module From fc1568db6142cf49007809bd73edcf7b3f4bf5c1 Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Mon, 29 Oct 2018 23:59:04 -0700 Subject: [PATCH 7/9] fixing cifs issue with my last change and reordering so we don't need a separate credential file --- run/cifs_archive/verify-archive-configuration.sh | 2 ++ setup/pi/setup-teslausb | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/run/cifs_archive/verify-archive-configuration.sh b/run/cifs_archive/verify-archive-configuration.sh index b7d47e1..684a42b 100644 --- a/run/cifs_archive/verify-archive-configuration.sh +++ b/run/cifs_archive/verify-archive-configuration.sh @@ -24,6 +24,8 @@ function check_archive_mountable () { mkdir "$test_mount_location" fi + local tmp_credentials_file_path="/root/.teslaCamArchiveCredentials" + local mount_failed=false mount -t cifs "//$archive_server_ip_address/$sharename" "$test_mount_location" -o "vers=${cifs_version},credentials=${tmp_credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777" || mount_failed=true diff --git a/setup/pi/setup-teslausb b/setup/pi/setup-teslausb index b80034e..0b52fe1 100644 --- a/setup/pi/setup-teslausb +++ b/setup/pi/setup-teslausb @@ -320,10 +320,10 @@ then mkdir /root/bin fi -install_archive_scripts - get_script /root/bin get-archiveserver-ip-address.sh run +install_archive_scripts +/root/bin/configure-archive.sh /root/bin/verify-archive-configuration.sh check_available_space @@ -332,7 +332,6 @@ get_ancillary_setup_scripts pushd ~ - configure_archive_scripts configure_pushover_scripts @@ -346,8 +345,6 @@ headless_setup_progress_flash 3 create_usb_drive_backing_files -/root/bin/configure-archive.sh - configure_rc_local configure_hostname From 9254d857be49e573916553ecd10a344394e7df7a Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Tue, 30 Oct 2018 00:32:01 -0700 Subject: [PATCH 8/9] - fixed adafruit link to the correct official case - added zero stem option because it's cool - added hint about setting campercent for the music option --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e95413c..89a6ffc 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,10 @@ Required: * A mechanism to connect the Pi to the Tesla. Either: * A USB A/Micro B cable: [Adafruit](https://www.adafruit.com/product/898) or [Amazon](https://www.amazon.com/gp/product/B013G4EAEI/), or * A USB A Add-on Board if you want to plug your Pi into your Tesla like a USB drive instead of using a cable. [Amazon](https://www.amazon.com/gp/product/B07BK2BR6C/) + * A PCB kit if you want the lowest profile possible and you're able to solder. [Sparkfun](https://www.sparkfun.com/products/14526) Optional: -* A case. The "Official" case: [Adafruit](https://www.adafruit.com/product/2885) or [Amazon](https://www.amazon.com/gp/product/B06Y593MHV). There are many others to choose from. Note that the official case won't work with the USB A Add on board. +* A case. The "Official" case: [Adafruit](https://www.adafruit.com/product/3446) or [Amazon](https://www.amazon.com/gp/product/B06Y593MHV). There are many others to choose from. Note that the official case won't work with the USB A Add-on board or the PCB kit. * USB Splitter if you don't want to lose a front USB port. [The Onvian Splitter](https://www.amazon.com/gp/product/B01KX4TKH6) has been reported working by multiple people on reddit. ### Software @@ -94,6 +95,8 @@ On the next boot, the Pi hostname will become `teslausb`, so future `ssh` sessio Your Pi is now ready to be plugged into your Tesla. If you want to add music to the Pi, follow the instructions in the next section. ## (Optional) Add music to the Pi +> Note: If you set `campercent` to 100% this drive will not show up + Connect the Pi to a computer. 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 computer as a USB drive. 1. Copy any music you'd like to the drive labeled MUSIC. From 7bc57b102597bcb76433dc46a464976aad0cc1ce Mon Sep 17 00:00:00 2001 From: Ray Tanaka Date: Tue, 30 Oct 2018 00:35:47 -0700 Subject: [PATCH 9/9] grammar police --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89a6ffc..eabba21 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Required: * A Micro SD card, at least 8 GB in size, and an adapter (if necessary) to connect the card to your computer. * A mechanism to connect the Pi to the Tesla. Either: * A USB A/Micro B cable: [Adafruit](https://www.adafruit.com/product/898) or [Amazon](https://www.amazon.com/gp/product/B013G4EAEI/), or - * A USB A Add-on Board if you want to plug your Pi into your Tesla like a USB drive instead of using a cable. [Amazon](https://www.amazon.com/gp/product/B07BK2BR6C/) + * A USB A Add-on Board if you want to plug your Pi into your Tesla like a USB drive instead of using a cable. [Amazon](https://www.amazon.com/gp/product/B07BK2BR6C/), or * A PCB kit if you want the lowest profile possible and you're able to solder. [Sparkfun](https://www.sparkfun.com/products/14526) Optional: