hpr-tools/Show_Submission/sync_hpr

76 lines
1.8 KiB
Bash
Executable File

#!/bin/bash -
#===============================================================================
#
# FILE: sync_hpr
#
# USAGE: ./sync_hpr
#
# DESCRIPTION: Runs rsync to pull the contents of the 'upload' directory from
# the HPR server. Uses a filter in the file '.rsync_hpr_upload'
# so that it only copies the files relevant to managing
# submitted shows. Files and directories deleted on the HPR
# server are also deleted here.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
# VERSION: 0.0.7
# CREATED: 2020-01-03 23:18:58
# REVISION: 2023-06-14 18:06:06
#
#===============================================================================
set -o nounset # Treat unset variables as an error
SCRIPT=${0##*/}
# DIR=${0%/*}
#
# Load library functions
#
LIB="$HOME/bin/function_lib.sh"
[ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; }
# shellcheck source=/home/cendjm/bin/function_lib.sh
source "$LIB"
#
# Colour codes
#
define_colours
#
# Directories
#
BASEDIR="$HOME/HPR/Show_Submission"
HPRUPLOAD='hpr@hackerpublicradio.org:upload/'
UPLOAD="$BASEDIR/upload"
#
# Settings
#
# PORT=22074
PORT=22
#
# Change directory
#
cd "$BASEDIR" || { echo "$SCRIPT: Failed to change directory to $BASENAME"; exit 1; }
#
# Check the tunnel is open
#
if ! tunnel_is_open; then
echo "$SCRIPT: Open the tunnel before running"
exit 1
fi
#
# Use 'rsync' to collect relevant data from the HPR server's 'upload'
# directory.
#
rsync -vaP -e "ssh -p $PORT" --delete --filter=". .rsync_hpr_upload" "$HPRUPLOAD" "$UPLOAD"
# vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21