improved detecting fails and errors.

This commit is contained in:
Pierre Gode 2019-04-02 13:15:44 +02:00
parent 95cb2ce96c
commit 60063f372b

View File

@ -173,13 +173,13 @@ 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
sudo service sssd restart
################################# Check ####################################### ################################# Check #######################################
if [ $? = 0 ] if ! sudo service sssd restart
then then
echo "Checking sssd config.. OK"
else
echo "Checking sssd config.. FAIL" echo "Checking sssd config.. FAIL"
else
echo "Checking sssd config.. OK"
fi fi
therealm=$(realm discover "$DOMAIN" | grep -i configured: | cut -d ':' -f2 | sed -e 's/^[[:space:]]*//') therealm=$(realm discover "$DOMAIN" | grep -i configured: | cut -d ':' -f2 | sed -e 's/^[[:space:]]*//')
if [ "$therealm" = "no" ] if [ "$therealm" = "no" ]
@ -369,13 +369,11 @@ 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
sudo service sssd restart
####################### Check ######################### ####################### Check #########################
if [ $? = 0 ] if ! sudo service sssd restart
then then
echo "Checking sssd config.. OK" echo "SSSD failed relading, please see journalctl -xe"
else
echo "Checking sssd config.. FAIL"
fi fi
therealm=$(realm discover "$DOMAIN" | grep -i configured: | cut -d ':' -f2 | sed -e 's/^[[:space:]]*//') therealm=$(realm discover "$DOMAIN" | grep -i configured: | cut -d ':' -f2 | sed -e 's/^[[:space:]]*//')
if [ "$therealm" = "no" ] if [ "$therealm" = "no" ]
@ -455,7 +453,6 @@ MintOS=$( hostnamectl | grep -i Operating | awk '{print $4}' ) < /dev/null > /de
rasp=$( lsb_release -a | grep -i Distributor | awk '{print $3}' ) < /dev/null > /dev/null 2>&1 rasp=$( lsb_release -a | grep -i Distributor | awk '{print $3}' ) < /dev/null > /dev/null 2>&1
kalilinux=$( lsb_release -a | grep -i Distributor | awk '{print $3}' ) < /dev/null > /dev/null 2>&1 kalilinux=$( lsb_release -a | grep -i Distributor | awk '{print $3}' ) < /dev/null > /dev/null 2>&1
#### OS detection #### #### OS detection ####
if [ "$TheOS" = "Fedora" ] < /dev/null > /dev/null 2>&1 if [ "$TheOS" = "Fedora" ] < /dev/null > /dev/null 2>&1
then then
@ -477,7 +474,6 @@ then
echo "Ubuntu detected" echo "Ubuntu detected"
echo "" echo ""
echo "Checking if it is a Desktop or server" echo "Checking if it is a Desktop or server"
desktop=$( sudo apt list --installed | grep -i desktop | grep -i ubuntu | cut -d '-' -f1 | grep -i desktop | head -1 | awk '{print$1}' ) < /dev/null > /dev/null 2>&1 desktop=$( sudo apt list --installed | grep -i desktop | grep -i ubuntu | cut -d '-' -f1 | grep -i desktop | head -1 | awk '{print$1}' ) < /dev/null > /dev/null 2>&1
if [ "$desktop" = "desktop" ] < /dev/null > /dev/null 2>&1 if [ "$desktop" = "desktop" ] < /dev/null > /dev/null 2>&1
then then
@ -520,27 +516,31 @@ export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) myhost=$( hostname | cut -d '.' -f1 )
clear clear
sudo echo "${RED_TEXT}Installing pakages do no abort!.......${END}" sudo echo "${RED_TEXT}Installing pakages do no abort!.......${END}"
sudo apt-get -qq install realmd adcli sssd -y if ! sudo apt-get -qq install realmd adcli sssd ntp -y && sudo apt-get -qq install -f -y
sudo apt-get -qq install ntp -y then
sudo apt-get -qq install -f -y echo "${RED_TEXT}Failed installing packages, please resolve dpkg and try again ${END}"
exit 1
fi
clear clear
sudo dpkg -l | grep realmd if ! sudo dpkg -l | grep realmd
if [ $? = 0 ]
then then
clear clear
sudo echo "${INTRO_TEXT}Pakages installed${END}" sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}"
else else
clear clear
sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}" sudo echo "${INTRO_TEXT}Pakages installed${END}"
exit
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
echo "Looking for Realms.. please wait" echo "Looking for Realms.. please wait"
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
ping -c 2 "$DOMAIN" >/dev/null if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
if [ $? = 0 ]
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
else
clear
echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}" echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -550,11 +550,6 @@ read -r -p "Do you wish to use it (y/n)?" yn
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
clear clear
@ -572,7 +567,11 @@ echo ""
echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}" echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
read -r ADMIN read -r ADMIN
sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/ if ! sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/
then
echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit
fi
else else
if [ "$var" -eq "16" ] if [ "$var" -eq "16" ]
then then
@ -584,7 +583,11 @@ echo ""
echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}" echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
read -r ADMIN read -r ADMIN
sudo realm join --verbose --user="$ADMIN" "$DOMAIN" if ! sudo realm join --verbose --user="$ADMIN" "$DOMAIN"
then
echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit
fi
else else
if [ "$var" -eq "17" ] || [ "$var" -eq "18" ] if [ "$var" -eq "17" ] || [ "$var" -eq "18" ]
then then
@ -597,7 +600,11 @@ echo ""
echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}" echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
read -r ADMIN read -r ADMIN
sudo realm join --verbose --user="$ADMIN" "$DOMAIN" --install=/ if ! sudo realm join --verbose --user="$ADMIN" "$DOMAIN" --install=/
then
echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit
fi
else else
clear clear
sudo echo "${RED_TEXT}I am having issuers to detect your Ubuntu version${END}" sudo echo "${RED_TEXT}I am having issuers to detect your Ubuntu version${END}"
@ -606,7 +613,7 @@ read -r ADMIN
fi fi
fi fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "${RED_TEXT}AD join failed.please check that computer object is already created and test again${END}" echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit exit
fi fi
fi_auth fi_auth
@ -623,22 +630,25 @@ sudo apt-get -qq install ntp -y
sudo apt-get -qq install -y sssd-tools samba-common krb5-user sudo apt-get -qq install -y sssd-tools samba-common krb5-user
sudo apt-get -qq install -f -y sudo apt-get -qq install -f -y
clear clear
sudo dpkg -l | grep realmd if ! sudo dpkg -l | grep realmd
if [ $? = 0 ]
then then
clear clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
else
clear
sudo echo "${RED_TEXT}Installing pakages failed.. please check connection and dpkg and try again.${END}" sudo echo "${RED_TEXT}Installing pakages failed.. please check connection and dpkg and try again.${END}"
exit exit
else
clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
fi fi
sleep 1 sleep 1
DOMAIN=$( realm discover | grep -i realm-name | awk '{print $2}') DOMAIN=$( realm discover | grep -i realm-name | awk '{print $2}')
ping -c 1 "$DOMAIN" if ! ping -c 1 "$DOMAIN"
if [ $? = 0 ]
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
else
clear
echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}" echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -648,20 +658,15 @@ read -r -p "Do you wish to use it (y/n)?" yn
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
fi fi
sudo echo "${INTRO_TEXT}Realm= $DOMAIN${END}" sudo echo "${INTRO_TEXT}Realm= $DOMAIN${END}"
sudo echo "${NORMAL}${NORMAL}" sudo echo "${NORMAL}${NORMAL}"
echo "${INTRO_TEXT}Please type DomainAdmin user:${END}" echo "${INTRO_TEXT}Please type DomainAdmin user:${END}"
read -r DomainADMIN read -r DomainADMIN
sudo realm join -v -U "$DomainADMIN" "$DOMAIN" --install=/ if ! sudo realm join -v -U "$DomainADMIN" "$DOMAIN" --install=/
if [ $? -ne 0 ]; then then
echo "${RED_TEXT}AD join failed.please check that computer object is already created and test again ${END}" echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit 1 exit
fi fi
echo "${NUMBER}Please type groupname in AD for admins${END}" echo "${NUMBER}Please type groupname in AD for admins${END}"
read -r Mysrvgroup read -r Mysrvgroup
@ -810,22 +815,25 @@ sudo apt-get -qq install realmd adcli sssd -y
sudo apt-get -qq install ntp -y sudo apt-get -qq install ntp -y
sudo apt-get -qq install -f -y sudo apt-get -qq install -f -y
clear clear
sudo dpkg -l | grep realmd if ! sudo dpkg -l | grep realmd
if [ $? = 0 ]
then then
clear clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
else
clear
sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}" sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}"
exit exit
else
clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
ping -c 2 "$DOMAIN" >/dev/null if ! ping -c 2 "$DOMAIN" >/dev/null
if [ $? = 0 ]
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below...${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
else
clear
echo "${NUMBER}I searched for an available domain and found $DOMAIN ${END}" echo "${NUMBER}I searched for an available domain and found $DOMAIN ${END}"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -835,11 +843,6 @@ read -r -p "Do you wish to use it (y/n)?" yn
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below...${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
echo "" echo ""
@ -848,10 +851,10 @@ read -r ADMIN
clear clear
sudo echo "${INTRO_TEXT}Realm= $DOMAIN${END}" sudo echo "${INTRO_TEXT}Realm= $DOMAIN${END}"
sudo echo "${NORMAL}${NORMAL}" sudo echo "${NORMAL}${NORMAL}"
sudo realm join --verbose --user="$ADMIN" "$DOMAIN" --install=/ if ! sudo realm join --verbose --user="$ADMIN" "$DOMAIN" --install=/
if [ $? -ne 0 ]; then then
echo "${RED_TEXT}AD join failed.please check that computer object is already created and test again${END}" echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit exit
fi fi
fi_auth fi_auth
} }
@ -860,12 +863,11 @@ fi_auth
debianclient(){ debianclient(){
export HOSTNAME export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) myhost=$( hostname | cut -d '.' -f1 )
dkpg -l | grep sudo if ! dkpg -l | grep sudo
if [ $? = 0 ]
then then
""
else
apt get install sudo -y apt get install sudo -y
else
echo ""
export whoami export whoami
whoamis=$( whoami ) whoamis=$( whoami )
echo "$whoamis" echo "$whoamis"
@ -884,23 +886,26 @@ sudo apt-get -qq install realmd adcli sssd -y
sudo apt-get -qq install ntp -y sudo apt-get -qq install ntp -y
sudo apt-get -qq install -f sudo apt-get -qq install -f
clear clear
sudo dpkg -l | grep realmd if ! sudo dpkg -l | grep realmd
if [ $? = 0 ]
then then
clear clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
else
clear
sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}" sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}"
exit exit
else
clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
sleep 1 sleep 1
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
ping -c 2 "$DOMAIN" >/dev/null if ! ping -c 2 "$DOMAIN" >/dev/null
if [ $? = 0 ]
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below...${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
else
clear
echo "${NUMBER}I searched for an available domain and found $DOMAIN ${END}" echo "${NUMBER}I searched for an available domain and found $DOMAIN ${END}"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -910,11 +915,6 @@ read -r -p "Do you wish to use it (y/n)?" yn
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below...${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
echo "" echo ""
@ -923,10 +923,10 @@ read -r ADMIN
clear clear
sudo echo "${INTRO_TEXT}Realm= $DOMAIN${END}" sudo echo "${INTRO_TEXT}Realm= $DOMAIN${END}"
sudo echo "${NORMAL}${NORMAL}" sudo echo "${NORMAL}${NORMAL}"
sudo realm join --verbose --user="$ADMIN" "$DOMAIN" --install=/ if ! sudo realm join --verbose --user="$ADMIN" "$DOMAIN" --install=/
if [ $? -ne 0 ]; then then
echo "${RED_TEXT}AD join failed.please check that computer object is already created and test again${END}" echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit exit
fi fi
fi_auth fi_auth
} }
@ -941,10 +941,16 @@ echo "Looking for domains..."
DOMAIN=$(realm discover | grep -i realm-name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm-name | awk '{print $2}')
if [ -n "$DOMAIN" ] if [ -n "$DOMAIN" ]
then then
ping -c 1 "$DOMAIN" if ! ping -c 1 "$DOMAIN"
if [ $? = 0 ]
then then
clear clear
echo "I searched for an available domain and found $DOMAIN but it is not responding to ping, please type your domain manually below... "
echo "Please enter the domain you wish to join:"
read -r DOMAIN
echo "I Please enter AD admin user "
read -r ADMIN
else
clear
echo "I searched for an available domain and found >>> $DOMAIN <<<" echo "I searched for an available domain and found >>> $DOMAIN <<<"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -959,13 +965,6 @@ read -r -p "Do you wish to use it (y/n)?" yn
;; ;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "I searched for an available domain and found $DOMAIN but it is not responding to ping, please type your domain manually below... "
echo "Please enter the domain you wish to join:"
read -r DOMAIN
echo "I Please enter AD admin user "
read -r ADMIN
fi fi
else else
clear clear
@ -977,10 +976,10 @@ read -r ADMIN
fi fi
sudo echo "Realm= $DOMAIN" sudo echo "Realm= $DOMAIN"
sudo echo "" sudo echo ""
sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/ if ! sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/
if [ $? -ne 0 ]; then then
echo "AD join failed.please check that computer object is already created and test again" echo "AD join failed.please check your errors with journalctl -xe"
exit 1 exit
fi fi
fi_auth_yum fi_auth_yum
exit exit
@ -999,10 +998,10 @@ DOMAIN=$( realm discover | grep -i realm-name | awk '{print $2}')
echo "" echo ""
echo "please type Domain admin" echo "please type Domain admin"
read -r ADMIN read -r ADMIN
sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/ if ! sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/
if [ $? -ne 0 ]; then then
echo "AD join failed.please check that computer object is already created and test again" echo "AD join failed.please check your errors with journalctl -xe"
exit 1 exit
fi fi
sudo systemctl start sssd sudo systemctl start sssd
echo "session required pam_mkhomedir.so skel=/etc/skel/ umask=0022" | sudo tee -a /etc/pam.d/common-session echo "session required pam_mkhomedir.so skel=/etc/skel/ umask=0022" | sudo tee -a /etc/pam.d/common-session
@ -1033,10 +1032,16 @@ export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) myhost=$( hostname | cut -d '.' -f1 )
yum -y install realmd sssd oddjob oddjob-mkhomedir adcli samba-common-tools samba-common yum -y install realmd sssd oddjob oddjob-mkhomedir adcli samba-common-tools samba-common
DOMAIN=$(realm discover | grep -i realm-name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm-name | awk '{print $2}')
ping -c 1 "$DOMAIN" if ! ping -c 1 "$DOMAIN"
if [ $? = 0 ]
then then
clear clear
echo "I searched for an available domain and found nothing, please type your domain manually below... "
echo "Please enter the domain you wish to join:"
read -r DOMAIN
echo "I Please enter AD admin user "
read -r ADMIN
else
clear
echo "I searched for an available domain and found >>> $DOMAIN <<<" echo "I searched for an available domain and found >>> $DOMAIN <<<"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -1046,23 +1051,16 @@ read -r -p "Do you wish to use it (y/n)?" yn
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "I searched for an available domain and found nothing, please type your domain manually below... "
echo "Please enter the domain you wish to join:"
read -r DOMAIN
echo "I Please enter AD admin user "
read -r ADMIN
fi fi
clear clear
sudo echo "Please enter AD admin user:" sudo echo "Please enter AD admin user:"
read -r ADMIN read -r ADMIN
sudo echo "Realm= $DOMAIN" sudo echo "Realm= $DOMAIN"
sudo echo "" sudo echo ""
sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/ if ! sudo realm join -v -U "$ADMIN" "$DOMAIN" --install=/
if [ $? -ne 0 ]; then then
echo "AD join failed.please check that computer object is already created and test again" echo "AD join failed.please check your errors with journalctl -xe"
exit 1 exit
fi fi
fi_auth_yum fi_auth_yum
exit exit
@ -1077,10 +1075,14 @@ sudo apt-get -qq install -f -y
echo "hostname is $myhost" echo "hostname is $myhost"
echo "Looking for Realms.. please wait" echo "Looking for Realms.. please wait"
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
ping -c 2 "$DOMAIN" >/dev/null if ! ping -c 2 "$DOMAIN" >/dev/null
if [ "$?" = "0" ]
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
else
clear
echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}" echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -1090,11 +1092,6 @@ read -r -p "Do you wish to use it (y/n)?" yn
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
fi fi
clear clear
echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}" echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}"
@ -1102,10 +1099,10 @@ echo "${INTRO_TEXT}Please type Admin user:${END}"
read -r ADMIN read -r ADMIN
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
clear clear
sudo realm join --verbose --user="$ADMIN" "$DOMAIN" if ! sudo realm join --verbose --user="$ADMIN" "$DOMAIN"
if [ $? -ne 0 ]; then then
echo "${RED_TEXT}AD join failed.please check that computer object is already created and test again ${END}" echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit exit
fi fi
allowguest=$( sudo grep manual /usr/share/lightdm/lightdm.conf.d/50-disable-guest.conf | grep true | cut -d '=' -f2 | head -1 ) allowguest=$( sudo grep manual /usr/share/lightdm/lightdm.conf.d/50-disable-guest.conf | grep true | cut -d '=' -f2 | head -1 )
if [ "$allowguest" = "true" ] if [ "$allowguest" = "true" ]
@ -1147,8 +1144,7 @@ exit
failcheck(){ failcheck(){
clear clear
export HOSTNAME export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) if ! hostname | cut -d '.' -f1
if [ $? = 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
@ -1212,8 +1208,7 @@ exit
failcheck_yum(){ failcheck_yum(){
clear clear
export HOSTNAME export HOSTNAME
myhost=$( hostname | cut -d '.' -f1 ) if ! hostname | cut -d '.' -f1
if [ $? = 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
@ -1621,7 +1616,11 @@ while test $# -gt 0; do
;; ;;
-j) -j)
if test $# -gt 0; then if test $# -gt 0; then
sudo realm join -v -U "$2" "$3" --install=/ if ! sudo realm join -v -U "$2" "$3" --install=/
then
echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit
fi
exit exit
else else
echo "" echo ""
@ -1680,23 +1679,26 @@ sudo apt-get -qq install realmd adcli sssd -y
sudo apt-get -qq install ntp -y sudo apt-get -qq install ntp -y
sudo apt-get install -f -y sudo apt-get install -f -y
clear clear
sudo dpkg -l | grep realmd if ! sudo dpkg -l | grep realmd
if [ $? = 0 ]
then then
clear clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
else
clear
sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}" sudo echo "${RED_TEXT}Installing pakages failed.. please check connection ,dpkg and apt-get update then try again.${END}"
exit exit
else
clear
sudo echo "${INTRO_TEXT}Pakages installed${END}"
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
echo "Looking for Realms.. please wait" echo "Looking for Realms.. please wait"
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
ping -c 2 "$DOMAIN" >/dev/null if ! ping -c 2 "$DOMAIN" >/dev/null
if [ $? = 0 ]
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below...${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
else
clear
echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}" echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}"
read -r -p "Do you wish to use it (y/n)?" yn read -r -p "Do you wish to use it (y/n)?" yn
case $yn in case $yn in
@ -1706,11 +1708,6 @@ read -r -p "Do you wish to use it (y/n)?" yn
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
else
clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below...${END}"
echo "Please enter the domain you wish to join:"
read -r DOMAIN
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
clear clear
@ -1728,7 +1725,11 @@ echo ""
echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}" echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
read -r ADMIN read -r ADMIN
realm join -v --user="$ADMIN" --computer-ou="$2" "$DOMAIN" --install=/ if ! realm join -v --user="$ADMIN" --computer-ou="$2" "$DOMAIN" --install=/
then
echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit
fi
else else
if [ "$var" -eq "16" ] if [ "$var" -eq "16" ]
then then
@ -1740,7 +1741,11 @@ echo ""
echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}" echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
read -r ADMIN read -r ADMIN
realm join -v --user="$ADMIN" --computer-ou="$2" "$DOMAIN" if ! realm join -v --user="$ADMIN" --computer-ou="$2" "$DOMAIN"
then
echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit
fi
else else
if [ "$var" -eq "17" ] || [ "$var" -eq "18" ] if [ "$var" -eq "17" ] || [ "$var" -eq "18" ]
then then
@ -1753,7 +1758,11 @@ echo ""
echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}" echo "${INTRO_TEXT}Please log in with domain admin to $DOMAIN to connect${END}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
read -r ADMIN read -r ADMIN
realm join -v --user="$ADMIN" --computer-ou="$2" "$DOMAIN" --install=/ if ! realm join -v --user="$ADMIN" --computer-ou="$2" "$DOMAIN" --install=/
then
echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe${END}"
exit
fi
else else
clear clear
sudo echo "${RED_TEXT}I am having issuers to detect your Ubuntu version${END}" sudo echo "${RED_TEXT}I am having issuers to detect your Ubuntu version${END}"
@ -1762,7 +1771,7 @@ read -r ADMIN
fi fi
fi fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "${RED_TEXT}AD join failed.please check that computer object is already created and test again ${END}" echo "${RED_TEXT}AD join failed.please check your errors with journalctl -xe ${END}"
exit exit
fi fi
fi_auth fi_auth