Created
December 19, 2025 20:50
-
-
Save dmd/efbfe29d4814f42edf8403e0f37de432 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # 1. pulls the Tech schedule ICS from Booked | |
| # 2. adds it to the scandiumexport git repo | |
| # 3. push that repo to plesk which publishes it to https://www.mcleanmri.org/scandiumexport/techs.ics | |
| # --- Configuration --- | |
| TARGET_DIR="/home/scandium/scandiumexport" | |
| FILENAME="techs.ics" | |
| TEMP_FILE="${FILENAME}.tmp" | |
| LOG_FILE="/home/scandium/scandiumexport.log" | |
| ICAL_URL="https://scandium.mclean.harvard.edu/export/ical-subscribe.php?uid=&sid=&rid=00f6d84beb4f7dcf28e1&icskey=ji58gjj4329dfkgj5nhkfi" | |
| PING_URL="https://hc-ping.com/f8a11d1a-3eef-4eb5-9047-470d40ae1b33" | |
| # --- Logging Setup --- | |
| # Redirect all Standard Output (1) and Standard Error (2) to the log file | |
| exec >> "$LOG_FILE" 2>&1 | |
| # Add a timestamp so you know when this run started | |
| echo "--- Run started at $(date) ---" | |
| # --- Execution --- | |
| # 1. Change to the target directory | |
| if ! cd "$TARGET_DIR"; then | |
| echo "Critical Error: Could not find directory $TARGET_DIR" | |
| exit 1 | |
| fi | |
| # 2. Download to a temp file first | |
| # -sSfL: Silent (but show errors), Fail on HTTP error, Follow redirects | |
| if curl -sSfL "$ICAL_URL" -o "$TEMP_FILE"; then | |
| # 3. Rename temp file to actual file | |
| mv "$TEMP_FILE" "$FILENAME" | |
| # 4. Git Operations | |
| git add "$FILENAME" | |
| # Check if there are changes to commit. | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Update $FILENAME: $(date '+%Y-%m-%d %H:%M:%S')" | |
| # Push changes | |
| if git push; then | |
| echo "Git push successful." | |
| # 5. Success Ping | |
| curl -fsS -m 10 --retry 5 -o /dev/null "$PING_URL" | |
| else | |
| echo "Error: Git push failed." | |
| exit 1 | |
| fi | |
| else | |
| echo "No changes detected in $FILENAME. Skipping commit." | |
| # Still ping because the check was successful | |
| curl -fsS -m 10 --retry 5 -o /dev/null "$PING_URL" | |
| fi | |
| else | |
| # Curl failed | |
| rm -f "$TEMP_FILE" | |
| echo "Error: Download failed. No changes made." | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment