add bookshelf module, fix gitea minor typo, add fixe ip for vms
This commit is contained in:
38
modules/apps/bookshelf/lib/scripts/install-bookshelf.sh
Normal file
38
modules/apps/bookshelf/lib/scripts/install-bookshelf.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /opt/bookshelf/env.sh
|
||||
|
||||
# trigger manually a CI/CD pipeline
|
||||
curl -X POST -H "Authorization: token $GITEA_BOOKSHELF_APPLICATION_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
$GITEA_INSTANCE_URL/api/v1/repos/$GITEA_BOOKSHELF_REPOSITORY/actions/workflows/deploy.yaml/dispatches \
|
||||
-d '{"ref": "main", "inputs": {"ref": "main"}}'
|
||||
|
||||
RUN_ID=$(curl -s -H "Authorization: token $GITEA_BOOKSHELF_APPLICATION_TOKEN" \
|
||||
$GITEA_INSTANCE_URL/api/v1/repos/$GITEA_BOOKSHELF_REPOSITORY/actions/runs \
|
||||
| jq -r '.workflow_runs | sort_by(.created_at) | .[0].id')
|
||||
|
||||
while true; do
|
||||
STATUS=$(curl -s -H "Authorization: token $GITEA_BOOKSHELF_APPLICATION_TOKEN" \
|
||||
$GITEA_INSTANCE_URL/api/v1/repos/$GITEA_BOOKSHELF_REPOSITORY/actions/runs/$RUN_ID \
|
||||
| jq -r '.status')
|
||||
|
||||
if [ "$STATUS" = "completed" ]; then
|
||||
CONCLUSION=$(curl -s -H "Authorization: token $GITEA_BOOKSHELF_APPLICATION_TOKEN" \
|
||||
$GITEA_INSTANCE_URL/api/v1/repos/$GITEA_BOOKSHELF_REPOSITORY/actions/runs/$RUN_ID \
|
||||
| jq -r '.conclusion')
|
||||
echo "Workflow finished with status: $CONCLUSION"
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Waiting 10 seconds..."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
if [ "$CONCLUSION" = "success" ]; then
|
||||
echo "Launching command..."
|
||||
systemctl start restore-backup.service
|
||||
else
|
||||
echo "Workflow failed or was cancelled, aborting."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user