#!/bin/bash

if [ -z $2 ]; then
    AUTH="none"
else
    AUTH="password"
fi

cp -Rn /init-config/.oh-my-zsh         /config/
cp -Rn /init-config/.openvscode-server /config/
cp -Rn /init-config/.zshrc             /config/
mkdir /config/workspace
chown -R abc:abc /config

# Environment
export TZ=Europe/Paris
export SUDO_PASSWORD=abc

# Not executed ?
/usr/bin/bash /etc/cont-init.d/30-config

cd /app/openvscode-server || exit

exec \
    s6-setuidgid abc \
        /usr/local/bin/code-server \
            --bind-addr 0.0.0.0:8443 \
            --user-data-dir /config/data \
            --extensions-dir /config/extensions \
            --disable-telemetry \
            --auth "${AUTH}" \
            /config/workspace
