#!/bin/bash
# This is a script that installs the packages and makes the configurations when joining a Linux machine on the domain.
# You still need to run "sudo domainjoin-cli join RD.UNR.EDU $your_netid@UNR.EDU" in order to get it joined to the domain.
# Make sure that you get the machine moved to the right OU in the Active Directory in order to prevent getting kicked off the domain in a week.

# Getting the packages we need to join the machine to the @UNR.EDU domain...
wget -O - http://repo.pbis.beyondtrust.com/yum/RPM-GPG-KEY-pbis|sudo apt-key add -
sudo wget -O /etc/apt/sources.list.d/pbiso.list http://repo.pbis.beyondtrust.com/apt/pbiso.list
sudo apt update -y
sudo apt install pbis-open openssh-server -y

# Configuring pbis so that the @UNR.EDU domain is the default login domain...
sudo /opt/pbis/bin/config RequireMembershipOf "UNR\\GG-Engr-ECC-Students" "UNR\\GG-Engr-ECC-Admin" "UNR\\GG-Engr-ECC-Faculty"
sudo /opt/pbis/bin/config HomeDirTemplate "/home/%U"
sudo /opt/pbis/bin/config HomeDirUmask "077"
sudo /opt/pbis/bin/config UserDomainPrefix "UNR"
sudo /opt/pbis/bin/config AssumeDefaultDomain true
sudo /opt/pbis/bin/config LoginShellTemplate /bin/bash
