Update ad-join-script.sh
Admm dynDNS
This commit is contained in:
parent
24c91e32e0
commit
de0c26703c
@ -1,5 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Prompt the user for the hostname
|
||||
read -p "Enter the hostname for the server: " hostname
|
||||
echo
|
||||
@ -26,37 +25,42 @@ echo "Changing the hostname to: $hostname.$domain_name"
|
||||
|
||||
# Change the hostname
|
||||
hostnamectl set-hostname $hostname
|
||||
echo "$hostname.$domain_name" | sudo tee -a /etc/hostname
|
||||
echo "$hostname.$domain_name" | sudo tee /etc/hostname
|
||||
|
||||
# Change the DNS server settings in /etc/resolv.conf
|
||||
echo "Changing DNS server to: $dns_server"
|
||||
echo "nameserver $dns_server" | sudo tee /etc/resolv.conf
|
||||
|
||||
# Install the necessary packages
|
||||
# Install the necessary packages with a loading bar
|
||||
echo "Installing required packages..."
|
||||
apt -y install realmd sssd sssd-tools libnss-sss libpam-sss adcli samba-common-bin oddjob oddjob-mkhomedir packagekit
|
||||
apt -y install realmd sssd sssd-tools libnss-sss libpam-sss adcli samba-common-bin oddjob oddjob-mkhomedir packagekit & loading_bar
|
||||
|
||||
# Discover the domain
|
||||
echo "Discovering the domain..."
|
||||
realm discover $domain_name
|
||||
|
||||
# Join the domain using the provided information
|
||||
# Discover the domain and join, registering DNS
|
||||
echo "Joining the domain and registering DNS..."
|
||||
echo $admin_password | realm join --user=$admin_user $domain_name
|
||||
|
||||
|
||||
# Modify the sssd.conf configuration
|
||||
echo "Modifying sssd.conf..."
|
||||
sed -i 's/use_fully_qualified_names = True/use_fully_qualified_names = False/g' /etc/sssd/sssd.conf
|
||||
# Modify the sssd.conf configuration to enable dynamic DNS updates
|
||||
echo "Configuring dynamic DNS updates..."
|
||||
cat <<EOF | sudo tee -a /etc/sssd/sssd.conf
|
||||
[domain/$domain_name]
|
||||
id_provider = ad
|
||||
auth_provider = ad
|
||||
chpass_provider = ad
|
||||
access_provider = ad
|
||||
ldap_schema = ad
|
||||
dyndns_update = true
|
||||
dyndns_refresh_interval = 43200
|
||||
dyndns_update_ptr = true
|
||||
dyndns_ttl = 3600
|
||||
EOF
|
||||
|
||||
# Restart the SSSD service
|
||||
echo "Restarting the SSSD service..."
|
||||
systemctl restart sssd
|
||||
|
||||
# Add the user to the sudoers file
|
||||
echo "Adding the user to the sudoers file..."
|
||||
# Add the user and AD group to the sudoers file
|
||||
echo "Adding the user and AD group to the sudoers file..."
|
||||
echo "$admin_user ALL=(ALL:ALL) ALL" | sudo tee -a /etc/sudoers
|
||||
echo "Adding the group to the sudoers file..."
|
||||
echo "%$ad_group ALL=(ALL:ALL) ALL" | sudo tee -a /etc/sudoers
|
||||
|
||||
# Verify successful domain join by looking up the user
|
||||
|
||||
Loading…
Reference in New Issue
Block a user