afornerot 2021-01-07 14:53:53 +01:00
parent b7d5c65902
commit 71c72fe923
1 changed files with 23 additions and 15 deletions

@ -20,29 +20,37 @@ user_exists() {
$CONTAINER_EXEC samba-tool user show "${username}" > /dev/null 2>&1
}
if [ -f /etc/eole/samba4-vars.conf ];then
CONTAINER_EXEC=''
elif [ -f /usr/lib/eole/eolead.sh ];then
CONTAINER_EXEC='lxc-attach -n addc --'
else
exit 0
fi
PRIVATE_DIR=/etc/eole/private
WRITER_PASSWORD_FILE="${PRIVATE_DIR}/eole-workstation-writer.password"
if [ ! -s "${WRITER_PASSWORD_FILE}" ]
then
pwgen -scn1 42 > "/etc/eole/private/eole-workstation-writer.password"
pwgen -scn1 42 > "${WRITER_PASSWORD_FILE}"
fi
chmod 700 "/etc/eole/private/eole-workstation-writer.password"
chmod 700 "${WRITER_PASSWORD_FILE}"
if ! user_exists eole-workstation-manager
WRITER_PASSWORD=$(cat "${WRITER_PASSWORD_FILE}")
if ! user_exists eole-workstation-writer
then
echo "Ajout du compte de jonction au domaine 'eole-workstation-manager'... "
$CONTAINER_EXEC samba-tool user create --random-password eole-workstation-manager
fi
echo "Mise en conformité de lutilisateur 'eole-workstation-manager'... "
$CONTAINER_EXEC samba-tool user setexpiry eole-workstation-manager --noexpiry
if ! $CONTAINER_EXEC samba-tool group listmembers 'Domain Admins' | grep -q '^eole-workstation-manager$'
then
$CONTAINER_EXEC samba-tool group addmembers 'Domain Admins' eole-workstation-manager
fi
$CONTAINER_EXEC samba-tool user setpassword eole-workstation-manager --newpassword="${MANAGER_PASSWORD}"
echo "Ajout du compte de jonction au domaine 'eole-workstation-writer'... "
$CONTAINER_EXEC samba-tool user create --random-password eole-workstation-writer
fi
echo "Mise en conformité de lutilisateur 'eole-workstation-writer'... "
$CONTAINER_EXEC samba-tool user setexpiry eole-workstation-writer --noexpiry
if ! $CONTAINER_EXEC samba-tool group listmembers 'Domain Admins' | grep -q '^eole-workstation-manager$'
then
$CONTAINER_EXEC samba-tool group addmembers 'Domain Admins' eole-workstation-manager
fi
$CONTAINER_EXEC samba-tool user setpassword eole-workstation-writer --newpassword="${WRITER_PASSWORD}"
```