diff -urN scripts-old/ip-down scripts/ip-down --- scripts-old/ip-down 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-down 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,17 @@ +#!/bin/sh + +# This script is run by pppd after the link is brought down. +# It executes all the scripts available in /etc/ppp/ip-down.d directory, +# with the following parameters: +# $1 = interface name (e.g. ppp0) +# $2 = tty device +# $3 = speed +# $4 = local IP address +# $5 = remote IP address +# $6 = ipparam (user specified parameter, see man pppd) + +cd /etc/ppp/ip-down.d || exit + +for SCRIPT in *.sh ; do + . ./"${SCRIPT}" "$@" +done diff -urN scripts-old/ip-down.d/30-wins.sh scripts/ip-down.d/30-wins.sh --- scripts-old/ip-down.d/30-wins.sh 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-down.d/30-wins.sh 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,18 @@ +#!/bin/sh + +# Remove WINS servers from smb.conf +# Used parameters and environment variables: +# $1 - interface name (e.g. ppp0) +# $USEPEERWINS - set if user specified usepeerdns +# $WINS1 and $WINS2 - WINS servers reported by peer + +if [ "$USEPEERWINS" = 1 -a -f /etc/samba/smb.conf ]; then + # Remove the WINS servers + winsservers= + [ -n "$WINS1" ] && winsservers="$winsservers $1:$WINS1" + [ -n "$WINS2" ] && winsservers="$winsservers $1:$WINS2" + sed -i -e "s/^\([[:space:]]*wins[[:space:]]*server[[:space:]]*=[^#]*\) $winsservers /\1/i" /etc/samba/smb.conf + + # Reload nmbd configuration + smbcontrol nmbd reload-config +fi diff -urN scripts-old/ip-down.d/40-dns.sh scripts/ip-down.d/40-dns.sh --- scripts-old/ip-down.d/40-dns.sh 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-down.d/40-dns.sh 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +# Restore DNS resolver settings +# Used parameters and environment variables: +# $1 - interface name (e.g. ppp0) +# $USEPEERDNS - set if user specified usepeerdns + +if [ "$USEPEERDNS" ]; then + if [ -x /sbin/resolvconf ]; then + /sbin/resolvconf -d "$1" + else + # taken from debian's 0000usepeerdns + # follow any symlink to find the real file + REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf) + + if [ "$REALRESOLVCONF" != "/etc/ppp/resolv.conf" ]; then + + # if an old resolv.conf file exists, restore it + if [ -e $REALRESOLVCONF.pppd-backup ]; then + mv $REALRESOLVCONF.pppd-backup $REALRESOLVCONF + fi + + fi + fi +fi diff -urN scripts-old/ip-down.d/50-initd.sh scripts/ip-down.d/50-initd.sh --- scripts-old/ip-down.d/50-initd.sh 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-down.d/50-initd.sh 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,12 @@ +#!/bin/sh + +# Deactivates correspondent net.${iface} service +# Used parameters and environment variables: +# $1 - interface name (e.g. ppp0) + +if [ -x /etc/init.d/net.$1 ]; then + if /etc/init.d/net.$1 --quiet status ; then + export IN_BACKGROUND="true" + /etc/init.d/net.$1 --quiet stop + fi +fi diff -urN scripts-old/ip-up scripts/ip-up --- scripts-old/ip-up 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-up 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,17 @@ +#!/bin/sh + +# This script is run by pppd after the link is established. +# It executes all the scripts available in /etc/ppp/ip-up.d directory, +# with the following parameters: +# $1 = interface name (e.g. ppp0) +# $2 = tty device +# $3 = speed +# $4 = local IP address +# $5 = remote IP address +# $6 = ipparam (user specified parameter, see man pppd) + +cd /etc/ppp/ip-up.d || exit + +for SCRIPT in *.sh ; do + . ./"${SCRIPT}" "$@" +done diff -urN scripts-old/ip-up.d/30-wins.sh scripts/ip-up.d/30-wins.sh --- scripts-old/ip-up.d/30-wins.sh 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-up.d/30-wins.sh 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,27 @@ +#!/bin/sh + +# Handle smb.conf updating when the usepeerwins pppd option is being used. +# Used parameters and environment variables: +# $1 - interface name (e.g. ppp0) +# $USEPEERWINS - set if user specified usepeerdns +# $WINS1 and $WINS2 - WINS servers reported by peer +# Will additionally "tag" the wins servers, as explained in smb.conf(5), using the $1 value. + +if [ "$USEPEERWINS" = 1 -a -f /etc/samba/smb.conf ]; then + # Add global section if it is needed + grep -qi '\[[[:space:]]*global[[:space:]]*\]' /etc/samba/smb.conf \ + || sed -i -e '1i[global]' /etc/samba/smb.conf + + # Add wins server line if is missing + grep -qi '^[[:space:]]*wins[[:space:]]*server[[:space:]]*=' /etc/samba/smb.conf \ + || sed -i -e '/\[[[:space:]]*global[[:space:]]*\]/a\ wins server =' /etc/samba/smb.conf + + # Set the WINS servers + winsservers= + [ -n "$WINS1" ] && winsservers="$winsservers $1:$WINS1" + [ -n "$WINS2" ] && winsservers="$winsservers $1:$WINS2" + sed -i -e "s/^\([[:space:]]*wins[[:space:]]*server[[:space:]]*=[^#]*\)/\1 $winsservers /i" /etc/samba/smb.conf + + # Reload nmbd configuration + smbcontrol nmbd reload-config +fi diff -urN scripts-old/ip-up.d/40-dns.sh scripts/ip-up.d/40-dns.sh --- scripts-old/ip-up.d/40-dns.sh 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-up.d/40-dns.sh 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,42 @@ +#!/bin/sh + +# Handle resolv.conf generation when usepeerdns pppd option is being used. +# Used parameters and environment variables: +# $1 - interface name (e.g. ppp0) +# $USEPEERDNS - set if user specified usepeerdns +# $DNS1 and $DNS2 - DNS servers reported by peer + +if [ "$USEPEERDNS" ]; then + + if [ -x /sbin/resolvconf ]; then + { + echo "# Generated by ppp for $1" + [ -n "$DNS1" ] && echo "nameserver $DNS1" + [ -n "$DNS2" ] && echo "nameserver $DNS2" + } | /sbin/resolvconf -a "$1" + else + # add the server supplied DNS entries to /etc/resolv.conf + # (taken from debian's 0000usepeerdns) + + # follow any symlink to find the real file + REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf) + + if [ "$REALRESOLVCONF" != "/etc/ppp/resolv.conf" ]; then + + # merge the new nameservers with the other options from the old configuration + { + grep --invert-match '^nameserver[[:space:]]' $REALRESOLVCONF + cat /etc/ppp/resolv.conf + } > $REALRESOLVCONF.tmp + + # backup the old configuration and install the new one + cp -dpP $REALRESOLVCONF $REALRESOLVCONF.pppd-backup + mv $REALRESOLVCONF.tmp $REALRESOLVCONF + + # correct permissions + chmod 0644 /etc/resolv.conf + chown root:root /etc/resolv.conf + fi + fi + +fi diff -urN scripts-old/ip-up.d/50-initd.sh scripts/ip-up.d/50-initd.sh --- scripts-old/ip-up.d/50-initd.sh 1970-01-01 01:00:00.000000000 +0100 +++ scripts/ip-up.d/50-initd.sh 2009-08-15 22:16:34.000000000 +0200 @@ -0,0 +1,12 @@ +#!/bin/sh + +# Activates correspondent net.${iface} service +# Used parameters and environment variables: +# $1 - interface name (e.g. ppp0) + +if [ -x /etc/init.d/net.$1 ]; then + if ! /etc/init.d/net.$1 --quiet status ; then + export IN_BACKGROUND="true" + /etc/init.d/net.$1 --quiet start + fi +fi