Initial rsync support (untested)

Currently untested, but the main idea is there
Currently it's either the normal archive server or rsync; not both, which is something to consider when adding things like gdrive and s3 (make it more modular?)
This commit is contained in:
Gocnak
2018-10-20 03:26:08 -04:00
parent 29a79bf45e
commit 002d1e6f6c
5 changed files with 103 additions and 13 deletions

View File

@@ -109,11 +109,20 @@ function create_usb_drive_backing_files () {
function configure_archive () {
echo "Configuring the archive..."
mkdir /mnt/archive
local archive_server_ip_address="$(ping -c 1 -w 1 $archiveserver 2>/dev/null | head -n 1 | grep -o -e "(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\})" | tr -d '()')"
echo "//$archive_server_ip_address/$sharename /mnt/archive cifs vers=3,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab
if [ $RSYNC_ENABLE = true ]
then
echo "Configuring for Rsync..."
echo "user=$RSYNC_USER" > /root/.teslaCamRsyncConfig
echo "server=$RSYNC_SERVER" > /root/.teslaCamRsyncConfig
echo "path=$RSYNC_PATH" > /root/.teslaCamRsyncConfig
else
echo "Configuring for a shared drive..."
local archive_server_ip_address="$(ping -c 1 -w 1 $archiveserver 2>/dev/null | head -n 1 | grep -o -e "(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\})" | tr -d '()')"
echo "//$archive_server_ip_address/$sharename /mnt/archive cifs vers=3,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab
echo "username=$shareuser" > /root/.teslaCamArchiveCredentials
echo "password=$sharepassword" >> /root/.teslaCamArchiveCredentials
echo "username=$shareuser" > /root/.teslaCamArchiveCredentials
echo "password=$sharepassword" >> /root/.teslaCamArchiveCredentials
fi
echo "Configured the archive."
}
@@ -131,6 +140,12 @@ function configure_archive_scripts () {
pushd /root/bin
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/archive-teslacam-clips
chmod +x archive-teslacam-clips
if [ $RSYNC_ENABLE = true ]
then
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/archive-rsync
chmod +x archive-rsync
fi
popd
echo "Configured the archive scripts."
@@ -193,10 +208,18 @@ function make_root_fs_readonly () {
echo "Verifying environment variables..."
if [ $RSYNC_ENABLE = true ]
then
check_variable "RSYNC_USER"
check_variable "RSYNC_SERVER"
archiveserver = $RSYNC_SERVER
check_variable "RSYNC_PATH"
else # Else for now, TODO allow both for more redundancy?
check_variable "sharename"
check_variable "shareuser"
check_variable "sharepassword"
fi
check_variable "archiveserver"
check_variable "sharename"
check_variable "shareuser"
check_variable "sharepassword"
check_variable "campercent"
check_pushover_enabled