add gateway automatic template and fefan vm

This commit is contained in:
2026-01-19 17:05:38 +01:00
parent d98c7b8bdb
commit f851ead7cd
56 changed files with 1243 additions and 82 deletions

View File

@@ -3,6 +3,6 @@
source /opt/bookshelf/env.sh
TIMESTAMP=$(date +'%Y-%m-%d_%H%M%S')
docker exec bookshelf-database-1 mariadb-dump --all-database -u root -p"$MARIADB_ROOT_PASSWORD" > $BOOKSHELF_BACKUPS_DIR/bookshelf-dump-$TIMESTAMP.sql
docker exec bookshelf-database-1 mariadb-dump --all-databases -u root -p"$MARIADB_ROOT_PASSWORD" > $BOOKSHELF_BACKUPS_DIR/bookshelf-dump-$TIMESTAMP.sql
ls -1dt $BOOKSHELF_BACKUPS_DIR/$BOOKSHELF_BACKUP_PREFIX-*.zip | tail -n +5 | xargs -r rm -f
ls -1dt $BOOKSHELF_BACKUPS_DIR/$BOOKSHELF_BACKUP_PREFIX-*.sql | tail -n +5 | xargs -r rm -f

View File

@@ -1,4 +1,4 @@
#!/bin/bash
set -a
[ -f /opt/bookshelf/secrets/bookshelf.env ] && source /opt/bookshelf/secrets/bookshelf.env
[ -f /opt/bookshelf/bookshelf.env ] && source /opt/bookshelf/bookshelf.env
set +a

View File

@@ -31,6 +31,17 @@ done
if [ "$CONCLUSION" = "success" ]; then
echo "Launching command..."
while [ "$(docker inspect -f '{{.State.Running}}' bookshelf-database-1 2>/dev/null)" != "true" ]; do
echo "Waiting database container status"
sleep 5
done
until docker exec bookshelf-database-1 sh -c "mariadb -u root -p$MARIADB_ROOT_PASSWORD -e 'SELECT 1;' >/dev/null 2>&1"; do
echo "Waitin mariadb to accept connections"
sleep 5
done
echo "Restoring backup"
systemctl start restore-backup.service
else
echo "Workflow failed or was cancelled, aborting."

View File

@@ -2,6 +2,16 @@
source /opt/bookshelf/env.sh
## .env should define
# ACT_RUNNER_USER: act_runner username (act_runner)
# ACT_RUNNER_LOCATION: act_runner binary location (/usr/local/bin)
# ACT_RUNNER_VERSION: act_runner version (0.2.13)
# ENV_FILE_LOCATION: .env file location on vm (/opt/bookshelf/bookshelf.env)
# GITEA_INSTANCE_URL: url of the gitea instance (https://gitea.aldon.fr)
# GITEA_RUNNER_REGISTRATION_TOKEN: registration token for gitea runner (repository scope)
# USERNAME: username of the vm (bookshelf)
# REPOSITORY: repository on which service code is hosted (mop/bookshelf)
if ! id -u $ACT_RUNNER_USER >/dev/null 2>&1; then
adduser \
--system \
@@ -30,9 +40,9 @@ runner:
fetch_interval: 2s
github_mirror: ''
labels:
- "ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest"
- "ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04"
- "ubuntu-20.04:docker://docker.gitea.com/runner-images:ubuntu-20.04"
- 'ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest'
- 'ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04'
- 'ubuntu-20.04:docker://docker.gitea.com/runner-images:ubuntu-20.04'
cache:
enabled: true
dir: ""
@@ -55,5 +65,5 @@ host:
EOF
cd /home/act_runner
sudo -u $ACT_RUNNER_USER act_runner register --no-interactive --instance $GITEA_INSTANCE_URL --token $GITEA_RUNNER_REGISTRATION_TOKEN --name $USERNAME --labels $USERNAME $REPOSITORY
sudo -u $ACT_RUNNER_USER act_runner register --no-interactive --instance $GITEA_INSTANCE_URL --token $GITEA_RUNNER_REGISTRATION_TOKEN --name $USERNAME --labels $USERNAME
chown -R $ACT_RUNNER_USER:docker /home/$ACT_RUNNER_USER