Pause resume folder using CLI

Got it; turns out that reusing the temp file “f” doesn’t work; having a second temp file “o” works.

#!/bin/bash
set -euo pipefail

folder=$1
echo "resuming "$folder

st='http://localhost:8384/rest/system/config' 
key='myKey'

f=$(mktemp)
o=$(mktemp)
function clean {
  rm -f "$f"
  rm -f "$o"
}
trap clean EXIT

curl -s -H X-API-Key:$key $st > "$f" 
#cat $f > orig.txt

jq --arg fldr "$folder" -r '(.folders[] | select(.label==$fldr)) .paused = false' "$f" > $o
#jq --arg fldr "$folder" -r '(.folders[] | select(.label==$fldr)) .paused = false' "$f" > output.txt

curl -s -H X-API-Key:$key --data-binary @$o $st

Now I have a nice little function that I can call with a folder name and it will resume; I will make a copy of this called pause and change the false to true. i.e.

~/myScripts/Resume.sh aFolder
~/myScripts/Pause.sh aFolder
1 Like