mjestecko/upload.sh

31 lines
758 B
Bash
Raw Permalink Normal View History

2024-02-16 11:53:21 +00:00
#!/usr/bin/env bash
2024-02-16 15:25:19 +00:00
set +e
2024-07-28 01:06:19 +00:00
for arg in "$*"
do
case "$arg" in
"--fresh") find ./html/ -type f -name '*.upload-checksum' -delete
;;
esac
done
2023-05-25 19:00:38 +00:00
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