Merge pull request #66 from cimryan/u/cimryan/cifs_graceful_failure

U/cimryan/cifs graceful failure
This commit is contained in:
cimryan
2018-10-25 20:55:24 -07:00
committed by GitHub
4 changed files with 49 additions and 54 deletions

View File

@@ -1,35 +0,0 @@
#!/bin/bash -eu
export LOG_FILE=/tmp/archive-teslacam-clips.log
export ARCHIVE_MOUNT=/mnt/archive
function log () {
echo "$( date )" >> "$LOG_FILE"
echo "$1" >> "$LOG_FILE"
}
function disconnect_usb_drives_from_host () {
log "Disconnecting usb from host..."
modprobe -r g_mass_storage
log "Disconnected usb from host."
}
export -f log
log "Starting..."
/root/bin/connect-archive.sh
disconnect_usb_drives_from_host
ensure_cam_file_is_mounted
fix_errors_in_cam_file
/root/bin/archive-clips.sh
/root/bin/disconnect-archive.sh
unmount_cam_file
connect_usb_drives_to_host

View File

@@ -1,10 +1,11 @@
#!/bin/bash -eu
ARCHIVE_HOST_NAME="$1"
LOG_FILE=/tmp/archiveloop.log
export LOG_FILE=/tmp/archiveloop.log
export CAM_MOUNT=/mnt/cam
export MUSIC_MOUNT=/mnt/music
export ARCHIVE_MOUNT=/mnt/archive
function log () {
echo "$( date )" >> "$LOG_FILE"
@@ -154,12 +155,6 @@ function fix_errors_in_music_file () {
fix_errors_in_mount_point "$MUSIC_MOUNT"
}
function archive_clips () {
log "Archiving..."
/root/bin/archive-teslacam-clips
log "Finished archiving."
}
function wait_for_archive_to_be_unreachable () {
log "Waiting for archive to be unreachable..."
while [ true ]
@@ -199,17 +194,47 @@ function mount_and_fix_errors_in_files () {
mount_and_fix_errors_in_music_file
}
export -f fix_errors_in_mount_point
export -f fix_errors_in_cam_file
export -f retry
function disconnect_usb_drives_from_host () {
log "Disconnecting usb from host..."
modprobe -r g_mass_storage
log "Disconnected usb from host."
}
function archive_teslacam_clips () {
log "Starting..."
/root/bin/connect-archive.sh
disconnect_usb_drives_from_host
ensure_cam_file_is_mounted
fix_errors_in_cam_file
/root/bin/archive-clips.sh
/root/bin/disconnect-archive.sh
unmount_cam_file
connect_usb_drives_to_host
}
function archive_clips () {
log "Archiving..."
if archive_teslacam_clips
then
log "Finished archiving."
else
log "Archiving failed."
fi
}
export -f mount_mountpoint
export -f ensure_mountpoint_is_mounted
export -f retry
export -f ensure_mountpoint_is_mounted_with_retry
export -f ensure_cam_file_is_mounted
export -f fix_errors_in_cam_file
export -f unmount_mount_point
export -f unmount_cam_file
export -f connect_usb_drives_to_host
export -f log
log "Starting..."

View File

@@ -7,9 +7,15 @@ NUM_FILES_MOVED=0
for file_name in "$CAM_MOUNT"/TeslaCam/saved*; do
[ -e "$file_name" ] || continue
log "Moving $file_name ..."
mv -- "$file_name" "$ARCHIVE_MOUNT" >> "$LOG_FILE" 2>&1 || echo ""
if mv -f -t "$ARCHIVE_MOUNT" -- "$file_name" >> "$LOG_FILE" 2>&1
then
log "Moved $file_name."
NUM_FILES_MOVED=$((NUM_FILES_MOVED + 1))
else
log "Failed to move $file_name."
fi
done
log "Moved $NUM_FILES_MOVED file(s)."

View File

@@ -112,7 +112,6 @@ function configure_archive_scripts () {
echo "Configuring the archive scripts..."
get_script /root/bin archiveloop run
get_script /root/bin archive-teslacam-clips run
if [ $RSYNC_ENABLE = true ]
then