#!/usr/bin/env bash

. /usr/share/dosis2/bin/shell-support-functions

systemtype="$1"

CONFFILE="`choose_first_existing_file \"/etc/gdm3/custom.conf\" \"/etc/gdm/custom.conf\"`"

if [ "${CONFFILE}" != "" ]; then
    if [ "${systemtype}" = "site-server" ]; then
        echo "Updating ${CONFFILE} daemon.AutomaticLoginEnable=false"
        /opt/dosis2/bin/conf-edit "${CONFFILE}" \
            --output "${CONFFILE}" \
            --set daemon.AutomaticLoginEnable="false"
    else
        echo "Updating ${CONFFILE} daemon.AutomaticLoginEnable=true"
        /opt/dosis2/bin/conf-edit "${CONFFILE}" \
            --output "${CONFFILE}" \
            --set daemon.AutomaticLoginEnable="true"
    fi
fi
