Browse Source

Added debugging and error handling

expose_links
Drew Short 5 years ago
parent
commit
f9f48ef2b6
  1. 10
      assets/common.sh
  2. 8
      assets/out

10
assets/common.sh

@ -21,10 +21,18 @@ load_config() {
} }
load_files() { load_files() {
local files=$(jq -r '.source.files | keys | join(" ")' < $1)
set +e
local files=$(jq -r '.source.files | keys | join(" ") // ""' < $1) 2> /dev/null
set -e
# TODO: Remove Me - DEBUGGING
echo "Files:"
echo $files
for fileName in files; do for fileName in files; do
local jq_path=".source.files.${fileName}" local jq_path=".source.files.${fileName}"
local content=$(jq -r "${jq_path}" < $1) local content=$(jq -r "${jq_path}" < $1)
echo "$content" > "/tmp/${fileName}" echo "$content" > "/tmp/${fileName}"
# TODO: Remove Me - DEBUGGING
echo "File /tmp/${fileName}"
cat /tmp/${fileName}
done done
} }

8
assets/out

@ -25,6 +25,10 @@ PATH=/usr/local/bin:$PATH
payload=$(mktemp $TMPDIR/rclone-resource-request.XXXXXX) payload=$(mktemp $TMPDIR/rclone-resource-request.XXXXXX)
cat > $payload <&0 cat > $payload <&0
# TODO: Remove Me - DEBUGGING
echo "Payload:"
cat $payload
load_config $payload load_config $payload
load_files $payload load_files $payload
@ -32,6 +36,10 @@ rclone_source_directory=$(jq -r '.params.source // ""' < $payload)
rclone_destination=$(jq -r '.params.destination // ""' < $payload) rclone_destination=$(jq -r '.params.destination // ""' < $payload)
rclone_destination_subdir_file=$(jq -r '.params.subdir // ""' < $payload) rclone_destination_subdir_file=$(jq -r '.params.subdir // ""' < $payload)
echo "Source directory: $rclone_source_directory"
echo "Destination: $rclone_destination"
echo "Destination subdir file: $rclone_destination_subdir_file"
if [ -z "$rclone_source_directory" ]; then if [ -z "$rclone_source_directory" ]; then
echo "invalid source directory (missing source)" echo "invalid source directory (missing source)"
exit 1 exit 1

Loading…
Cancel
Save