From 80ef4acf48954cff98423408369604f44e5e52c0 Mon Sep 17 00:00:00 2001 From: cimryan Date: Mon, 5 Nov 2018 21:56:29 -0800 Subject: [PATCH 1/3] Skip configuring the archive if the user didn't pick an archive system. --- doc/SetupRClone.md | 6 +- doc/SetupRSync.md | 6 +- doc/SetupShare.md | 1 + doc/teslausb_setup_variables.conf.sample | 9 +- .../teslausb_setup_variables.conf.sample | 9 +- setup/pi/configure.sh | 101 ++++++++++-------- 6 files changed, 63 insertions(+), 69 deletions(-) diff --git a/doc/SetupRClone.md b/doc/SetupRClone.md index fad7189..fa81d35 100644 --- a/doc/SetupRClone.md +++ b/doc/SetupRClone.md @@ -19,7 +19,7 @@ These instructions will speed you through the process with good defaults. If you ``` 1. Run these commands: ``` - export RCLONE_ENABLE=true + export ARCHIVE_SYSTEM=rclone export RCLONE_DRIVE=gdrive export RCLONE_PATH=TeslaCam @@ -86,8 +86,6 @@ Confirm that the directory `TeslaCam` is present. If not, start over. # Step 4: Exports Run this command to cause the setup processes which you'll resume in the main instructions to use rclone4pi: ``` -export RCLONE_ENABLE=true +export ARCHIVE_SYSTEM=rclone ``` -**Note:** `RCLONE_ENABLE=true` is going to disable the default archive server. It also will **not** play nicely with `RSYNC_ENABLE=true` 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. - Now return to the section "Set up the USB storage functionality" in the [main instructions](../README.md). diff --git a/doc/SetupRSync.md b/doc/SetupRSync.md index 0d586ac..48e50f4 100644 --- a/doc/SetupRSync.md +++ b/doc/SetupRSync.md @@ -30,20 +30,20 @@ Similar to sftp, rsync by default uses ssh to connect to a remote server and tra Run this command to cause the setup processes which you'll resume in the main instructions to use rsync: ``` -export RSYNC_ENABLE=true +export ARCHIVE_SYSTEM=rsync export RSYNC_USER= export RSYNC_SERVER= export RSYNC_PATH= ``` Explanations for each: -* `RSYNC_ENABLE`: `true` for enabling rsync +* `ARCHIVE_SYSTEM`: `rsync` 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 config is below: ``` -export RSYNC_ENABLE=true +export ARCHIVE_SYSTEM=rsync export RSYNC_USER=pi export RSYNC_SERVER=192.168.1.254 export RSYNC_PATH=/mnt/PIHDD/TeslaCam/ diff --git a/doc/SetupShare.md b/doc/SetupShare.md index cee21aa..f09c9f2 100644 --- a/doc/SetupShare.md +++ b/doc/SetupShare.md @@ -23,6 +23,7 @@ Now, on the Pi: 1. Run these commands, subsituting your values: ``` sudo -i + export ARCHIVE_SYSTEM="cifs" export archiveserver="Nautilus" export sharename="SailfishCam" export shareuser="sailfish" diff --git a/doc/teslausb_setup_variables.conf.sample b/doc/teslausb_setup_variables.conf.sample index 140e355..bca3c68 100644 --- a/doc/teslausb_setup_variables.conf.sample +++ b/doc/teslausb_setup_variables.conf.sample @@ -9,6 +9,7 @@ ###################################################################### # Default variables for CIFS (Windows/Mac file sharing) setup +export ARCHIVE_SYSTEM=cifs export archiveserver=your_archive_name_or_ip export sharename=your_archive_share_name export shareuser=username @@ -33,11 +34,3 @@ export HEADLESS_SETUP=true # Uncomment and change if you want a different branch than master # export BRANCH=master - -# Uncomment if you're using rsync/ssh for the archive. -# Note: RSYNC is not usable for headless setup since it currently requires a manual step. -# Note: RSYNC_ENABLE=true is going to disable the default archive server. -# export RSYNC_ENABLE=true -# export RSYNC_USER= -# export RSYNC_SERVER= -# export RSYNC_PATH= \ No newline at end of file diff --git a/pi-gen-sources/files/teslausb_setup_variables.conf.sample b/pi-gen-sources/files/teslausb_setup_variables.conf.sample index 5c0b859..bca3c68 100644 --- a/pi-gen-sources/files/teslausb_setup_variables.conf.sample +++ b/pi-gen-sources/files/teslausb_setup_variables.conf.sample @@ -9,6 +9,7 @@ ###################################################################### # Default variables for CIFS (Windows/Mac file sharing) setup +export ARCHIVE_SYSTEM=cifs export archiveserver=your_archive_name_or_ip export sharename=your_archive_share_name export shareuser=username @@ -33,11 +34,3 @@ export HEADLESS_SETUP=true # Uncomment and change if you want a different branch than master # export BRANCH=master - -# Uncomment if you're using rsync/ssh for the archive. -# Note: RSYNC_ENABLE=true is going to disable the default archive server. -# -# export RSYNC_ENABLE=true -# export RSYNC_USER= -# export RSYNC_SERVER= -# export RSYNC_PATH= \ No newline at end of file diff --git a/setup/pi/configure.sh b/setup/pi/configure.sh index fc22fde..31fb225 100644 --- a/setup/pi/configure.sh +++ b/setup/pi/configure.sh @@ -3,6 +3,8 @@ REPO=${REPO:-cimryan} BRANCH=${BRANCH:-master} +ARCHIVE_SYSTEM=${ARCHIVE_SYSTEM:-none} + export INSTALL_DIR=${INSTALL_DIR:-/root/bin} function check_variable () { @@ -60,50 +62,52 @@ EOF function check_archive_configs () { echo -n "Checking archive configs: " - RSYNC_ENABLE="${RSYNC_ENABLE:-false}" - RCLONE_ENABLE="${RCLONE_ENABLE:-false}" - if [ "$RSYNC_ENABLE" = true ] && [ "$RCLONE_ENABLE" = true ] - then - echo "STOP: Can't enable rsync and rclone at the same time" - exit 1 - fi - - if [ "$RSYNC_ENABLE" = true ] - then - check_variable "RSYNC_USER" - check_variable "RSYNC_SERVER" - check_variable "RSYNC_PATH" - export archiveserver="$RSYNC_SERVER" - - elif [ "$RCLONE_ENABLE" = true ] - then - check_variable "RCLONE_DRIVE" - check_variable "RCLONE_PATH" - export archiveserver="8.8.8.8" # since it's a cloud hosted drive we'll just set this to google dns - else - # default to cifs - check_variable "sharename" - check_variable "shareuser" - check_variable "sharepassword" - check_variable "archiveserver" - fi - + case "$ARCHIVE_SYSTEM" in + rsync) + check_variable "RSYNC_USER" + check_variable "RSYNC_SERVER" + check_variable "RSYNC_PATH" + export archiveserver="$RSYNC_SERVER" + ;; + rclone) + check_variable "RCLONE_DRIVE" + check_variable "RCLONE_PATH" + export archiveserver="8.8.8.8" # since it's a cloud hosted drive we'll just set this to google dns + ;; + cifs) + check_variable "sharename" + check_variable "shareuser" + check_variable "sharepassword" + check_variable "archiveserver" + ;; + none) + ;; + *) + echo "STOP: Unrecognized archive system: $ARCHIVE_SYSTEM" + exit 1 + ;; + esac + echo "done" } function get_archive_module () { - if [ "$RSYNC_ENABLE" = true ] - then - archive_module="run/rsync_archive" - elif [ "$RCLONE_ENABLE" = true ] - then - archive_module="run/rclone_archive" - else - archive_module="run/cifs_archive" - fi - - echo $archive_module + case "$ARCHIVE_SYSTEM" in + rsync) + echo "run/rsync_archive" + ;; + rclone) + echo "run/rclone_archive" + ;; + cifs) + echo "run/cifs_archive" + ;; + *) + echo "Internal error: Attempting to configure unrecognized archive system: $ARCHIVE_SYSTEM" + exit 1 + ;; + esac } function install_archive_scripts () { @@ -125,7 +129,6 @@ function install_archive_scripts () { get_script $install_path archive-is-reachable.sh $archive_module } - function check_pushover_configuration () { if [ ! -z "${pushover_enabled+x}" ] then @@ -147,10 +150,10 @@ function check_pushover_configuration () { function configure_pushover () { if [ ! -z "${pushover_enabled+x}" ] then - echo "Enabling pushover" - echo "export pushover_enabled=true" > /root/.teslaCamPushoverCredentials - echo "export pushover_user_key=$pushover_user_key" >> /root/.teslaCamPushoverCredentials - echo "export pushover_app_key=$pushover_app_key" >> /root/.teslaCamPushoverCredentials + echo "Enabling pushover" + echo "export pushover_enabled=true" > /root/.teslaCamPushoverCredentials + echo "export pushover_user_key=$pushover_user_key" >> /root/.teslaCamPushoverCredentials + echo "export pushover_app_key=$pushover_app_key" >> /root/.teslaCamPushoverCredentials else echo "Pushover not configured." fi @@ -158,8 +161,8 @@ function configure_pushover () { function check_and_configure_pushover () { check_pushover_configuration - - configure_pushover + + configure_pushover } function install_pushover_scripts() { @@ -167,6 +170,12 @@ function install_pushover_scripts() { get_script $install_path send-pushover run } +if [ "$ARCHIVE_SYSTEM" = "none" ] +then + echo "Skipping archive configuration." + exit 1 +fi + if ! [ $(id -u) = 0 ] then echo "STOP: Run sudo -i." From b576256dd247b0576f30eaf41b6dbf47de9cc080 Mon Sep 17 00:00:00 2001 From: cimryan Date: Mon, 5 Nov 2018 22:48:36 -0800 Subject: [PATCH 2/3] Skipping the configuration of the archive is not an error condition. --- setup/pi/configure.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/pi/configure.sh b/setup/pi/configure.sh index 31fb225..174fbee 100644 --- a/setup/pi/configure.sh +++ b/setup/pi/configure.sh @@ -173,7 +173,7 @@ function install_pushover_scripts() { if [ "$ARCHIVE_SYSTEM" = "none" ] then echo "Skipping archive configuration." - exit 1 + exit 0 fi if ! [ $(id -u) = 0 ] From 267ee46ff1f4dc5572f887c7d2ea0685ef0af685 Mon Sep 17 00:00:00 2001 From: cimryan Date: Mon, 5 Nov 2018 23:06:49 -0800 Subject: [PATCH 3/3] Export the updated value of campercent --- 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 28ad24c..e201913 100644 --- a/setup/pi/setup-teslausb +++ b/setup/pi/setup-teslausb @@ -6,7 +6,7 @@ HEADLESS_SETUP=${HEADLESS_SETUP:-false} USE_LED_FOR_SETUP_PROGRESS=true CONFIGURE_ARCHIVING=${CONFIGURE_ARCHIVING:-true} UPGRADE_PACKAGES=${UPGRADE_PACKAGES:-true} -campercent=${campercent:-90} +export campercent=${campercent:-90} function setup_progress () { local setup_logfile=/boot/teslausb-headless-setup.log