2024-02-10 17:27:52 +00:00
|
|
|
Title: Cached Neocities Uploads
|
|
|
|
Brief: Making uploading of directories to Neocities less painful.
|
|
|
|
Date: 1707585916
|
2024-02-16 11:29:54 +00:00
|
|
|
Tags: Programming, Bash
|
2024-02-10 17:27:52 +00:00
|
|
|
CSS: /style.css
|
|
|
|
|
|
|
|
Quick and dirty Bash-based sha256sum checksum solution to create stamps for later checking and rejection.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
#!/usr/bin/bash
|
|
|
|
|
|
|
|
for cur in ./html/{*,*/*,*/*/*}; do
|
|
|
|
if [ -f "$cur" ] && [[ ! "$cur" == *.upload-checksum ]]; then
|
|
|
|
if [ -f "$cur.upload-checksum" ]; then
|
|
|
|
c=$(cat "$cur.upload-checksum" | sha256sum -c 2> /dev/null)
|
|
|
|
if [[ "$c" == *OK ]]; then
|
|
|
|
echo "$cur is up-to-date, skipping"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $(sha256sum "$cur") > "$cur.upload-checksum"
|
|
|
|
d=$(dirname $(realpath --relative-to="./html" "$cur"))
|
|
|
|
if [[ "$d" == "." ]]; then
|
|
|
|
neocities upload $cur
|
|
|
|
else
|
|
|
|
neocities upload -d $(dirname $(realpath --relative-to="./html" "$cur")) $cur
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
```
|