#!/bin/bash
#
# Written by Michel Decima
# Copyright (C) 2020 Orange
#

(( 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/03-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

