diff --git a/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-ciso-assistant.sh b/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-ciso-assistant.sh index 8605e39..26cd82c 100644 --- a/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-ciso-assistant.sh +++ b/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-ciso-assistant.sh @@ -1,17 +1,11 @@ #! /usr/bin/env bash set -euo pipefail -DB_FILE="db/ciso-assistant.sqlite3" -BACKUP_FILE="ciso-assistant-backup.sqlite3" +#DB_FILE="db/ciso-assistant.sqlite3" +#BACKUP_FILE="ciso-assistant-backup.sqlite3" # Backup the database -if [ ! -f "$DB_FILE" ]; then - echo "Error: No database found, please initialize CISO Assistant first" - exit 1 -else - cp "$DB_FILE" "$BACKUP_FILE" - echo "Backup of the database created in $BACKUP_FILE" -fi +/usr/bin/docker compose -f /opt/cisoas/docker-compose.yml exec -T postgres /usr/local/bin/backup # Stop and clean the containers docker compose rm -fs diff --git a/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-cisoas-enterprise_test.sh b/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-cisoas-enterprise_test.sh index ed84447..da482cf 100644 --- a/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-cisoas-enterprise_test.sh +++ b/global/overlay/etc/puppet/modules/net/files/cisoassistant/update-cisoas-enterprise_test.sh @@ -1,3 +1,30 @@ #! /usr/bin/env bash -cd /opt/cisoas/ -./update-ciso-assistant.sh enterprise \ No newline at end of file + +VERSION=${1:-community} + + +if [ "$VERSION" = "enterprise" ]; then + BACKEND_IMAGE="ghcr.io/intuitem/ciso-assistant-enterprise-backend:latest" + FRONTEND_IMAGE="ghcr.io/intuitem/ciso-assistant-enterprise-frontend:latest" +else + BACKEND_IMAGE="ghcr.io/intuitem/ciso-assistant-community/backend:latest" + FRONTEND_IMAGE="ghcr.io/intuitem/ciso-assistant-community/frontend:latest" +fi + +echo "Update of the version : $VERSION" + +# Backup the database + +echo "Backing up database" + +/opt/cisoas ❯ /usr/bin/docker compose -f /opt/cisoas/docker-compose.yml exec -T postgres /usr/local/bin/backup + +# Stop the containers +docker compose down + +# Remove the images +docker rmi "$BACKEND_IMAGE" "$FRONTEND_IMAGE" 2>/dev/null + +# Start the containers +docker compose up -d +echo "CISO assistant updated successfully" \ No newline at end of file diff --git a/global/overlay/etc/puppet/modules/net/manifests/cisoassistant_test.pp b/global/overlay/etc/puppet/modules/net/manifests/cisoassistant_test.pp index 6ad9bc5..db036d6 100644 --- a/global/overlay/etc/puppet/modules/net/manifests/cisoassistant_test.pp +++ b/global/overlay/etc/puppet/modules/net/manifests/cisoassistant_test.pp @@ -64,13 +64,6 @@ class net::cisoassistant_test ($ciso_service_name='', content => file('net/cisoassistant/update-cisoas-enterprise_test.sh'), } -> - file { '/opt/cisoas/update-ciso-assistant.sh': - mode => '0744', - owner => 'root', - group => 'root', - content => file('net/cisoassistant/update-ciso-assistant.sh'), - } -> - file { '/opt/cisoas/Caddyfile': owner => 'root', group => 'root', @@ -85,4 +78,12 @@ class net::cisoassistant_test ($ciso_service_name='', ok_criteria => ['exit_status=0', 'max_age=10d'], } + sunet::scriptherder::cronjob { 'postgres_backup': + cmd => '/usr/bin/docker compose -f /opt/cisoas/docker-compose.yml exec -T postgres /usr/local/bin/backup', + minute => '34', + hour => '3', + ok_criteria => ['exit_status=0', 'max_age=25h'], + warn_criteria => ['exit_status=0', 'max_age=49h'], + } + }