summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2016-02-02 13:15:37 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-02-02 13:15:37 (GMT)
commit0225fb12aa45a259f728951693d5b101c010c3fd (patch) (side-by-side diff)
tree1e8990874b8370cdb8ee1d2f3f29f4b4c8b31004
parent814257a140f499653d9cf3dbc64be9fac53a09fe (diff)
downloaddnstools-0225fb12aa45a259f728951693d5b101c010c3fd.tar.gz
dnstools-0225fb12aa45a259f728951693d5b101c010c3fd.tar.bz2
Bugfixes
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xdgd/rc.uplink88
-rwxr-xr-xvhostcname/vhostcname13
2 files changed, 66 insertions, 35 deletions
diff --git a/dgd/rc.uplink b/dgd/rc.uplink
index 239d85f..55b3242 100755
--- a/dgd/rc.uplink
+++ b/dgd/rc.uplink
@@ -26,6 +26,10 @@ END {
echo "$n $1" >> $rt_tables
fi
ip rule add from $3 table $1
+ ip rule add from $5 table $1
+ if [ -n "$6" ]; then
+ ip rule add from $6 table $1
+ fi
ip route add default via $4 table $1
if [ -n "$7" ]; then
ip route add $7 dev $2 src $3 table $1
@@ -40,6 +44,7 @@ gw=$4
ns=$5 $6
net=$7
EOF
+ /etc/rc.d/rc.dgd reload
}
readlinkinfo() {
@@ -51,54 +56,79 @@ readlinkinfo() {
linkcleanup() {
test -f "$linkdir/$1" && rm "$linkdir/$1"
ip route flush table $1
+ /etc/rc.d/rc.dgd reload
}
-#linkup NAME
+#linkup NAME [ IF IP GW NS1 NS2 [NET] ]
linkup() {
local name=$1 link_if link_ip link_gw link_ns link_net
- shift
- if [ -f "$linkdir/$name" ]; then
- readlinkinfo "$linkdir/$name"
- if [ -z "$link_gw" ]; then
- echo >&2 "$0: $linkdir/$name: gw not set"
+ if [ $# -eq 1 ]; then
+ if [ -f "$linkdir/$name" ]; then
+ readlinkinfo "$linkdir/$name"
+ if [ -z "$link_gw" ]; then
+ echo >&2 "$0: $linkdir/$name: gw not set"
+ exit 1
+ fi
+ else
+ echo >&2 "$0: $linkdir/$name: no such file"
exit 1
fi
- ip route add default via $link_gw
- cat > $active <<EOT
+ elif [ $# -lt 6 ]; then
+ echo >&2 "$0: bad number of arguments to linkup"
+ exit 1
+ else
+ link_if=$2
+ link_ip=$3
+ link_gw=$4
+ link_ns="$5 $6"
+ link_net=$7
+ fi
+ ip route add default via $link_gw
+ cat > $active <<EOT
[core]
active = $name
EOT
- echo "$link_ns" | awk '
+ echo "$link_ns" | awk '
BEGIN { print "forwarders {" }
{ for (i = 1; i <= NF; i++) print " " $(i) ";"; }
END { print "};" }' > $forwarders
- rndc reload
- else
- echo >&2 "$0: $linkdir/$name: no such file"
- exit 1
- fi
+ rndc reload || /etc/rc.d/rc.bind restart
+ export link_if
+ /etc/rc.d/rc.iptables -f nat start
}
-#linkdown NAME
+#linkdown NAME [ IF IP GW NS1 NS2 [NET] ]
linkdown() {
local name=$1 link_if link_ip link_gw link_ns link_net link_active
- shift
- if [ -f "$linkdir/$name" ]; then
- readlinkinfo "$linkdir/$name"
- if [ -z "$link_gw" ]; then
- echo >&2 "$0: $linkdir/$name: gw not set"
- exit 1
- fi
- ip route del default via $link_gw
- if [ -r "$active" ]; then
- readlinkinfo $active
- if [ "$link_name" = "$name" ]; then
- rm $active
+ if [ $# -eq 1 ]; then
+ if [ -f "$linkdir/$name" ]; then
+ readlinkinfo "$linkdir/$name"
+ if [ -z "$link_gw" ]; then
+ echo >&2 "$0: $linkdir/$name: gw not set"
+ exit 1
fi
+ else
+ echo >&2 "$0: $linkdir/$name: no such file"
+ exit 1
fi
+ elif [ $# -lt 6 ]; then
+ echo >&2 "$0: bad number of arguments to linkdown"
+ exit 1
else
- echo >&2 "$0: $linkdir/$name: no such file"
- exit 1
+ link_if=$2
+ link_ip=$3
+ link_gw=$4
+ link_ns="$5 $6"
+ link_net=$7
+ fi
+ export link_if
+ /etc/rc.d/rc.iptables -f nat stop
+ ip route del default via $link_gw
+ if [ -r "$active" ]; then
+ readlinkinfo $active
+ if [ "$link_name" = "$name" ]; then
+ rm $active
+ fi
fi
}
diff --git a/vhostcname/vhostcname b/vhostcname/vhostcname
index 5981871..91a2c8d 100755
--- a/vhostcname/vhostcname
+++ b/vhostcname/vhostcname
@@ -88,7 +88,7 @@ sub parse_section {
$input = $2;
$quote = undef;
} else {
- die "unparsable input $input";
+ abend(EX_CONFIG, "unparsable input $input");
}
}
@@ -527,9 +527,9 @@ sub com_status {
my %comtab = (
start => \&com_start,
- restart => \&com_reload,
- 'force-restart' => \&com_start,
+ 'force-restart' => 'start',
reload => \&com_reload,
+ restart => 'reload',
stop => \&com_stop,
status => \&com_status
);
@@ -537,11 +537,12 @@ my %comtab = (
sub getcom {
my $com = shift;
- while (defined($comtab{$com}) and ref($comtab{$com}) ne 'CODE') {
+ while (exists($comtab{$com}) and ref($comtab{$com}) ne 'CODE') {
+ die "internal error: unresolved command alias"
+ unless exists $comtab{$com};
$com = $comtab{$com};
}
- die "internal error: unresolved command alias" unless defined $com;
- return $comtab{$com} if defined $comtab{$com};
+ return $comtab{$com} if exists $comtab{$com};
my @v = map { /^$com/ ? $_ : () } sort keys %comtab;
if ($#v == -1) {

Return to:

Send suggestions and report system problems to the System administrator.