name: Setup
runs:
  using: composite
  steps:
    - shell: bash
      run: |
        set -x

        sudo service mysql start
        sudo service postgresql start
        sudo service slapd start
        mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
        # Ensure local_infile tests can run.
        mysql -uroot -proot -e "SET GLOBAL local_infile = true"
        sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
        sudo -u postgres psql -c "CREATE DATABASE test;"
        docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U SA -P "<YourStrong@Passw0rd>" -Q "create login pdo_test with password='password', check_policy=off; create user pdo_test for login pdo_test; grant alter, control to pdo_test;"
        sudo locale-gen de_DE

        ./.github/scripts/setup-slapd.sh &>/dev/null

        sudo cp ext/snmp/tests/snmpd.conf /etc/snmp
        sudo cp ext/snmp/tests/bigtest /etc/snmp
        sudo service snmpd restart

        sudo groupadd -g 5000 vmail
        sudo useradd -m -d /var/vmail -s /bin/false -u 5000 -g vmail vmail
        sudo cp ext/imap/tests/setup/dovecot.conf /etc/dovecot/dovecot.conf
        sudo cp ext/imap/tests/setup/dovecotpass /etc/dovecot/dovecotpass
        sudo service dovecot restart
