From 2bba724fc51f5d762dafcad5386803e2faad3275 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 12 Jul 2005 16:37:39 +0000 Subject: r8387: moving wins_hook to scripts directory (This used to be commit 9d507b218d90d4a7e6a5cc97994f5f5adb686cbf) --- examples/scripts/wins_hook/README | 8 +++ examples/scripts/wins_hook/dns_update | 94 +++++++++++++++++++++++++++++++++++ examples/wins_hook/README | 8 --- examples/wins_hook/dns_update | 94 ----------------------------------- 4 files changed, 102 insertions(+), 102 deletions(-) create mode 100644 examples/scripts/wins_hook/README create mode 100644 examples/scripts/wins_hook/dns_update delete mode 100644 examples/wins_hook/README delete mode 100644 examples/wins_hook/dns_update diff --git a/examples/scripts/wins_hook/README b/examples/scripts/wins_hook/README new file mode 100644 index 0000000000..1147f57e22 --- /dev/null +++ b/examples/scripts/wins_hook/README @@ -0,0 +1,8 @@ +This is an example script for doing dynamic DNS updates from the WINS +database. You use this by putting the full path to the script in the +"wins hook" option in smb.conf. Remember to mark the script executable +and to set the right domain at the top of the script. + +See the BIND documentation for how to enable dynamic DNS +updates. Remember to restrict the updates as far as you can to reduce +the security risks inherent in dynamic DNS. diff --git a/examples/scripts/wins_hook/dns_update b/examples/scripts/wins_hook/dns_update new file mode 100644 index 0000000000..a4c1a79ab9 --- /dev/null +++ b/examples/scripts/wins_hook/dns_update @@ -0,0 +1,94 @@ +#!/bin/sh +# +# Example script for "wins hook". This attempts to update the DNS with +# new A records for the NETBIOS name that Samba passes us. We do this +# the simple way, by deleting all DNS records for the name and then +# readding all the expected 'A' records. +# +# Written by Stephen Rothwell +# + +# +# Configurable things +# +# The domain in which to create names +# YOU MUST CHANGE THIS +# N.B. include the trailing dot +# +# It is a good idea to use a subdomain of your primary domain to ensure +# that rogue machines can't take over (or delete) important names on +# your network. +DOMAIN=wins.example.com. + +# +# The DNS TTL to give the records (in seconds) +# +TTL=3600 +# +# NETBIOS name types that we want to create DNS records for: +# 20 is server +# 00 is workstation +# 03 is user +# +USEFUL_TYPES="20 00 03" +# +# The name of a cache file to use to avoid continual updates +# of the same name and IP addresses. If you comment this out +# then the cache is not kept at all. +# +#CACHE_FILE=/usr/local/samba/var/wins_update.cache + +if [ $# -lt 4 ]; then + echo "Usage: $0 op name type ttl [ip_addr ...]" 1>&2 + echo " op is one of add, refresh, delete" 1>&2 + echo " name is the NETBIOS name" 1>&2 + echo " type is the NETBIOS name type" 1>&2 + echo " ttl is the NETBIOS time to live" 1>&2 + echo " ip_addr's are the remaining IP addresses for this name" 1>&2 + exit 1 +fi + +NSUPDATE=`which nsupdate` +[ -x "$NSUPDATE" ] || NSUPDATE=/usr/bin/nsupdate +[ -x "$NSUPDATE" ] || NSUPDATE=/sbin/nsupdate +[ -x "$NSUPDATE" ] || NSUPDATE=/usr/sbin/nsupdate +[ -x "$NSUPDATE" ] || { + echo "Cannot find nsupdate." 1>&2 + exit 1 +} + +OP=$1 +NAME=$2 +TYPE=$3 +WINS_TTL=$4 +shift 4 +IP_ADDRS="$@" + +do_update=0 +for i in $USEFUL_TYPES +do + [ "$TYPE" = "$i" ] && do_update=1 +done +[ $do_update = 1 ] || exit 0 + +if [ -n "$CACHE_FILE" ]; then + if [ -r "$CACHE_FILE" ]; then + fgrep -q -x -i "$NAME $IP_ADDRS" "$CACHE_FILE" && + exit 0 + grep -v -i "^$NAME " "$CACHE_FILE" >"$CACHE_FILE".$$ + fi + echo "$NAME $IP_ADDRS" >>"$CACHE_FILE".$$ + mv "$CACHE_FILE" "$CACHE_FILE".old 2>/dev/null + mv "$CACHE_FILE".$$ "$CACHE_FILE" +fi + +{ + echo update delete $NAME.$DOMAIN + for i in $IP_ADDRS + do + echo update add $NAME.$DOMAIN $TTL A $i + done + echo +} 2>/dev/null | $NSUPDATE >/dev/null 2>&1 & + +exit 0 diff --git a/examples/wins_hook/README b/examples/wins_hook/README deleted file mode 100644 index 1147f57e22..0000000000 --- a/examples/wins_hook/README +++ /dev/null @@ -1,8 +0,0 @@ -This is an example script for doing dynamic DNS updates from the WINS -database. You use this by putting the full path to the script in the -"wins hook" option in smb.conf. Remember to mark the script executable -and to set the right domain at the top of the script. - -See the BIND documentation for how to enable dynamic DNS -updates. Remember to restrict the updates as far as you can to reduce -the security risks inherent in dynamic DNS. diff --git a/examples/wins_hook/dns_update b/examples/wins_hook/dns_update deleted file mode 100644 index a4c1a79ab9..0000000000 --- a/examples/wins_hook/dns_update +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# -# Example script for "wins hook". This attempts to update the DNS with -# new A records for the NETBIOS name that Samba passes us. We do this -# the simple way, by deleting all DNS records for the name and then -# readding all the expected 'A' records. -# -# Written by Stephen Rothwell -# - -# -# Configurable things -# -# The domain in which to create names -# YOU MUST CHANGE THIS -# N.B. include the trailing dot -# -# It is a good idea to use a subdomain of your primary domain to ensure -# that rogue machines can't take over (or delete) important names on -# your network. -DOMAIN=wins.example.com. - -# -# The DNS TTL to give the records (in seconds) -# -TTL=3600 -# -# NETBIOS name types that we want to create DNS records for: -# 20 is server -# 00 is workstation -# 03 is user -# -USEFUL_TYPES="20 00 03" -# -# The name of a cache file to use to avoid continual updates -# of the same name and IP addresses. If you comment this out -# then the cache is not kept at all. -# -#CACHE_FILE=/usr/local/samba/var/wins_update.cache - -if [ $# -lt 4 ]; then - echo "Usage: $0 op name type ttl [ip_addr ...]" 1>&2 - echo " op is one of add, refresh, delete" 1>&2 - echo " name is the NETBIOS name" 1>&2 - echo " type is the NETBIOS name type" 1>&2 - echo " ttl is the NETBIOS time to live" 1>&2 - echo " ip_addr's are the remaining IP addresses for this name" 1>&2 - exit 1 -fi - -NSUPDATE=`which nsupdate` -[ -x "$NSUPDATE" ] || NSUPDATE=/usr/bin/nsupdate -[ -x "$NSUPDATE" ] || NSUPDATE=/sbin/nsupdate -[ -x "$NSUPDATE" ] || NSUPDATE=/usr/sbin/nsupdate -[ -x "$NSUPDATE" ] || { - echo "Cannot find nsupdate." 1>&2 - exit 1 -} - -OP=$1 -NAME=$2 -TYPE=$3 -WINS_TTL=$4 -shift 4 -IP_ADDRS="$@" - -do_update=0 -for i in $USEFUL_TYPES -do - [ "$TYPE" = "$i" ] && do_update=1 -done -[ $do_update = 1 ] || exit 0 - -if [ -n "$CACHE_FILE" ]; then - if [ -r "$CACHE_FILE" ]; then - fgrep -q -x -i "$NAME $IP_ADDRS" "$CACHE_FILE" && - exit 0 - grep -v -i "^$NAME " "$CACHE_FILE" >"$CACHE_FILE".$$ - fi - echo "$NAME $IP_ADDRS" >>"$CACHE_FILE".$$ - mv "$CACHE_FILE" "$CACHE_FILE".old 2>/dev/null - mv "$CACHE_FILE".$$ "$CACHE_FILE" -fi - -{ - echo update delete $NAME.$DOMAIN - for i in $IP_ADDRS - do - echo update add $NAME.$DOMAIN $TTL A $i - done - echo -} 2>/dev/null | $NSUPDATE >/dev/null 2>&1 & - -exit 0 -- cgit