67 lines
1.2 KiB
Bash
Executable File
67 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
source ./.env
|
|
|
|
url="https://neocities.org"
|
|
auth="Authorization: Bearer $KEY"
|
|
site=.mirror
|
|
|
|
_upload_html() {
|
|
if [ ${1:0:1} = "" ];then
|
|
echo Path must start with ./
|
|
exit 1
|
|
fi
|
|
echo $(pwd)
|
|
for f in $@;do
|
|
remote_path=${f:1}
|
|
echo curl -H "$auth" -F "$remote_path=@$f" $url/api/upload
|
|
curl -H "$auth" -F "$remote_path=@$f" $url/api/upload
|
|
done
|
|
}
|
|
|
|
html() {
|
|
# Total reupload of the site's html
|
|
_upload_html $(find -name '*.html')
|
|
}
|
|
|
|
roots() {
|
|
_upload_html ./*.html
|
|
}
|
|
|
|
folder() {
|
|
if [ -z $1];then
|
|
echo No folder specified > /dev/stderr
|
|
else
|
|
pushd $1 > /dev/null
|
|
_upload_html ./*.html
|
|
popd > /dev/null
|
|
fi
|
|
}
|
|
|
|
_help() {
|
|
cat <<EOF
|
|
Options:
|
|
h => Reuploads all the html content
|
|
r => Uploads all root html pages
|
|
f [FOLDER] => Upload all html in [FOLDER]
|
|
s [PATH] => Upload single html page with mirrord path
|
|
EOF
|
|
}
|
|
|
|
if [ -z $1 ];then
|
|
_help
|
|
else
|
|
pushd $site > /dev/null
|
|
while getopts ':Hhrf:s:' opt;do
|
|
case $opt in
|
|
H) _help;;
|
|
h) _upload_html $(find -name '*.html');; # Upload all html content
|
|
r) _upload_html ./*.html;; # Upload all root html pages
|
|
f) _upload_html $2/*.html;;# Upload html in the spec'd folder
|
|
s) _upload_html $2;;# upload single html page
|
|
esac
|
|
done
|
|
popd > /dev/null
|
|
fi
|
|
|