-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit.sh
executable file
·103 lines (69 loc) · 2.99 KB
/
init.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
USER="max-control"
HOST="127.0.0.1"
PORT="389"
HOSTNAME="$(hostname)"
PASS="$(tr -cd '[:alnum:]' < /dev/urandom | fold -w15 | head -n1)"
# create max-control user or change password if exists
if ! samba-tool user list 2>/dev/null | grep -q ^max-control$ ; then
echo " * Creando usuario administrador del panel..."
samba-tool user add "$USER" "$PASS" > /dev/null 2>&1
# samba-tool group addmembers "Domain Admins" "$USER" > /dev/null 2>&1
# samba-tool group addmembers "Administrators" "$USER" > /dev/null 2>&1
GROUP="Domain Admins" NEWUSER="${USER}" zentyal-maxcontrol addgroupmember > /dev/null 2>&1
GROUP="Administrators" NEWUSER="${USER}" zentyal-maxcontrol addsysgroupmember > /dev/null 2>&1
else
samba-tool user setpassword "${USER}" --newpassword="${PASS}" > /dev/null 2>&1
if ! id max-control | grep -q -i admin; then
echo " * Actualizando usuario administrador del panel... "
GROUP="Domain Admins" NEWUSER="${USER}" zentyal-maxcontrol addgroupmember > /dev/null 2>&1
GROUP="Administrators" NEWUSER="${USER}" zentyal-maxcontrol addsysgroupmember > /dev/null 2>&1
fi
fi
DOMAIN=$(dnsdomainname)
BASEDN=$(dnsdomainname | sed -e 's/\./,DC=/g' -e 's/^/DC=/')
WORKGROUP=$(dnsdomainname | awk -F. '{print toupper($1)}')
if [ "$BASEDN" = "" ]; then
echo " * ERROR: No se pudo determinar el servidor de dominio."
exit 0
fi
# create MAXGroups container
# and Teacher, CoordinadoresTIC and Instaladores
zentyal-maxcontrol init
rm -f /etc/max-control/conf.inc.php
cat << EOF > /etc/max-control/conf.inc.php
<?php
// file autogenerated with init.sh on '`date`'
// basedn del dominio
define('LDAP_BASEDN', '${BASEDN}');
define('WORKGROUP', '${WORKGROUP}');
// autenticacion
define('LDAP_BINDDN', 'CN=${USER},CN=Users,${BASEDN}');
define('LDAP_BINDPW', '${PASS}');
define("LDAP_ADMIN", '${USER}');
// autogenerated password in init.sh
define("LDAP_PASS", '${PASS}');
// Entidades organizativas
define('LDAP_OU_COMPUTERS', 'CN=Computers,${BASEDN}');
define('LDAP_OU_USERS', 'CN=Users,${BASEDN}');
define('LDAP_OU_GROUPS', 'CN=Users,${BASEDN}');
// dominio
define('LDAP_DOMAIN', '${DOMAIN}');
define('LDAP_OU_BUILTINS', 'CN=MAXGroups,${BASEDN}');
// Administrators
define('LDAP_OU_ADMINS', 'CN=Administrators,CN=Builtin,${BASEDN}');
define('LDAP_OU_DADMINS', 'CN=Domain Admins,CN=Users,${BASEDN}');
define('LDAP_OU_DUSERS', 'CN=Domain Users,CN=Users,${BASEDN}');
define('TEACHERS', 'Teachers');
define('LDAP_OU_TEACHERS', 'CN=Teachers,CN=MAXGroups,${BASEDN}');
define('TICS', 'CoordinadoresTIC');
define('LDAP_OU_TICS', 'CN=CoordinadoresTIC,CN=MAXGroups,${BASEDN}');
define('INSTALLATORS', 'Instaladores');
define('LDAP_OU_INSTALLATORS', 'CN=Instaladores,CN=MAXGroups,${BASEDN}');
define("HOMES", "/home/${WORKGROUP}/");
define("LDAP_HOST", "${HOST}");
define("LDAP_HOSTNAME", "${HOSTNAME}");
define("LDAP_PORT", ${PORT});
define('CONFIGURED', True);
`cat /usr/share/max-control/conf.inc.php.init`
EOF