#!/bin/bash

UUID=b88416e8-1762-45c7-ad93-82be4fbf72a4

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<project version=\"4\">
    <component name=\"RemoteMappingsManager\">
        <list>
            <list>
                <remote-mappings server-id=\"php@${UUID}\" />
            </list>
        </list>
    </component>
</project>" > /drupal/.idea/remote-mappings.xml

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<project version=\"4\">
    <component name=\"PhpDockerContainerSettings\">
        <list>
            <map>
                <entry key=\"${UUID}\">
                    <value>
                        <DockerContainerSettings>
                            <option name=\"envVars\">
                                <list>
                                    <DockerEnvVarImpl>
                                        <option name=\"name\"
                                                value=\"COMPOSE_PROJECT_NAME\"/>
                                        <option name=\"value\" value=\"${COMPOSE_PROJECT_NAME}\"/>
                                    </DockerEnvVarImpl>
                                    <DockerEnvVarImpl>
                                        <option name=\"name\"
                                                value=\"PHP_VERSION\"/>
                                        <option name=\"value\" value=\"${PHP_VERSION}\"/>
                                    </DockerEnvVarImpl>
                                    <DockerEnvVarImpl>
                                        <option name=\"name\"
                                                value=\"SSH_AUTH_SOCK\"/>
                                        <option name=\"value\"
                                                value=\"/ssh-agent\"/>
                                    </DockerEnvVarImpl>
                                </list>
                            </option>
                            <option name=\"version\" value=\"1\"/>
                            <option name=\"volumeBindings\">
                                <list>
                                    <DockerVolumeBindingImpl>
                                        <option name=\"containerPath\"
                                                value=\"/drupal\"/>
                                        <option name=\"hostPath\"
                                                value=\"${WORKDIR}\"/>
                                    </DockerVolumeBindingImpl>
                                    <DockerVolumeBindingImpl>
                                        <option name=\"containerPath\"
                                                value=\"/ssh-agent\"/>
                                        <option name=\"hostPath\"
                                                value=\"${SSHAUTH}\"/>
                                    </DockerVolumeBindingImpl>
                                    <DockerVolumeBindingImpl>
                                        <option name=\"containerPath\"
                                                value=\"/var/run/docker.sock\"/>
                                        <option name=\"hostPath\"
                                                value=\"/var/run/docker.sock\"/>
                                    </DockerVolumeBindingImpl>
                                    <DockerVolumeBindingImpl>
                                        <option name=\"containerPath\"
                                                value=\"/root/.traefik\"/>
                                        <option name=\"hostPath\"
                                                value=\"${HOMEDIR}/.traefik\"/>
                                    </DockerVolumeBindingImpl>
                                    <DockerVolumeBindingImpl>
                                        <option name=\"containerPath\"
                                                value=\"/root/.gitconfig\"/>
                                        <option name=\"hostPath\"
                                                value=\"${HOMEDIR}/.gitconfig\"/>
                                    </DockerVolumeBindingImpl>
                                    <DockerVolumeBindingImpl>
                                        <option name=\"containerPath\"
                                                value=\"/root/.composer/auth.json\"/>
                                        <option name=\"hostPath\"
                                                value=\"${HOMEDIR}/.composer/auth.json\"/>
                                    </DockerVolumeBindingImpl>
                                </list>
                            </option>
                        </DockerContainerSettings>
                    </value>
                </entry>
            </map>
        </list>
    </component>
</project>" > /drupal/.idea/php-docker-settings.xml
