diff --git a/domainjoin.sh b/domainjoin.sh index 925ff53..389d364 100644 --- a/domainjoin.sh +++ b/domainjoin.sh @@ -11,15 +11,19 @@ read -e -p "Enter netBIOS name: " -i "GAUNT" netbiosname read -e -p "Enter Domain Admin username: " -i "jgaunt" username read -e -s -p "Enter Password: " password -domainjoin-cli join ${domain} ${username} ${password} +# join the computer to the domain +echo ${password} | realm join -U ${username} ${domain} -/opt/pbis/bin/config UserDomainPrefix ${netbiosname} -/opt/pbis/bin/config AssumeDefaultDomain true -/opt/pbis/bin/config LoginShellTemplate /bin/bash -/opt/pbis/bin/config HomeDirTemplate %H/%U +# set the sssd options +# don't require the full domain for the usernames +sed --in-place 's/^use_fully_qualified_names = True/use_fully_qualified_names = False/' /etc/sssd/sssd.conf +# set home directory to /home/ +sed --in-place 's/^fallback_homedir = \/home\/%u@%d/fallback_homedir = \/home\/%u/' /etc/sssd/sssd.conf -echo "## ${domain} Admins ##" >> /etc/sudoers.d/${netbiosname}AD -echo "# Allow members of ${netbiosname}\Domain Admins group sudo access" >> /etc/sudoers.d/${netbiosname}AD -echo "%Domain^Admins ALL=(ALL:ALL) ALL" >> /etc/sudoers.d/${netbiosname}AD +# reboot sssd +systemctl restart sssd -echo 'Reboot? (y/n)' && read x && [[ "$x" == "y" ]] && reboot; +# set the sudoers.d file for the domain admins +echo "## ${netbiosname} Admins ##" > /etc/sudoers.d/${netbiosname} +echo "# Allow members of ${netbiosname}\Domain Admins group sudo access" >> /etc/sudoers.d/${netbiosname} +echo "%Domain\ Admins ALL=(ALL:ALL) ALL" >> /etc/sudoers.d/${netbiosname}