- I would like to have website autobuild when new pages are added.
- What about drafts?
- Drafts would still be synced
- Server would see changes
- Server would rebuild needlessly as I wrote my articles
- Could write all drafts in an “exlcuded” folder
- Don’t like this though
- Maybe set sync to like 15 minutes?
- A nice balance between syncing and constant building.
- 15 minutes isn’t a long time to wait for new articles.
- I have obsidian sync working locally
- It’s easy to set up,
- key thing is to set —mode to
mirror-remote.- This will ensure changes are one way only
- Plan
- setup obsidian sync on server
- setup quartz on server
- write a script that will
- Run obsidian sync
- if changes detected
- Build with quartz
- Push files to http folder
- Dangers to watch out for
- Sync message changing, ruining change detection
- sync client going out of date
- Running through Setup now
- Installed ob sync on server
- Ran test sync
- I think the best way of testing for changes I know (without using AI) is to count the lines
VAR=$(ob sync --path /home/shroomy/vaults/shroo.my/ | wc -l)- When this is greater than 13 then do build
- Installed my version of quartz from my repo
- Ran a test build
- Deleted existing wesite
- Copied from public to serverer folder
- It works!
- Although I’ve forgotten to sync my customizations from my home laptop to my repo Bash script:
#!/bin/bash
LINECOUNT=$(ob sync --path /home/shroomy/vaults/shroo.my/ | wc -l)`
cd /home/shroomy/code/shroo.my
npx quartz sync
if [ "$LINECOUNT" -gt 13 ];then
npx quartz build
rm -rf /var/www/shroo.my/html/*
cp -r /home/shroomy/code/shroo.my/public/* /var/www/shroo.my/html/
fiMajor EDIT!
After poking around I found a Database file! It lives in /home/{user}/.config/obsidian-headless/{vault_id}/state.db. In the META table is a version number that increases with every sync. So… my new script doesn’t rely on the line count anymore! Also, I added some comments…
#!/bin/bash
echo "===[$(date)] Starting Obsidian sync==="
DB_PATH="/home/shroomy/.config/obsidian-headless/sync/f48cba89fc7b0d97233d008f7992bee5/state.db"
before=$(sqlite3 "$DB_PATH" 'SELECT value FROM meta WHERE key="version";')
ob sync --path /home/shroomy/vaults/shroo.my/
after=$(sqlite3 "$DB_PATH" 'SELECT value FROM meta WHERE key="version";')
if [ "$before" != "$after" ];then
echo "===Changes Found, Starting Build==="
echo "===Starting Quartz sync==="
cd /home/shroomy/code/shroo.my
npx quartz sync
echo "===Starting Quartz Build==="
npx quartz build
echo "===Deleting Old Files==="
rm -rf /var/www/shroo.my/html/*
echo "===Copying accross new files==="
cp -r /home/shroomy/code/shroo.my/public/* /var/www/shroo.my/html/
else
echo "=== No Changes Detected! ==="
fi
echo "===Sync Complete!==="
echo "