blob: fc48da18e83f45daad4c0a7295b9ca23a6ea0b4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/bash
# catch errors
set -e
set -E
trap 'es=$?;
echo ERROR: failed in function \"${FUNCNAME}\" at line ${LINENO} of ${BASH_SOURCE[0]} with code $es;
exit $es' ERR
# Make this explicit so we only get RHEL updates to make things nice
# and clear. This duplicates what happens in basic-postinstall.sh but
# we may have just rewound the cluster, so we might be running this on
# the node install of from kickstart.
echo "Updating from YUM repositories"
yum -y update
# Install samba4 packages
echo "Installing Samba4 packages"
yum -y install samba4-dc samba4-python
# Remove samba3 configuration file
rm -f /etc/samba/smb.conf
# Create AD instance
echo "Provisioning Samba4 AD domain: @@DOMAIN@@"
short_dom=$(echo @@DOMAIN@@ | awk -F. '{print toupper($1)}')
hostip="@@IPBASE@@.@@IPNET0@@.@@IPNUM@@"
provision --realm="@@DOMAIN@@" \
--domain=$short_dom \
--host-ip="$hostip" \
--adminpass="@@AD_ADMIN_PASS@@" \
--server-role="domain controller" \
--function-level="@@AD_FUNCTION_LEVEL@@" \
--dns-backend="SAMBA_INTERNAL"
# Add samba configuration parameters
sed -i -e '/server services/a\
allow dns updates = True\
nsupdate command = nsupdate\
dns forwarder = @@NAMESERVER@@\
dns recursive queries = Yes' /etc/samba/smb.conf
# Add users/groups
echo "Adding users and groups"
samba-tool user add test test01
samba-tool user setexpiry --noexpiry Administrator
samba-tool user setexpiry --noexpiry test
# Samba start-up
cat >> /etc/rc.d/rc.local <<EOF
# Start SAMBA AD server
/usr/sbin/samba
EOF
mkdir /var/run/samba
# Update DNS configuration
echo "Updating /etc/resolv.conf"
sed -i -e 's@^\(nameserver.*\)@#\1@' /etc/resolv.conf
echo "nameserver $hostip" >> /etc/resolv.conf
# Start SAMBA
/usr/sbin/samba
|