Changed sync-netlogon.sh from samba to use samba config instead hard coded names.
This commit is contained in:
parent
12e01b282c
commit
26e9ece24d
1 changed files with 24 additions and 2 deletions
|
@ -1,7 +1,29 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# determine domain name
|
||||||
|
WORKGROUP=`echo '' | testparm -v --section-name global 2> /dev/null | \
|
||||||
|
sed -n 's/^\tworkgroup = \(.*\)/\1/p'`
|
||||||
|
if [ "${WORKGROUP}" = "" ]; then
|
||||||
|
echo "Error in netlogon sync, failed to determine domain name"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
WINSSERVER=`echo '' | testparm -v --section-name global 2> /dev/null | \
|
||||||
|
sed -n 's/^\twins server = \(.*\)/\1/p'`
|
||||||
|
if [ "${WINSSERVER}" = "" ]; then
|
||||||
|
NMBLOOKUP="nmblookup"
|
||||||
|
else
|
||||||
|
NMBLOOKUP="nmblookup -r ${WINSSERVER}"
|
||||||
|
fi
|
||||||
|
PDC=`${NMBLOOKUP} "${WORKGROUP}#1B" | \
|
||||||
|
sed -n "s/^\([0-9\.]*\) ${WORKGROUP}<1b>/\1/p" | head -1`
|
||||||
|
if [ "${PDC}" = "" ]; then
|
||||||
|
echo "Error in netlogon sync, failed to determine PDC address"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# check that domain controller is alive
|
# check that domain controller is alive
|
||||||
smbclient -N -L pdc > /dev/null 2>&1
|
smbclient -N -L ${PDC} > /dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error in netlogon sync, could not open connection to DC"
|
echo "Error in netlogon sync, could not open connection to DC"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -28,7 +50,7 @@ fi
|
||||||
mkdir ${TMPDIR}
|
mkdir ${TMPDIR}
|
||||||
|
|
||||||
# copy netlogon data from domain controller
|
# copy netlogon data from domain controller
|
||||||
( smbclient //pdc/netlogon -N -Tqc - | (cd ${TMPDIR} ; tar xf - ) ) \
|
( smbclient //${PDC}/netlogon -N -Tqc - | (cd ${TMPDIR} ; tar xf - ) ) \
|
||||||
>> /var/log/samba/log.sync-netlogon 2>&1
|
>> /var/log/samba/log.sync-netlogon 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error in netlogon sync see /var/log/samba/log.sync-netlogon"
|
echo "Error in netlogon sync see /var/log/samba/log.sync-netlogon"
|
||||||
|
|
Loading…
Add table
Reference in a new issue