From 9c3f1cbfd9b4beef7f95469cdd41fa91b336abfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Gourv=C3=A9nec?= Date: Tue, 25 Apr 2023 17:45:04 +0200 Subject: [PATCH] Add script to schedule an optimize on hydra's tables daily --- schedule/extra/01_optimize_hydra.xml | 20 ++++++++++++ schedule/scripts/optimize_hydra | 46 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 schedule/extra/01_optimize_hydra.xml create mode 100644 schedule/scripts/optimize_hydra diff --git a/schedule/extra/01_optimize_hydra.xml b/schedule/extra/01_optimize_hydra.xml new file mode 100644 index 0000000..d9b109a --- /dev/null +++ b/schedule/extra/01_optimize_hydra.xml @@ -0,0 +1,20 @@ + + + + + + + daily + + + + + + + non + dbEnableBackup + none + daily + + + diff --git a/schedule/scripts/optimize_hydra b/schedule/scripts/optimize_hydra new file mode 100644 index 0000000..837b426 --- /dev/null +++ b/schedule/scripts/optimize_hydra @@ -0,0 +1,46 @@ +#!/bin/bash + +DESC="Optimize sur les tables d'Hydra" + +. /usr/share/eole/schedule/config.sh + +echo "Begin date: $(date)" + +day=$(date '+%u') # 1 == Monday + +case $day in + 1) + tables='hydra_oauth2_access' + ;; + 2) + tables='hydra_oauth2_oidc' + ;; + 3) + tables='hydra_oauth2_code' + ;; + 4) + tables='hydra_oauth2_authentication_request' + ;; + 5) + tables='hydra_oauth2_consent_request' + ;; + 6) + tables='hydra_oauth2_logout_request, hydra_oauth2_consent_request_handled' + ;; + 7) + tables='hydra_oauth2_authentication_session, hydra_oauth2_authentication_request_handled, hydra_oauth2_pkce' + ;; + *) + echo "Unexpected error. Day: $day" + exit 1 +esac + +mysql --defaults-file=/etc/mysql/debian.cnf hydra <