-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·78 lines (60 loc) · 2.5 KB
/
entrypoint.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
#!/bin/sh
# Required environment variables
# SAMBA_DC_REALM - Samba Realm
# SAMBA_DC_ACTION - Action to take (provision or join)
# SAMBA_DC_MASTER - Only required or used during domain join. IP Address of existing DC to join.
# SAMBA_DC_ADMIN_PASSWD - Administrator password (only used to provision or join domain). If not specified, will randomly generate. Must be correct to join.
# Optional environment variables
# SAMBA_DC_DNS_FORWARDER - IP address to forward DNS requests to (accepts space separated list)
# SAMBA_DC_DOMAIN - Samba AD Domain shortname. Set to leftmost part of SAMBA_DC_REALM if unspecified.
set -e
COMMAND=ash
SAMBA_IP_ADDRESS=`ip addr | grep $SAMBA_INTERFACE | grep inet | awk '{print $2}' | cut -f1 -d"/"`
# Add $COMMAND if needed
if [ "${1:0:1}" = "-" ]
then
set -- $COMMAND "$@"
fi
info () {
echo "[INFO] $@"
}
if [ ! -f /etc/samba/smb.conf ]; then
: "${SAMBA_DC_REALM:?SAMBA_DC_REALM must be set}"
: "${SAMBA_DC_ACTION:?SAMBA_DC_ACTION must be set}"
SAMBA_DC_ADMIN_PASSWD=${SAMBA_DC_ADMIN_PASSWD:-`(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c20; echo) 2>/dev/null`}
SAMBA_OPTIONS=${SAMBA_OPTIONS:-}
SAMBA_DC_DOMAIN=${SAMBA_DC_DOMAIN:-${SAMBA_DC_REALM%%.*}}
info "Samba Domain shortname set to: ${SAMBA_DC_DOMAIN}"
case "${SAMBA_DC_ACTION}" in
"join")
: "${SAMBA_DC_MASTER:?SAMBA_DC_MASTER must be set to join a domain}"
info "${SAMBA_DC_DOMAIN} - Begin Domain Joining"
samba-tool domain join "${SAMBA_DC_REALM}" MEMBER \
--username="Administrator" \
--password="${SAMBA_DC_ADMIN_PASSWD}" \
--workgroup="${SAMBA_DC_DOMAIN}" \
--option="interfaces=lo $SAMBA_INTERFACE" \
--option="bind interfaces only=yes"
info "${SAMBA_DC_DOMAIN} - Domain Joining Successful"
echo "# ADD YOUR FOLDERS SHARES HERE #
# SET PERMISSIONS OF FOLDER WITH THIS COMMAND:
docker exec -it samba-pdc chown root:\"Domain Admins\" /samba/shares/FOLDER
" > /samba/shares/README.txt
;;
*)
: "${SAMBA_ERROR_OUT:?SAMBA_DC_ACTION must be either 'provision' or 'join'}"
;;
esac
fi
# rm -rf /etc/krb5.conf
# cp /var/lib/samba/private/krb5.conf /etc/krb5.conf
# chown root:named /etc/krb5.conf
# chown root:named /var/lib/samba/bind-dns -R
if [ "$1" = 'samba' ]
then
# named-checkconf "/etc/named.conf"
# exec /usr/sbin/named -4 -c /etc/named.conf -u named -f
exec /usr/bin/supervisord -c /etc/supervisord.d/supervisord.conf
fi
# If we get here, the user wants to run their own command. Let them.
exec "$@"