5 # Assume that an AD server cluster is always a single node :-)
7 # Remove samba3 configuration file
8 rm -f /etc/samba/smb.conf
11 echo "Provisioning Samba4 AD domain: @@DOMAIN@@"
12 hostip="@@NETWORK_PRIVATE_PREFIX@@.@@IPNUM@@"
13 samba-tool domain provision \
14 --realm="@@DOMAIN@@" \
15 --domain="@@WORKGROUP@@" \
17 --host-name="@@AD_NETBIOS_NAME@@" \
18 --server-role="domain controller" \
19 --function-level="@@AD_FUNCTION_LEVEL@@" \
20 --dns-backend="SAMBA_INTERNAL"
22 # Add samba configuration parameters
23 sed -i -e '/server services/a\
24 allow dns updates = True\
25 nsupdate command = nsupdate\
26 dns forwarder = @@NAMESERVER@@\
27 dns recursive queries = Yes' /etc/samba/smb.conf
30 echo "Adding users and groups"
31 samba-tool domain passwordsettings set --min-pwd-length=3
32 samba-tool domain passwordsettings set --complexity=off
33 samba-tool user add test test01
34 samba-tool user setexpiry --noexpiry Administrator
35 samba-tool user setexpiry --noexpiry test
36 samba-tool user setpassword administrator --newpassword="@@AD_ADMIN_PASS@@"
39 cat >> /etc/rc.d/rc.local <<EOF
41 # Start SAMBA AD server
46 # Add NetBIOS name to hosts
47 echo "$hostip @@AD_NETBIOS_NAME@@.@@DOMAIN@@ @@AD_NETBIOS_NAME@@" >>/etc/hosts
49 # Update DNS configuration
50 echo "Updating /etc/resolv.conf"
51 sed -i -e 's@^\(nameserver.*\)@#\1@' /etc/resolv.conf
52 echo "nameserver $hostip" >> /etc/resolv.conf