#!/bin/bash # Authors: # (C) 2021 Idea an concept by Christian Zengel # (C) 2021 Script design and prototype by Markus Helmke # (C) 2021 Script rework and documentation by Thorsten Spille set -euo pipefail source /root/functions.sh source /root/zamba.conf source /root/constants-service.conf apt update DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" acl samba winbind libpam-winbind libnss-winbind krb5-user krb5-config samba-dsdb-modules samba-vfs-modules mv /etc/krb5.conf /etc/krb5.conf.bak cat > /etc/krb5.conf < /etc/samba/smb.conf <> /etc/samba/smb.conf << EOF [$ZMB_SHARE] path = /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE read only = No create mask = 0660 directory mask = 0770 inherit acls = Yes EOF done echo -e "$ZMB_ADMIN_PASS" | kinit -V $ZMB_ADMIN_USER klist systemctl restart smbd echo -e "$ZMB_ADMIN_PASS" | net ads join -U $ZMB_ADMIN_USER createcomputer=Computers sed -i "s|files systemd|files systemd winbind|g" /etc/nsswitch.conf sed -i "s|#WINBINDD_OPTS=|WINBINDD_OPTS=|" /etc/default/winbind echo -e "session optional pam_mkhomedir.so skel=/etc/skel umask=077" >> /etc/pam.d/common-session systemctl restart winbind nmbd wbinfo -u wbinfo -g unset ZMB_SHARE for ZMB_SHARE in "${ZMB_SHARES_ARRAY[@]}" do mkdir -p /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE # originally 'domain users' was set, added variable for domain admins group, samba wiki recommends separate group e.g. 'unix admins' chown "${ZMB_ADMIN_USER@L}":"${ZMB_DOMAIN_ADMINS@L}" /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE setfacl -Rm u:${ZMB_ADMIN_USER@L}:rwx,g:"${ZMB_DOMAIN_ADMINS@L}":rwx,o::- /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE setfacl -Rdm u:${ZMB_ADMIN_USER@L}:rwx,g:"${ZMB_DOMAIN_ADMINS@L}":rwx,o::- /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE done systemctl restart smbd nmbd winbind