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