2015-04-14 15:45:16 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-02-07 20:44:19 +01:00
|
|
|
apt update
|
|
|
|
|
2016-06-17 07:58:53 +02:00
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install ldap-utils slapd -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -f -q -y
|
2019-02-07 22:44:51 +01:00
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install samba-dsdb-modules samba-vfs-modules samba -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -f -q -y
|
2016-07-28 06:44:02 +02:00
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install winbind -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -f -q -y
|
2024-03-13 00:18:47 +01:00
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install build-essential python3-dev libsasl2-dev slapd ldap-utils tox lcov valgrind libtidy-dev libldap-dev python3-cherrypy3 python3-ldap python3-mako -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -f -q -y
|
2015-04-14 16:25:48 +02:00
|
|
|
|
2019-02-07 22:34:47 +01:00
|
|
|
[ -e '/etc/default/slapd' ] && rm -rf /etc/default/slapd
|
2019-02-06 23:55:03 +01:00
|
|
|
cp -r `dirname $0`/etc/default/slapd /etc/default/slapd
|
2019-02-07 22:34:47 +01:00
|
|
|
[ -e '/etc/ldap' ] && rm -rf /etc/ldap
|
2019-02-06 23:55:03 +01:00
|
|
|
cp -r `dirname $0`/etc/ldap /etc/ldap
|
2019-02-07 22:34:47 +01:00
|
|
|
[ -e '/etc/ldapcherry' ] && rm -rf /etc/ldapcherry
|
2019-02-06 23:55:03 +01:00
|
|
|
cp -r `dirname $0`/etc/ldapcherry /etc/ldapcherry
|
|
|
|
|
2015-04-14 15:45:16 +02:00
|
|
|
cd `dirname $0`/../../
|
|
|
|
sudo sed -i "s%template_dir.*%template_dir = '`pwd`/resources/templates/'%" /etc/ldapcherry/ldapcherry.ini
|
|
|
|
sudo sed -i "s%tools.staticdir.dir.*%tools.staticdir.dir = '`pwd`/resources/static/'%" /etc/ldapcherry/ldapcherry.ini
|
|
|
|
|
2015-04-14 16:04:33 +02:00
|
|
|
chown -R openldap:openldap /etc/ldap/
|
|
|
|
/etc/init.d/slapd restart
|
2015-05-25 19:30:41 +02:00
|
|
|
ldapadd -c -H ldap://localhost:390 -x -D "cn=admin,dc=example,dc=org" -f /etc/ldap/content.ldif -w password
|
2019-02-06 23:55:03 +01:00
|
|
|
if grep -q '127.0.0.1' /etc/hosts && ! grep -q 'ldap.ldapcherry.org' /etc/hosts
|
2015-06-17 19:58:05 +02:00
|
|
|
then
|
|
|
|
sed -i "s/\(127.0.0.1.*\)/\1 ldap.ldapcherry.org ad.ldapcherry.org ldap.dnscherry.org/" /etc/hosts
|
|
|
|
else
|
|
|
|
echo '127.0.0.1 ldap.ldapcherry.org ad.ldapcherry.org ldap.dnscherry.org' >> /etc/hosts
|
|
|
|
fi
|
|
|
|
cat /etc/hosts
|
|
|
|
|
2015-04-14 17:33:31 +02:00
|
|
|
|
2015-04-14 21:28:38 +02:00
|
|
|
df -h
|
|
|
|
|
2016-07-22 21:19:38 +02:00
|
|
|
find /var/log/samba/ -type f -exec rm -f {} \;
|
|
|
|
|
2015-04-14 17:33:31 +02:00
|
|
|
smbconffile=/etc/samba/smb.conf
|
|
|
|
domain=dc
|
|
|
|
realm=dc.ldapcherry.org
|
2016-07-27 21:10:02 +02:00
|
|
|
sambadns=SAMBA_INTERNAL
|
2015-04-14 17:33:31 +02:00
|
|
|
targetdir=/var/lib/samba/
|
|
|
|
role=dc
|
2015-04-14 21:09:01 +02:00
|
|
|
sambacmd=samba-tool
|
|
|
|
adpass=qwertyP455
|
|
|
|
|
2019-02-07 22:07:28 +01:00
|
|
|
systemctl unmask samba-ad-dc
|
|
|
|
|
2016-07-27 21:13:56 +02:00
|
|
|
hostname ad.ldapcherry.org
|
2016-07-27 21:42:15 +02:00
|
|
|
pkill -9 dnsmasq
|
2019-02-07 22:34:47 +01:00
|
|
|
pkill -9 samba
|
2016-07-27 21:06:31 +02:00
|
|
|
|
2016-07-28 06:34:48 +02:00
|
|
|
kill -9 `cat /var/run/samba/smbd.pid`
|
|
|
|
rm -f /var/run/samba/smbd.pid
|
|
|
|
kill -9 `cat /var/run/samba/nmbd.pid`
|
|
|
|
rm -f /var/run/samba/nmbd.pid
|
2017-01-24 02:52:16 +01:00
|
|
|
rm -rf /var/run/samba
|
2016-07-28 06:34:48 +02:00
|
|
|
|
2015-04-14 22:15:58 +02:00
|
|
|
echo "deploy AD"
|
2015-04-14 17:33:31 +02:00
|
|
|
printf '' > "${smbconffile}" && \
|
|
|
|
${sambacmd} domain provision ${hostip} \
|
|
|
|
--domain="${domain}" --realm="${realm}" --dns-backend="${sambadns}" \
|
2016-06-17 08:03:10 +02:00
|
|
|
--targetdir="${targetdir}" --use-rfc2307 \
|
2015-04-14 22:15:58 +02:00
|
|
|
--configfile="${smbconffile}" --server-role="${role}" -d 1 --adminpass="${adpass}"
|
|
|
|
|
2015-04-14 17:33:31 +02:00
|
|
|
|
2015-04-14 22:15:58 +02:00
|
|
|
echo "Move configuration"
|
|
|
|
mv "${targetdir}/etc/smb.conf" "${smbconffile}"
|
|
|
|
|
2016-07-22 21:31:58 +02:00
|
|
|
cat ${smbconffile}
|
2016-07-22 21:19:38 +02:00
|
|
|
|
2015-04-14 22:15:58 +02:00
|
|
|
mv /var/lib/samba/private/krb5.conf /etc/krb5.conf
|
|
|
|
|
2019-02-07 23:46:10 +01:00
|
|
|
sleep 15
|
2016-06-17 08:09:44 +02:00
|
|
|
|
2019-02-07 23:46:10 +01:00
|
|
|
systemctl restart samba-ad-dc
|
|
|
|
/etc/init.d/samba-ad-dc restart
|
2016-07-10 09:53:09 +02:00
|
|
|
|
|
|
|
cat /var/log/samba/*
|
2015-04-14 21:47:52 +02:00
|
|
|
|
|
|
|
sleep 5
|
2015-04-14 21:30:52 +02:00
|
|
|
|
2019-02-09 15:42:48 +01:00
|
|
|
samba-tool domain passwordsettings set -d 1 --complexity off
|
|
|
|
samba-tool domain passwordsettings set -d 1 --min-pwd-length 0
|
2019-02-07 23:46:10 +01:00
|
|
|
systemctl status samba-ad-dc
|
2019-02-07 22:07:28 +01:00
|
|
|
ss -apn | grep samba
|