add: auto deployment scripts

This commit is contained in:
iceBear67 committed 2024-09-02 00:55:52 +08:00
1 parent a8719412c3
commit f2a8e26893
3 files changed
+89 -1

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
UPLOAD=$(ls $UPLOAD | tr ' ' '\n' | grep -v "all")
if ! test -f "$UPLOAD"; then
echo "File does not exist. $UPLOAD"
exit
fi
MOD=$(special_curl $API_ENDPOINT/api/client/servers/$SERVER_ID/files/list\?directory\=/mods -H "Authorization: Bearer $TOKEN" | jq -r ".data[] | .attributes.name" | grep "sfcraft")
echo "Fetch: $MOD"
if [ -n "$MOD" ]; then
echo "Update target: $MOD"
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/files/delete" -H "Content-Type: application/json" -H "Accept: application/json" -X POST -H "Authorization: Bearer $TOKEN" -d "{\"root\": \"/mods\", \"files\": [\"$MOD\"]}"
echo "Deleted."
fi
echo "Uploading $UPLOAD"
SIGNED_URL=$(special_curl $API_ENDPOINT/api/client/servers/$SERVER_ID/files/upload -H "Authorization: Bearer $TOKEN" | jq -r ".attributes.url")
if [ -z "$SIGNED_URL" ]; then
echo "!!! CANNOT FETCH SIGNED URL !!!"
exit
fi
special_curl "$SIGNED_URL&directory=/mods" -X POST -F "files=@$UPLOAD"
echo "Uploaded!"