apiVersion: v1
kind: ConfigMap
metadata:
  name: identity-configmap
data:
  start.sh: |-
    set -xe
    mkdir /httpdir/run || rm -rf /httpdir/run/*
    ln -s /etc/httpd/modules /httpdir/modules
    truncate --size=0 /httpdir/accesslog /httpdir/errorlog
    tail -qf /httpdir/accesslog /httpdir/errorlog &
    ulimit -c 0
    if [ ! -d /etc/ipsilon/httpd ];
    then
      # TODO: Run ipsilon installer and copy stuff back in
      mkdir /etc/ipsilon/{httpd,ipsilon,data}
      LOGFILE=/dev/stdout ipsilon-server-install --config-profile=/etc/ipsilon-cfg/cfgprofile
    fi
    exec httpd -f /etc/ipsilon-cfg/httpd.conf -DFOREGROUND -DNO_DETACH
  httpd.conf: |-
    ServerRoot "/httpdir"
    PidFile "/httpdir/httpd.pid"
    LoadModule authn_file_module modules/mod_authn_file.so
    LoadModule authn_anon_module modules/mod_authn_anon.so
    LoadModule authz_user_module modules/mod_authz_user.so
    LoadModule authz_host_module modules/mod_authz_host.so
    LoadModule include_module modules/mod_include.so
    LoadModule log_config_module modules/mod_log_config.so
    LoadModule env_module modules/mod_env.so
    LoadModule ext_filter_module modules/mod_ext_filter.so
    LoadModule expires_module modules/mod_expires.so
    LoadModule headers_module modules/mod_headers.so
    LoadModule mime_module modules/mod_mime.so
    LoadModule status_module modules/mod_status.so
    LoadModule dir_module modules/mod_dir.so
    LoadModule alias_module modules/mod_alias.so
    LoadModule rewrite_module modules/mod_rewrite.so
    LoadModule version_module modules/mod_version.so
    LoadModule wsgi_module modules/mod_wsgi.so
    LoadModule authn_core_module modules/mod_authn_core.so
    LoadModule authz_core_module modules/mod_authz_core.so
    LoadModule unixd_module modules/mod_unixd.so
    LoadModule mpm_event_module modules/mod_mpm_event.so
    LoadModule ssl_module modules/mod_ssl.so
    StartServers  20
    ServerLimit   100
    MaxRequestsPerChild 2000
    MaxRequestWorkers 100
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    CustomLog /httpdir/accesslog combined
    ErrorLog /httpdir/errorlog
    LogLevel debug
    TypesConfig /etc/mime.types
    AddDefaultCharset UTF-8
    CoreDumpDirectory /tmp
    Listen 0.0.0.0:8443 https
    SSLEngine on
    SSLProtocol TLSv1.2

    SSLCertificateFile /etc/servicecert/tls.crt
    SSLCertificateKeyFile /etc/servicecert/tls.key
    SSLCertificateChainFile /etc/cacert/cert

    Include /etc/ipsilon/httpd/*.conf
  cfgprofile: |-
    [globals]
    datadir = /etc/ipsilon/data
    httpdconfd = /etc/ipsilon/httpd
    confdir = /etc/ipsilon/ipsilon

    [arguments]
    ignored_database_url = postgresql://{{ databse_username }}:{{ database_password }}@{{ database_hostname }}/{{ database_name }}
    admin_user = admin
    gssapi = no
    ipa = no
    port = 8443
    testauth = yes
    openidc = yes
    hostname = identity.mbox.test
    server_debugging = True
    root_instance = yes
    instance = root
    pam = no
