Update ADconnection.sh

This commit is contained in:
PierreGode 2020-04-03 11:45:55 +02:00 committed by GitHub
parent 97a2433108
commit ae2448ea41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -824,32 +824,32 @@ sudo echo "${INTRO_TEXT}packages installed${END}"
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
echo "Looking for Realms.. please wait" echo "Looking for Realms.. please wait"
REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' ) REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' )
if [ "$REALM" = "null" ] if [ "$REALM" = "null" ]
then then
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1 if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}" 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:" echo "Please enter the domain you wish to join:"
read -r DOMAIN read -r DOMAIN
else else
clear 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
[Yy]* ) echo "";; [Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:" [Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
fi fi
else else
echo "Using Domain: $REALM" echo "Using Domain: $REALM"
DOMAIN=$(echo "$REALM") DOMAIN=$(echo "$REALM")
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
clear clear
var=$(lsb_release -a | grep -i release | awk '{print $2}' | cut -d '.' -f1) var=$(lsb_release -a | grep -i release | awk '{print $2}' | cut -d '.' -f1)
@ -954,32 +954,32 @@ clear
sudo echo "${INTRO_TEXT}packages installed${END}" sudo echo "${INTRO_TEXT}packages installed${END}"
fi fi
sleep 1 sleep 1
REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' ) REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' )
if [ "$REALM" = "null" ] if [ "$REALM" = "null" ]
then then
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1 if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}" 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:" echo "Please enter the domain you wish to join:"
read -r DOMAIN read -r DOMAIN
else else
clear 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
[Yy]* ) echo "";; [Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:" [Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
fi fi
else else
echo "Using Domain: $REALM" echo "Using Domain: $REALM"
DOMAIN=$(echo "$REALM") DOMAIN=$(echo "$REALM")
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}"
@ -1150,32 +1150,32 @@ clear
sudo echo "${INTRO_TEXT}packages installed${END}" sudo echo "${INTRO_TEXT}packages installed${END}"
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' ) REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' )
if [ "$REALM" = "null" ] if [ "$REALM" = "null" ]
then then
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1 if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}" 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:" echo "Please enter the domain you wish to join:"
read -r DOMAIN read -r DOMAIN
else else
clear 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
[Yy]* ) echo "";; [Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:" [Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
fi fi
else else
echo "Using Domain: $REALM" echo "Using Domain: $REALM"
DOMAIN=$(echo "$REALM") DOMAIN=$(echo "$REALM")
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
echo "" echo ""
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
@ -1229,32 +1229,32 @@ sudo echo "${INTRO_TEXT}packages installed${END}"
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
sleep 1 sleep 1
REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' ) REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' )
if [ "$REALM" = "null" ] if [ "$REALM" = "null" ]
then then
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1 if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}" 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:" echo "Please enter the domain you wish to join:"
read -r DOMAIN read -r DOMAIN
else else
clear 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
[Yy]* ) echo "";; [Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:" [Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
fi fi
else else
echo "Using Domain: $REALM" echo "Using Domain: $REALM"
DOMAIN=$(echo "$REALM") DOMAIN=$(echo "$REALM")
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
echo "" echo ""
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
@ -1414,32 +1414,32 @@ sudo apt-get -qq install -y realmd sssd sssd-tools samba-common krb5-user
sudo apt-get -qq install -f -y 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"
REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' ) REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' )
if [ "$REALM" = "null" ] if [ "$REALM" = "null" ]
then then
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1 if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
then then
clear clear
echo "I searched for an available domain and found nothing, please type your domain manually below..." 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:" echo "Please enter the domain you wish to join:"
read -r DOMAIN read -r DOMAIN
else else
clear 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
[Yy]* ) echo "";; [Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:" [Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
fi fi
else else
echo "Using Domain: $REALM" echo "Using Domain: $REALM"
DOMAIN=$(echo "$REALM") DOMAIN=$(echo "$REALM")
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}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
@ -1470,32 +1470,32 @@ sudo apt-get -qq install -y realmd sssd sssd-tools samba-common krb5-user
sudo apt-get -qq install -f -y 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"
REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' ) REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' )
if [ "$REALM" = "null" ] if [ "$REALM" = "null" ]
then then
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1 if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
then then
clear clear
echo "I searched for an available domain and found nothing, please type your domain manually below..." 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:" echo "Please enter the domain you wish to join:"
read -r DOMAIN read -r DOMAIN
else else
clear 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
[Yy]* ) echo "";; [Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:" [Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
fi fi
else else
echo "Using Domain: $REALM" echo "Using Domain: $REALM"
DOMAIN=$(echo "$REALM") DOMAIN=$(echo "$REALM")
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}"
echo "${INTRO_TEXT}Please type Admin user:${END}" echo "${INTRO_TEXT}Please type Admin user:${END}"
@ -2172,32 +2172,32 @@ sudo echo "${INTRO_TEXT}packages installed${END}"
fi fi
echo "hostname is $myhost" echo "hostname is $myhost"
echo "Looking for Realms.. please wait" echo "Looking for Realms.. please wait"
REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' ) REALM=$( sudo grep DOMAIN readfile | awk '{print $3}' )
if [ "$REALM" = "null" ] if [ "$REALM" = "null" ]
then then
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1 if ! ping -c 2 "$DOMAIN" < /dev/null > /dev/null 2>&1
then then
clear clear
echo "${NUMBER}I searched for an available domain and found nothing, please type your domain manually below... ${END}" 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:" echo "Please enter the domain you wish to join:"
read -r DOMAIN read -r DOMAIN
else else
clear 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
[Yy]* ) echo "";; [Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:" [Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;; read -r DOMAIN;;
* ) echo 'Please answer yes or no.';; * ) echo 'Please answer yes or no.';;
esac esac
fi fi
else else
echo "Using Domain: $REALM" echo "Using Domain: $REALM"
DOMAIN=$(echo "$REALM") DOMAIN=$(echo "$REALM")
fi fi
NetBios=$(echo "$DOMAIN" | cut -d '.' -f1) NetBios=$(echo "$DOMAIN" | cut -d '.' -f1)
clear clear
var=$(lsb_release -a | grep -i release | awk '{print $2}' | cut -d '.' -f1) var=$(lsb_release -a | grep -i release | awk '{print $2}' | cut -d '.' -f1)