Update ad-join-script.sh
Admm dynDNS
This commit is contained in:
parent
24c91e32e0
commit
de0c26703c
@ -1,5 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Prompt the user for the hostname
|
# Prompt the user for the hostname
|
||||||
read -p "Enter the hostname for the server: " hostname
|
read -p "Enter the hostname for the server: " hostname
|
||||||
echo
|
echo
|
||||||
@ -26,37 +25,42 @@ echo "Changing the hostname to: $hostname.$domain_name"
|
|||||||
|
|
||||||
# Change the hostname
|
# Change the hostname
|
||||||
hostnamectl set-hostname $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
|
# Change the DNS server settings in /etc/resolv.conf
|
||||||
echo "Changing DNS server to: $dns_server"
|
echo "Changing DNS server to: $dns_server"
|
||||||
echo "nameserver $dns_server" | sudo tee /etc/resolv.conf
|
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..."
|
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
|
# Discover the domain and join, registering DNS
|
||||||
echo "Discovering the domain..."
|
|
||||||
realm discover $domain_name
|
|
||||||
|
|
||||||
# Join the domain using the provided information
|
|
||||||
echo "Joining the domain and registering DNS..."
|
echo "Joining the domain and registering DNS..."
|
||||||
echo $admin_password | realm join --user=$admin_user $domain_name
|
echo $admin_password | realm join --user=$admin_user $domain_name
|
||||||
|
|
||||||
|
# Modify the sssd.conf configuration to enable dynamic DNS updates
|
||||||
# Modify the sssd.conf configuration
|
echo "Configuring dynamic DNS updates..."
|
||||||
echo "Modifying sssd.conf..."
|
cat <<EOF | sudo tee -a /etc/sssd/sssd.conf
|
||||||
sed -i 's/use_fully_qualified_names = True/use_fully_qualified_names = False/g' /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
|
# Restart the SSSD service
|
||||||
echo "Restarting the SSSD service..."
|
echo "Restarting the SSSD service..."
|
||||||
systemctl restart sssd
|
systemctl restart sssd
|
||||||
|
|
||||||
# Add the user to the sudoers file
|
# Add the user and AD group to the sudoers file
|
||||||
echo "Adding the user 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 "$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
|
echo "%$ad_group ALL=(ALL:ALL) ALL" | sudo tee -a /etc/sudoers
|
||||||
|
|
||||||
# Verify successful domain join by looking up the user
|
# Verify successful domain join by looking up the user
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user