5 # Remove samba3 configuration file
6 rm -f /etc/samba/smb.conf
9 echo "Provisioning Samba4 AD domain: @@DOMAIN@@"
10 hostip="@@NETWORK_PRIVATE_PREFIX@@.@@IPNUM@@"
11 samba-tool domain provision \
12 --realm="@@DOMAIN@@" \
13 --domain="@@WORKGROUP@@" \
15 --host-name="@@AD_NETBIOS_NAME@@" \
16 --server-role="domain controller" \
17 --function-level="@@AD_FUNCTION_LEVEL@@" \
18 --dns-backend="SAMBA_INTERNAL"
20 # Add samba configuration parameters
21 sed -i -e '/server services/a\
22 allow dns updates = True\
23 nsupdate command = nsupdate\
24 dns forwarder = @@AD_DNS_FORWARDER@@\
25 dns recursive queries = Yes' /etc/samba/smb.conf
28 echo "Adding users and groups"
29 samba-tool domain passwordsettings set --min-pwd-length=3
30 samba-tool domain passwordsettings set --complexity=off
31 samba-tool user add test test01
32 samba-tool user setexpiry --noexpiry Administrator
33 samba-tool user setexpiry --noexpiry test
34 samba-tool user setpassword administrator --newpassword="@@AD_ADMIN_PASS@@"
37 cat >> /etc/rc.d/rc.local <<EOF
39 # Start SAMBA AD server
44 # Add NetBIOS name to hosts
45 echo "$hostip @@AD_NETBIOS_NAME@@.@@DOMAIN@@ @@AD_NETBIOS_NAME@@" >>/etc/hosts
47 # Update DNS configuration
48 echo "Updating /etc/resolv.conf"
49 sed -i -e 's@^\(nameserver.*\)@#\1@' /etc/resolv.conf
50 echo "nameserver $hostip" >> /etc/resolv.conf