Verified Commit 968b905e authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Make init container SQL config more generic

This requires changes to the database secrets, which now have to have
an item with a key that matches the value of a line in each
`sql*.conf.ext` file formatted as:

> # dbname: <KEY>

Each item must additionally contain a "host" value as well as the
previously required "username" and "password" values.  Optionally
a "dbname" value could be supplied to override the database name in the
items's key.
parent fb58673c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
# dbname: app_accounts

# [userdb_]mail fields need removal with a data migration

default_pass_scheme = SHA256
+17 −6
Original line number Diff line number Diff line
@@ -55,16 +55,27 @@ spec:
          mountPath: /secrets
        command:
        - sh
        - -c
        - -euc
        - |
          . /secrets/pass.cnf
          mkdir -p /var/mail/virtual
          chown 5000:5000 /var/mail/virtual
          cp -Lr /source/* /config
          cat <<END_CONF >>/config/sql-site.conf.ext
          for conf in /config/sql-*.conf.ext; do
            if ! dbname=`sed -n 's/^#\s*dbname:\s*\(.*\)/\1/p' <$conf`; then
              echo >&2 'unable to find "# dbname: <NAME>" line in' "$conf"
              exit 1
            fi
            if ! [[ -r /secrets/$dbname ]]; then
              echo >&2 'unable to read details for database' "$dbname"
              exit 1
            fi
            . /secrets/$dbname
            cat <<END_CONF >>$conf
              driver = mysql
          connect = host=dex.kodo.org.uk dbname=app_accounts user=$username password=$password
              connect = host=$host dbname=$dbname user=$username password=$password
            END_CONF
            unset host username password
          done
      # - name: migrate
      #   image: docker.kodo.org.uk/docker/dovecot:2.3.19-1
      #   command: ["doveadm", "sync", "-f", "-A", "imap.default.svc.cluster.local"]