From 414188d9e22e7be9af6dd39daedff312712d689b Mon Sep 17 00:00:00 2001 From: "user@node5.net" Date: Sun, 5 Jul 2026 18:50:24 +0200 Subject: fetch program - fix symblink broken on new fetch --- fetch_program.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'fetch_program.sh') diff --git a/fetch_program.sh b/fetch_program.sh index 526e194..4a93b0a 100755 --- a/fetch_program.sh +++ b/fetch_program.sh @@ -14,25 +14,31 @@ last_json="${last_xml%.*}.json" curl "https://bornhack.dk/bornhack-$year/program/frab.xml" > "$xml_path" +symlink() { + ln -sfr "$json_path" "programs/next.json" + mv --no-copy "programs/next.json" "programs/current.json" + stat -c %N programs/current.json +} + + if [ -f "$last_xml" ]; then - if diff -q -- "$xml_path" "$last_xml" >/dev/null; then + if diff -q "$xml_path" "$last_xml" >/dev/null; then echo "No change in program" # echo "Newly fetched program: $xml_path is the same as last program: $last_program, cleaning up last_program" rm -f -- "$last_xml" mv "$last_json" "$json_path" + symlink exit 0 fi fi -cat "$xml_path" | xq '.schedule.day | map(.room) | flatten | map(.event) | map(select(. != null)) | flatten | map({title, date, room, duration}) | sort_by(.date)' > "$json_path" +cat "$xml_path" | xq '.schedule.day | map(.room) | flatten | map(.event) | map(select(. != null)) | flatten | sort_by(.date)' > "$json_path" if [ -f "$last_json" ]; then diff --color=always "$last_json" "$json_path" rm -f -- "$last_json" fi -ln -sfr "$json_path" "programs/next.json" -mv --no-copy "programs/next.json" "programs/current.json" +symlink echo 'New program content fetched' -stat -c %N programs/current.json -- cgit v1.3.1