#!/bin/bash # # Copyright (C) 2015 Nethesis S.r.l. # http://www.nethesis.it - nethserver@nethesis.it # # This script is part of NethServer. # # NethServer is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, # or any later version. # # NethServer is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with NethServer. If not, see COPYING. # ipAddress=$(/sbin/e-smith/config getprop nsdc IpAddress) if [[ -r /root/.joincredentials ]]; then read -d $'\0' joinUser joinPass < /root/.joincredentials fi /sbin/e-smith/config setprop sssd status enabled Provider ad AdDns ${ipAddress} /sbin/e-smith/expand-template /etc/dnsmasq.conf systemctl restart dnsmasq # Ensure sssd is stopped systemctl stop sssd # Truncate sssd.conf > /etc/sssd/sssd.conf for ((attempt = 1;attempt < 4; attempt++)); do # Avoid false "already joined" condition: > /etc/samba/smb.conf # Truncate old realm configuration sed -i -r -e '/default_realm = / d' -e '/^\[(domain_realm|realms)\]/,$ d' /etc/krb5.conf # Join the domain with default credentials echo "${joinPass:-Nethesis,1234}" | /usr/sbin/realm join -U "${joinUser:-Administrator}" $(/sbin/e-smith/config getprop sssd Realm) if [[ $? == 0 ]]; then exec /sbin/e-smith/signal-event nethserver-sssd-save fi echo "[WARNING] DC join attempt $attempt of 3 failed! Wait a few seconds..." sleep 5 done echo "[ERROR] DC join failed" 1>&2 exit 1