Added flag options see: sudo sh ADconnection.sh --help

This commit is contained in:
root 2018-05-21 14:03:50 +02:00
parent ec6c1445f1
commit 3108810afd

View File

@ -919,10 +919,12 @@ exit
readmes(){ readmes(){
clear clear
echo "Usage: sh ADconnection.sh [--help] [-d (ubuntu debug mode)]" echo "Usage: sh ADconnection.sh [--help] "
echo " [-d (ubuntu debug mode)]"
echo " [-j admin domain (Simple direct join)" echo " [-j admin domain (Simple direct join)"
echo " [-l (script output to log file)]" echo " [-l (script output to log file)]"
echo " [-s (Discover domain)]" echo " [-s (Discover domain)]"
echo " [-o (assign OU for computer object (-o OU=Clients,OU=Computers))"
echo "" echo ""
echo"" echo""
echo "${INTRO_TEXT} Active directory connection tool ${INTRO_TEXT}" echo "${INTRO_TEXT} Active directory connection tool ${INTRO_TEXT}"
@ -1046,10 +1048,132 @@ else
sudo realm discover sudo realm discover
exit exit
else else
echo "" if [ "$1" = "-ou" ]
then
desktop=$( sudo apt list --installed | grep -i desktop | grep -i ubuntu | cut -d '-' -f1 | grep -i desktop )
rasp=$( lsb_release -a | grep -i Distributor | awk '{print $3}' )
kalilinux=$( lsb_release -a | grep -i Distributor | awk '{print $3}' )
if [ "$desktop" = "desktop" ]
then
if [ "$rasp" = "Raspbian" ]
then
echo "${INTRO_TEXT}"Detecting Raspberry Pi"${END}"
raspberry
else
if [ "$kalilinux" = "Kali" ]
then
echo "${INTRO_TEXT}"Detecting Kali linux"${END}"
kalijoin
else
echo ""
fi
fi
else
echo "this seems to be a server, swithching to server mode"
ubuntuserver14
fi
export HOSTNAME
myhost=$( hostname )
clear
sudo echo "${RED_TEXT}"Installing pakages do no abort!......."${INTRO_TEXT}"
sudo apt-get -qq install realmd adcli sssd -y
sudo apt-get -qq install ntp -y
sudo apt-get install -f -y
clear
sudo dpkg -l | grep realmd
if [ $? = 0 ]
then
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."${INTRO_TEXT}"
exit
fi
echo "hostname is $myhost"
echo "Looking for Realms.. please wait"
DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}')
ping -c 2 $DOMAIN >/dev/null
if [ $? = 0 ]
then
clear
echo "${NUMBER}I searched for an available domain and found ${MENU}>>> $DOMAIN <<<${END}${END}"
read -p "Do you wish to use it (y/n)?" yn
case $yn in
[Yy]* ) echo "";;
[Nn]* ) echo "Please enter the domain you wish to join:"
read -r DOMAIN;;
* ) echo 'Please answer yes or no.';;
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
NetBios=$(echo $DOMAIN | cut -d '.' -f1)
clear
var=$(lsb_release -a | grep -i release | awk '{print $2}' | cut -d '.' -f1)
if [ "$var" -eq "14" ]
then
echo "Installing additional dependencies"
sudo apt-get -qq install -y realmd sssd sssd-tools samba-common krb5-user
sudo apt-get install -f -y
clear
echo "${INTRO_TEXT}"Detecting Ubuntu $var"${END}"
sudo echo "${INTRO_TEXT}"Realm=$DOMAIN"${INTRO_TEXT}"
echo "${INTRO_TEXT}"Joining Ubuntu $var"${END}"
echo ""
echo "${INTRO_TEXT}"Please log in with domain admin to $DOMAIN to connect"${END}"
echo "${INTRO_TEXT}"Please type Admin user:"${END}"
read ADMIN
realm join -v --user="$ADMIN" --computer-ou="$2" $DOMAIN --install=/
else
if [ "$var" -eq "16" ]
then
echo "${INTRO_TEXT}"Detecting Ubuntu $var"${END}"
clear
sudo echo "${INTRO_TEXT}"Realm=$DOMAIN"${INTRO_TEXT}"
echo "${INTRO_TEXT}"Joining Ubuntu $var"${END}"
echo ""
echo "${INTRO_TEXT}"Please log in with domain admin to $DOMAIN to connect"${END}"
echo "${INTRO_TEXT}"Please type Admin user:"${END}"
read ADMIN
realm join -v --user="$ADMIN" --computer-ou="$2" $DOMAIN
else
if [ "$var" -eq "17" ] || [ "$var" -eq "18" ]
then
echo "${INTRO_TEXT}"Detecting Ubuntu $var"${END}"
sleep 1
clear
sudo echo "${INTRO_TEXT}"Realm=$DOMAIN"${INTRO_TEXT}"
echo "${INTRO_TEXT}"Joining Ubuntu $var"${END}"
echo ""
echo "${INTRO_TEXT}"Please log in with domain admin to $DOMAIN to connect"${END}"
echo "${INTRO_TEXT}"Please type Admin user:"${END}"
read ADMIN
realm join -v --user="$ADMIN" --computer-ou="$2" $DOMAIN --install=/
else
clear
sudo echo "${RED_TEXT}"I am having issuers to detect your Ubuntu version"${INTRO_TEXT}"
exit
fi
fi
fi
if [ $? -ne 0 ]; then
echo "${RED_TEXT}"AD join failed.please check that computer object is already created and test again "${END}"
exit
fi
fi_auth
else
echo ""
fi
fi fi
fi fi
fi fi
fi fi
fi fi
MENU_FN MENU_FN