Merge pull request #79 from rtanaka/master

Organizing some files around
This commit is contained in:
cimryan
2018-10-30 07:29:45 -07:00
committed by GitHub
6 changed files with 62 additions and 74 deletions

View File

@@ -29,10 +29,11 @@ Required:
* A Micro SD card, at least 8 GB in size, and an adapter (if necessary) to connect the card to your computer. * 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 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/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: 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. * 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 ### 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. 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 ## (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. 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. 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. 1. Copy any music you'd like to the drive labeled MUSIC.

View File

@@ -13,8 +13,8 @@ function configure_archive () {
fi fi
local credentials_file_path="/root/.teslaCamArchiveCredentials" local credentials_file_path="/root/.teslaCamArchiveCredentials"
echo "username=$shareuser" > "$credentials_file_path"
/root/bin/write-archive-credentials-to.sh "$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 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

View File

@@ -24,10 +24,8 @@ function check_archive_mountable () {
mkdir "$test_mount_location" mkdir "$test_mount_location"
fi fi
local tmp_credentials_file_path="/tmp/teslaCamArchiveCredentials" local tmp_credentials_file_path="/root/.teslaCamArchiveCredentials"
/root/bin/write-archive-credentials-to.sh "$tmp_credentials_file_path"
local mount_failed=false 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 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

View File

@@ -1,6 +0,0 @@
#!/bin/bash -eu
FILE_PATH="$1"
echo "username=$shareuser" > "$FILE_PATH"
echo "password=$sharepassword" >> "$FILE_PATH"

View File

@@ -25,7 +25,7 @@ append_cmdline_txt_param ro
# Move fake-hwclock.data to /mutable directory so it can be updated # Move fake-hwclock.data to /mutable directory so it can be updated
if ! findmnt --mountpoint /mutable if ! findmnt --mountpoint /mutable
then then
echo "Mounting the multable partition..." echo "Mounting the mutable partition..."
mount /mutable mount /mutable
echo "Mounted." echo "Mounted."
fi fi

View File

@@ -113,6 +113,43 @@ function check_pushover_enabled () {
fi fi
} }
function check_archive_configs () {
RSYNC_ENABLE="${RSYNC_ENABLE:-false}"
RCLONE_ENABLE="${RCLONE_ENABLE:-false}"
if [ "$RSYNC_ENABLE" = true ] && [ "$RCLONE_ENABLE" = true ]
then
setup_progress "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 () { function check_available_space () {
setup_progress "Verifying that there is sufficient space available on the MicroSD card..." 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..." setup_progress "Configuring the archive scripts..."
get_script /root/bin archiveloop run 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 get_script /root/bin remountfs_rw run
setup_progress "Configured the archive scripts." setup_progress "Configured the archive scripts."
} }
function install_archive_scripts () {
check_variable "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
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() { function configure_pushover_scripts() {
get_script /root/bin send-pushover run get_script /root/bin send-pushover run
} }
@@ -274,32 +306,8 @@ headless_setup_progress_flash 1
setup_progress "Verifying environment variables..." 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_variable "campercent"
check_archive_configs
check_pushover_enabled check_pushover_enabled
# Flash for Stage 3 headless (grab scripts) # Flash for Stage 3 headless (grab scripts)
@@ -312,22 +320,10 @@ then
mkdir /root/bin mkdir /root/bin
fi 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
get_script /root/bin get-archiveserver-ip-address.sh run get_script /root/bin get-archiveserver-ip-address.sh run
install_archive_scripts
/root/bin/configure-archive.sh
/root/bin/verify-archive-configuration.sh /root/bin/verify-archive-configuration.sh
check_available_space check_available_space
@@ -336,7 +332,6 @@ get_ancillary_setup_scripts
pushd ~ pushd ~
configure_archive_scripts configure_archive_scripts
configure_pushover_scripts configure_pushover_scripts
@@ -350,8 +345,6 @@ headless_setup_progress_flash 3
create_usb_drive_backing_files create_usb_drive_backing_files
/root/bin/configure-archive.sh
configure_rc_local configure_rc_local
configure_hostname configure_hostname