#!/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 ; }

update-alternatives --set gdm-smartcard \
    /etc/pam.d/gdm-smartcard-pkcs11-exclusive \
    || { echo >&2 "Cannot switch to PKI login (GDM too old?)" ; exit 1 ; }

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

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

