#!/bin/bash
#
#   Software Name : orange-yourdev-login
#   SPDX-License-Identifier: Orange-InnerSource
#   SPDX-FileCopyrightText: Copyright (c) 2020-2022 Orange SA
# 
#   This software is confidential and proprietary information of Orange SA.
#   You shall not disclose such Confidential Information and shall not copy,
#   use or distribute it in whole or in part without the prior written
#   consent of Orange SA.
#  
#   Author: Michel Decima <michel.decima@orange.com>
#


(( EUID == 0 )) || { echo >&2 "Not root." ; exit 1 ; }

if [ -e /etc/pam.d/gdm-smartcard-sssd-or-password ] ; then
    update-alternatives --set gdm-smartcard \
        /etc/pam.d/gdm-smartcard-sssd-or-password
fi

sed -Ei 's/(enable-smartcard-authentication)=.*/\1=false/' \
    /etc/dconf/db/gdm.d/01-smartcard
dconf update

systemctl enable sssd.service sssd-pam.socket
systemctl start sssd.service || exit 1

cat << EOF
Please restart desktop manager with command:
  systemctl restart gdm3
EOF

