Update on (leave realm)

Update on (leave realm)
This commit is contained in:
PierreGode 2022-03-29 13:33:16 +02:00 committed by GitHub
parent 6c0f5ce42d
commit 210b056ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2458,41 +2458,27 @@ leaves(){
export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 )
clear
LEFT=$(sudo realm discover | grep configured | awk '{print $2}') < /dev/null > /dev/null 2>&1
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') < /dev/null > /dev/null 2>&1
SSSD=$( sudo cat /etc/sssd/sssd.conf | grep domain | awk '{print $3}' | head -1 ) < /dev/null > /dev/null 2>&1
DOMAINlower=$( echo "$DOMAIN" | tr '[:upper:]' '[:lower:]' ) < /dev/null > /dev/null 2>&1
if ! realm discover < /dev/null > /dev/null 2>&1
if [ -f /etc/sssd/sssd.conf ]
then
echo ""
echo "Realm not found, nothing to leave"
echo ""
else
if [ "$DOMAINlower" = "$SSSD" ] < /dev/null > /dev/null 2>&1
then
echo "Detecting realm $SSSD"
else
if [ "$LEFT" = "no" ] < /dev/null > /dev/null 2>&1
then
echo ""
echo "$DOMAIN has not been configured"
echo ""
exit
fi
fi
read -r -p "Do you really want to leave the domain: $DOMAIN (y/n)?" yn
read -r -p "Do you really want to leave the domain: $SSSD (y/n)?" yn
case $yn in
[Yy]* ) echo "Listing domain"
sudo realm discover "$DOMAIN"
sudo realm leave "$DOMAIN"
#sudo realm discover "$SSSD"
if ! sudo realm leave "$SSSD"
then
echo "failed Nothing to leave"
exit 0
else
LEFT=$(sudo realm discover | grep configured | awk '{print $2}')
if [ "$LEFT" = "no" ]
then
echo ""
sudo echo "" | sudo tee /etc/sssd/sssd.conf
echo "$DOMAIN has been left"
echo "has left $SSSD"
echo ""
notify-send ADconnection "Left $DOMAIN "
notify-send ADconnection "Left $SSSD "
else
echo "something went wrong, try to leave manually"
echo ""
@ -2511,8 +2497,9 @@ read -r -p "Do you really want to leave the domain: $DOMAIN (y/n)?" yn
echo "something went wrong"
fi
fi
fi
;;
[Nn]* ) echo "Bye"
[Nn]* ) echo "Not leaving $SSSD"
exit
;;
* ) echo 'Please answer yes or no.';;
@ -2520,7 +2507,6 @@ read -r -p "Do you really want to leave the domain: $DOMAIN (y/n)?" yn
exit
fi
exit
}
################################## encrypt pwd ###############################
encrypt(){
echo "This will create 3 files public key, private key and encrypted file"