diff options
| author | user@node5.net <user@node5.net> | 2026-07-05 18:50:24 +0200 |
|---|---|---|
| committer | user@node5.net <user@node5.net> | 2026-07-05 18:57:22 +0200 |
| commit | 414188d9e22e7be9af6dd39daedff312712d689b (patch) | |
| tree | cde9cb360787d5d5f7903eaf091471a3df7124d2 | |
| parent | 54cf46883c2afc2a71de1066c272520367bfa6c3 (diff) | |
fetch program - fix symblink broken on new fetch
| -rwxr-xr-x | fetch_program.sh | 16 |
1 files changed, 11 insertions, 5 deletions
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 |
