Make cluster_setup.sh use generated configuration file
[autocluster.git] / base / all / root / scripts / tasks / setup_node_ad.sh
1 #!/bin/sh
2
3 #config: AD_ADMIN_PASS AD_DNS_FORWARDER AD_FUNCTION_LEVEL AD_NETBIOS_NAME
4 #config: DOMAIN IPNUM NETWORK_PRIVATE_PREFIX WORKGROUP
5
6 set -e
7
8 # Remove samba3 configuration file
9 rm -f /etc/samba/smb.conf
10
11 # Create AD instance
12 echo "Provisioning Samba4 AD domain: ${DOMAIN}"
13 hostip="${NETWORK_PRIVATE_PREFIX}.${IPNUM}"
14 samba-tool domain provision \
15     --realm="$DOMAIN" \
16         --domain="$WORKGROUP" \
17         --host-ip="$hostip" \
18         --host-name="$AD_NETBIOS_NAME" \
19         --server-role="domain controller" \
20         --function-level="$AD_FUNCTION_LEVEL" \
21         --dns-backend="SAMBA_INTERNAL"
22
23 # Add samba configuration parameters
24 sed -i -e '/server services/a\
25         allow dns updates = True\
26         nsupdate command = nsupdate\
27         dns forwarder = ${AD_DNS_FORWARDER}\
28         dns recursive queries = Yes' /etc/samba/smb.conf
29
30 # Add users/groups
31 echo "Adding users and groups"
32 samba-tool domain passwordsettings set --min-pwd-length=3
33 samba-tool domain passwordsettings set --complexity=off
34 samba-tool user add test test01
35 samba-tool user setexpiry --noexpiry Administrator
36 samba-tool user setexpiry --noexpiry test
37 samba-tool user setpassword administrator --newpassword="$AD_ADMIN_PASS"
38
39 # Samba start-up
40 cat >> /etc/rc.d/rc.local <<EOF
41
42 # Start SAMBA AD server
43 /usr/sbin/samba
44 EOF
45 mkdir /var/run/samba
46
47 # Add NetBIOS name to hosts
48 echo "${hostip} ${AD_NETBIOS_NAME}.${DOMAIN} ${AD_NETBIOS_NAME}" >>/etc/hosts
49
50 # Update DNS configuration
51 echo "Updating /etc/resolv.conf"
52 sed -i -e 's@^\(nameserver.*\)@#\1@' /etc/resolv.conf
53 echo "nameserver $hostip" >> /etc/resolv.conf
54
55 # Start SAMBA
56 /usr/sbin/samba