Move wait_until_healthy() into setup_cluster.sh
[tridge/autocluster.git] / base / all / root / scripts / setup_cluster_ad_server.sh
1 #!/bin/sh
2
3 set -e
4
5 # Assume that an AD server cluster is always a single node :-)
6
7 # Remove samba3 configuration file
8 rm -f /etc/samba/smb.conf
9
10 # Create AD instance
11 echo "Provisioning Samba4 AD domain: @@DOMAIN@@"
12 hostip="@@NETWORK_PRIVATE_PREFIX@@.@@IPNUM@@"
13 samba-tool domain provision \
14     --realm="@@DOMAIN@@" \
15         --domain="@@WORKGROUP@@" \
16         --host-ip="$hostip" \
17         --host-name="@@AD_NETBIOS_NAME@@" \
18         --server-role="domain controller" \
19         --function-level="@@AD_FUNCTION_LEVEL@@" \
20         --dns-backend="SAMBA_INTERNAL"
21
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
28
29 # Add users/groups
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@@"
37
38 # Samba start-up
39 cat >> /etc/rc.d/rc.local <<EOF
40
41 # Start SAMBA AD server
42 /usr/sbin/samba
43 EOF
44 mkdir /var/run/samba
45
46 # Add NetBIOS name to hosts
47 echo "$hostip @@AD_NETBIOS_NAME@@.@@DOMAIN@@ @@AD_NETBIOS_NAME@@" >>/etc/hosts
48
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
53
54 # Start SAMBA
55 /usr/sbin/samba