# SPDX-License-Identifier: MIT
# Nginx Proxy Manager on the measured requirements bench: what passage.sh needs to know about the
# application. Sourced by passage.sh, on the Proxmox host.

APP_NOM=nginx-proxy-manager
APP_VERSION=2.17.1
APP_IMAGES="jc21/nginx-proxy-manager:2.17.1@sha256:04a9d0835560b9719ab577275f84fe1f713298a1c1e2bdefa034b87f10e062e1"
APP_SANTE="http://10.30.0.207:81/api/"
APP_SANTE_MOTIF='"status":"OK"'
APP_DONNEES="data letsencrypt"
APP_UNITE="proxy-host"

# Simulated users per profile: one visitor per proxied site.
app_utilisateurs() {
  case "$1" in
    idle) echo 0 ;;
    light) echo 10 ;;
    sustained) echo 50 ;;
  esac
}

# The reference dataset: one proxy host per simulated user, HTTPS with an imported certificate.
app_jeu_de_donnees() { echo "$1"; }

app_poser() {
  local ct=$1 src=$2
  pct exec "$ct" -- mkdir -p /opt/banc/app/data /opt/banc/app/letsencrypt
  pct push "$ct" "$src/compose.yaml" /opt/banc/app/compose.yaml
  pct push "$ct" "$src/comptes.sh" /opt/banc/comptes.sh --perms 755
}

# On the load generator: the upstream site the proxy hosts forward to (nginx on port 8080, a page
# and three assets of a typical small site), and the self-signed certificate of *.banc.test that
# the dataset imports as a custom certificate.
app_generateur() {
  local gen=$1 src=$2
  pct push "$gen" "$src/amont.sh" /opt/banc/amont.sh --perms 755
  pct exec "$gen" -- /opt/banc/amont.sh
}
