Update ADconnection.sh

This commit is contained in:
PierreGode 2019-04-04 15:46:20 +02:00 committed by GitHub
parent b7d3a3a11b
commit b55394b1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,12 +16,12 @@
# see lines 355-371 for more advanced or specific setups of SSSD # see lines 355-371 for more advanced or specific setups of SSSD
# ~~~~~~~~~~ Environment Setup ~~~~~~~~~~ # # ~~~~~~~~~~ Environment Setup ~~~~~~~~~~ #
NORMAL="\033[m" NORMAL=$(printf "\033[m")
MENU="\033[36m" #Blue MENU=$(printf "\033[36m")
NUMBER="\033[33m" #yellow NUMBER=$(printf "\033[33m")
RED_TEXT="\033[31m" #Red RED_TEXT=$(printf "\033[31m")
INTRO_TEXT="\033[32m" #green and white text INTRO_TEXT=$(printf "\033[32m")
END="\033[0m" END=$(printf "\033[0m")
# ~~~~~~~~~~ Environment Setup ~~~~~~~~~~ # # ~~~~~~~~~~ Environment Setup ~~~~~~~~~~ #
################################ fix errors # funktion not called ################ ################################ fix errors # funktion not called ################
@ -173,6 +173,7 @@ entry_cache_timeout = 600
#ldap_group_member = uniquemember #ldap_group_member = uniquemember
#ad_enable_gc = False #ad_enable_gc = False
entry_cache_nowait_percentage = 75" | sudo tee -a /etc/sssd/sssd.conf entry_cache_nowait_percentage = 75" | sudo tee -a /etc/sssd/sssd.conf
clear
################################# Check ####################################### ################################# Check #######################################
if ! sudo service sssd restart if ! sudo service sssd restart
@ -181,7 +182,7 @@ echo "Checking sssd config.. FAIL"
else else
echo "Checking sssd config.. OK" echo "Checking sssd config.. OK"
fi fi
if ! realm discover if ! realm discover < /dev/null > /dev/null 2>&1
then then
echo "Realm not installed" echo "Realm not installed"
else else
@ -535,7 +536,7 @@ UbuntU(){
export HOSTNAME export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) myhost=$( hostname | cut -d '.' -f1 )
clear clear
sudo echo "${RED_TEXT}Installing packages do no abort!.......${END}" sudo echo "${NUMBER}Installing packages do no abort!.......${END}"
if ! sudo apt-get -qq install realmd adcli sssd ntp -y && sudo apt-get -qq install -f -y if ! sudo apt-get -qq install realmd adcli sssd ntp -y && sudo apt-get -qq install -f -y
then then
echo "${RED_TEXT}Failed installing packages, please resolve dpkg and try again ${END}" echo "${RED_TEXT}Failed installing packages, please resolve dpkg and try again ${END}"
@ -1165,7 +1166,7 @@ failcheck(){
clear clear
export HOSTNAME export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) myhost=$( hostname | cut -d '.' -f1 )
if ! hostname | cut -d '.' -f1 if ! hostname | cut -d '.' -f1 < /dev/null > /dev/null 2>&1
then then
echo "Sorry I am having issues finding your domain.. please type it" echo "Sorry I am having issues finding your domain.. please type it"
read -r DOMAIN read -r DOMAIN
@ -1174,9 +1175,10 @@ echo ""
fi fi
echo "" echo ""
echo "-------------------------------------------------------------------------------------" echo "-------------------------------------------------------------------------------------"
echo ""
if ! realm discover < /dev/null > /dev/null 2>&1 if ! realm discover < /dev/null > /dev/null 2>&1
then then
echo "realm not found" echo "Realm not found"
else else
echo "" echo ""
therealm=$( realm discover | grep -i configured | awk '{print $2}') therealm=$( realm discover | grep -i configured | awk '{print $2}')
@ -1186,7 +1188,6 @@ echo Realm configured?.. "${RED_TEXT}FAIL${END}"
else else
echo Realm configured?.. "${INTRO_TEXT}OK${END}" echo Realm configured?.. "${INTRO_TEXT}OK${END}"
fi fi
fi
if [ -f /etc/sudoers.d/sudoers ] < /dev/null > /dev/null 2>&1 if [ -f /etc/sudoers.d/sudoers ] < /dev/null > /dev/null 2>&1
then then
echo Checking sudoers file.. "${INTRO_TEXT}OK${END}" echo Checking sudoers file.. "${INTRO_TEXT}OK${END}"
@ -1214,6 +1215,7 @@ echo Checking PAM auth configuration.. "${INTRO_TEXT}OK${END}"
else else
echo Checking PAM auth configuration.. "${RED_TEXT}SSH security not configured${END}" echo Checking PAM auth configuration.. "${RED_TEXT}SSH security not configured${END}"
fi fi
fi
echo "" echo ""
echo "-------------------------------------------------------------------------------------" echo "-------------------------------------------------------------------------------------"
exit exit
@ -1224,7 +1226,7 @@ failcheck_yum(){
clear clear
export HOSTNAME export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) myhost=$( hostname | cut -d '.' -f1 )
if ! hostname | cut -d '.' -f1 if ! hostname | cut -d '.' -f1 < /dev/null > /dev/null 2>&1
then then
echo "Sorry I am having issues finding your domain.. please type it" echo "Sorry I am having issues finding your domain.. please type it"
read -r DOMAIN read -r DOMAIN
@ -1232,7 +1234,8 @@ else
echo "" echo ""
fi fi
echo "-------------------------------------------------------------------------------------" echo "-------------------------------------------------------------------------------------"
if ! realm dicover echo ""
if ! realm discover
then then
echo "realm not found" echo "realm not found"
else else
@ -1244,7 +1247,6 @@ echo "Realm configured?.. FAIL"
else else
echo "Realm configured?.. OK" echo "Realm configured?.. OK"
fi fi
fi
if [ -f /etc/sudoers.d/admins ] < /dev/null > /dev/null 2>&1 if [ -f /etc/sudoers.d/admins ] < /dev/null > /dev/null 2>&1
then then
echo "Checking sudoers file.. OK" echo "Checking sudoers file.. OK"
@ -1284,12 +1286,12 @@ echo "Checking PAM auth configuration.. OK"
else else
echo "Checking PAM auth configuration.. SSH security not configured" echo "Checking PAM auth configuration.. SSH security not configured"
fi fi
fi
echo "" echo ""
echo "-------------------------------------------------------------------------------------" echo "-------------------------------------------------------------------------------------"
exit exit
} }
#################################### ldapsearch ##################################################### #################################### ldapsearch #####################################################
ldaplook(){ ldaplook(){
export HOSTNAME export HOSTNAME
@ -1310,13 +1312,18 @@ sudo ldapsearch -x | grep -i "$own"
exit exit
else else
clear clear
sudo apt-get install ldap-utils -y if ! sudo apt-get install ldap-utils -y
then
echo "install failed"
exit
else
echo "${NUMBER}please edit in ldap.conf the lines BASE and URI ${END}" echo "${NUMBER}please edit in ldap.conf the lines BASE and URI ${END}"
sleep 3 sleep 3
sudo nano /etc/ldap/ldap.conf sudo nano /etc/ldap/ldap.conf
sudo ldapsearch -x | grep -i "$myhost" sudo ldapsearch -x | grep -i "$myhost"
exit exit
fi fi
fi
} }
############################### Reauth ########################################## ############################### Reauth ##########################################
@ -1389,10 +1396,17 @@ fi
######################### Leave Realm ################################ ######################### Leave Realm ################################
leaves(){ leaves(){
LEFT=$(sudo realm discover | grep configured | awk '{print $2}') clear
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') LEFT=$(sudo realm discover | grep configured | awk '{print $2}') < /dev/null > /dev/null 2>&1
SSSD=$( sudo cat /etc/sssd/sssd.conf | grep domain | awk '{print $3}' | head -1 ) DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') < /dev/null > /dev/null 2>&1
DOMAINlower=$( echo "$DOMAIN" | tr '[:upper:]' '[:lower:]' ) 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
then
echo ""
echo "Realm not found, nothing to leave"
echo ""
else
if [ "$DOMAINlower" = "$SSSD" ] < /dev/null > /dev/null 2>&1 if [ "$DOMAINlower" = "$SSSD" ] < /dev/null > /dev/null 2>&1
then then
echo "Detecting realm $SSSD" echo "Detecting realm $SSSD"
@ -1441,6 +1455,8 @@ read -r -p "Do you really want to leave the domain: $DOMAIN (y/n)?" yn
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
exit exit
fi
exit
} }
################################## info ################################## ################################## info ##################################
@ -1653,7 +1669,7 @@ while test $# -gt 0; do
;; ;;
-s) -s)
if test $# -gt 0; then if test $# -gt 0; then
if ! realm < /dev/null > /dev/null 2>&1 if ! realm discover < /dev/null > /dev/null 2>&1
then then
clear clear
echo "" echo ""