some cleanups need to be done - as well as a updated rock-net core is scheduled for tonight. git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@1821 c5f82cb5-29bc-0310-9cd0-bff59a50e3bcrocklinux
@ -0,0 +1,6 @@ |
|||
|
|||
public_dhcp() { |
|||
addcode up 5 5 "/sbin/dhclient -q $if" |
|||
addcode down 5 5 "killall -15 dhclient" |
|||
} |
|||
|
@ -1,67 +0,0 @@ |
|||
# --- ROCK-COPYRIGHT-NOTE-BEGIN --- |
|||
# |
|||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|||
# Please add additional copyright information _after_ the line containing |
|||
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by |
|||
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text! |
|||
# |
|||
# ROCK Linux: rock-src/package/base/iproute2/network.conf |
|||
# ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf |
|||
# |
|||
# This program 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 2 of the License, or |
|||
# (at your option) any later version. A copy of the GNU General Public |
|||
# License can be found at Documentation/COPYING. |
|||
# |
|||
# Many people helped and are helping developing ROCK Linux. Please |
|||
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM |
|||
# file for details. |
|||
# |
|||
# --- ROCK-COPYRIGHT-NOTE-END --- |
|||
# |
|||
# This file defines two shell functions: start_net() and stop_net() |
|||
# |
|||
# This functions are called by /etc/init.d/network to set up and shut |
|||
# down the networking stuff. In most cases its enought to change this |
|||
# variables. If your setup is more complex you need to rewrite the |
|||
# functions below. |
|||
# |
|||
|
|||
DHCP="on" |
|||
|
|||
IF="eth0" |
|||
IPADDR="192.168.5.10/24" |
|||
GATEWAY="192.168.5.1" |
|||
|
|||
# |
|||
# start and stop functions (called by /etc/init.d/network) |
|||
# |
|||
|
|||
xx() { echo ">> $*" ; eval "$*" ; return $? ; } |
|||
|
|||
start_net() { |
|||
if [ -f /etc/mactab ]; then |
|||
xx nameif -c /etc/mactab |
|||
fi |
|||
if [ ".$DHCP" = ".on" ]; then |
|||
xx /sbin/dhclient -q $IF |
|||
else |
|||
xx ip link set $IF up |
|||
for addr in $IPADDR; do |
|||
xx ip addr add $addr dev $IF |
|||
done |
|||
[ "$GATEWAY" ] && xx ip route add default via $GATEWAY |
|||
fi |
|||
return 0 |
|||
} |
|||
|
|||
stop_net() { |
|||
if [ ".$DHCP" = ".on" ]; then |
|||
xx killall -15 /sbin/dhclient |
|||
fi |
|||
xx ip route del default |
|||
xx ip addr flush dev $IF |
|||
xx ip link set $IF down |
|||
return 0 |
|||
} |
@ -0,0 +1,19 @@ |
|||
|
|||
iproute2_init_if() { |
|||
if isfirst "iproute2_$if"; then |
|||
addcode up 5 4 "ip link set $if up" |
|||
addcode down 5 4 "ip link set $if down" |
|||
addcode down 5 5 "ip addr flush dev $if" |
|||
fi |
|||
} |
|||
|
|||
public_ip() { |
|||
addcode up 5 5 "ip addr add $1 dev $if" |
|||
iproute2_init_if |
|||
} |
|||
|
|||
public_gw() { |
|||
addcode up 6 5 "ip route add default via $1 dev $if" |
|||
iproute2_init_if |
|||
} |
|||
|
@ -0,0 +1,49 @@ |
|||
|
|||
iptables_init_if() { |
|||
if isfirst "iptables_$if"; then |
|||
addcode up 1 1 "iptables -N firewall_$if" |
|||
addcode up 1 2 "iptables -A INPUT -i $if -j firewall_$if" |
|||
addcode up 1 3 "iptables -A firewall_$if ` |
|||
`-m state --state ESTABLISHED,RELATED -j ACCEPT" |
|||
|
|||
addcode down 1 3 "iptables -F firewall_$if" |
|||
addcode down 1 2 "iptables -D INPUT -i $if -j firewall_$if" |
|||
addcode down 1 1 "iptables -X firewall_$if" |
|||
fi |
|||
} |
|||
|
|||
iptales_parse_conditions() { |
|||
iptables_cond="" |
|||
while [ -n "$1" ] |
|||
do |
|||
case "$1" in |
|||
all) |
|||
shift |
|||
;; |
|||
tcp|udp) |
|||
iptables_cond="$iptables_cond -p $1 --dport $2" |
|||
shift; shift |
|||
;; |
|||
ip) |
|||
iptables_cond="$iptables_cond -s $2" |
|||
shift; shift |
|||
;; |
|||
*) |
|||
error "Unkown allow/deny condition: $1" |
|||
shift |
|||
esac |
|||
done |
|||
} |
|||
|
|||
public_allow() { |
|||
iptales_parse_conditions "$@" |
|||
addcode up 1 5 "iptables -A firewall_$if $iptables_cond -j ACCEPT" |
|||
iptables_init_if |
|||
} |
|||
|
|||
public_deny() { |
|||
iptales_parse_conditions "$@" |
|||
addcode up 1 5 "iptables -A firewall_$if $iptables_cond -j REJECT" |
|||
iptables_init_if |
|||
} |
|||
|
@ -0,0 +1,17 @@ |
|||
#!/bin/sh |
|||
|
|||
useage() { |
|||
echo "Useage: $0 interface [ profile ]" |
|||
exit 1 |
|||
} |
|||
|
|||
[ "$1" ] || useage |
|||
|
|||
if [ "$2" = "" ] ; then |
|||
profile="`cat /etc/network/profile`" |
|||
else |
|||
profile="$2" |
|||
fi |
|||
|
|||
/etc/network/rocknet $1 $2 ${x#if} |
|||
|
@ -0,0 +1,80 @@ |
|||
#!/bin/bash |
|||
|
|||
rocknet_debug=1 |
|||
rocknet_base="/etc/network" |
|||
|
|||
unset code_snipplets_idx code_snipplets_dat code_snipplets_counter |
|||
declare -a code_snipplets_idx='()' |
|||
declare -a code_snipplets_dat='()' |
|||
code_snipplets_counter=0 |
|||
|
|||
lineno=0 |
|||
ignore=0 |
|||
|
|||
if [ "$3" != "up" -a "$3" != "down" ]; then |
|||
echo "Usage: $0 { profile | default } { interface | auto } { up | down }" |
|||
exit 1 |
|||
fi |
|||
|
|||
profile=$1 |
|||
interface=$2 |
|||
mode=$3 |
|||
|
|||
# |
|||
# addcode mode major-priority minor-priority code1 |
|||
# |
|||
addcode() { |
|||
[ "$mode" != "$1" ] && return |
|||
[ "$ignore" -gt 0 ] && return |
|||
if [ "$1" = "up" ]; then udo="+"; else udo="-"; fi |
|||
code_snipplets_idx[code_snipplets_counter]="` |
|||
printf '%04d.%04d.%04d' $((5000$udo$2)) $((5000$udo$lineno)) \ |
|||
$((5000$udo$3))` $code_snipplets_counter" |
|||
code_snipplets_dat[code_snipplets_counter]="$4" |
|||
(( code_snipplets_counter++ )) |
|||
} |
|||
|
|||
# |
|||
# isfirst unique-id |
|||
# |
|||
isfirst() { |
|||
[ "$ignore" -gt 0 ] && return 0 |
|||
eval "\$isfirst_$1" |
|||
eval "isfirst_$1='return 1'" |
|||
return 0 |
|||
} |
|||
|
|||
# |
|||
# error error-message |
|||
# |
|||
error() { |
|||
echo "$*" |
|||
} |
|||
|
|||
for x in "$rocknet_base"/modules/*.sh; do . "$x"; done |
|||
|
|||
while read cmd para |
|||
do |
|||
(( lineno++ )) |
|||
if [ -n "$cmd" ]; then |
|||
cmd="${cmd//-/_}" |
|||
para="$( echo "$para" | sed 's,[\*\?],\\&,g' )" |
|||
if declare -f public_$cmd > /dev/null |
|||
then |
|||
public_$cmd $para |
|||
else |
|||
error "Unknown statement in config file: $cmd" |
|||
fi |
|||
fi |
|||
done < <( sed 's,#.*,,' < "$rocknet_base"/config ) |
|||
|
|||
while read id1 id2; do |
|||
if [ "$rocknet_debug" = 1 ]; then |
|||
echo ">> $id1 -> $id2: ${code_snipplets_dat[id2]}" |
|||
fi |
|||
eval "${code_snipplets_dat[id2]}" |
|||
done < <( |
|||
for x in "${code_snipplets_idx[@]}"; do echo "$x" |
|||
done | sort |
|||
) |
|||
|
@ -0,0 +1,46 @@ |
|||
|
|||
if="none" |
|||
declare -a auto_if=() |
|||
auto_if[0]="*" |
|||
|
|||
public_auto() { |
|||
auto_if=() |
|||
for x in "$@"; do |
|||
a="${x%(*}"; b="${x#*(}" |
|||
b="${b#)}"; b="${b//,/ }" |
|||
if [ "$a" = "$b" ]; then |
|||
auto_if[${#auto_if[*]}]="$a" |
|||
else |
|||
for x in $b; do |
|||
[ "$x" = "$profile" ] && \ |
|||
auto_if[${#auto_if[*]}]="$a" |
|||
done |
|||
fi |
|||
done |
|||
} |
|||
|
|||
public_interface() { |
|||
ignore=1 if="${1%(*}" |
|||
local prof="${1#*(}" |
|||
prof="${prof/)}"; prof="${prof//,/ }" |
|||
|
|||
if [ "$if" = "$prof" ]; then |
|||
ignore=0 |
|||
else |
|||
for x in $prof; do |
|||
[ "$x" = "$profile" ] && ignore=0 |
|||
done |
|||
fi |
|||
|
|||
if [ "$ignore" = 0 ]; then |
|||
if [ "$if" = "auto" ]; then |
|||
ignore=1 |
|||
for x in "${auto_if[@]}"; do |
|||
[[ "$if" == $x ]] && ignore=0 |
|||
done |
|||
else |
|||
[ "$if" = "$interface" ] || ignore=1 |
|||
fi |
|||
fi |
|||
} |
|||
|
@ -0,0 +1,19 @@ |
|||
|
|||
public_script() { |
|||
local a="$1"; shift |
|||
addcode up 5 5 "$a up $*" |
|||
addcode down 5 5 "$a down $*" |
|||
} |
|||
|
|||
public_run_up() { |
|||
addcode up 5 5 "$*" |
|||
} |
|||
|
|||
public_run_down() { |
|||
addcode down 5 5 "$*" |
|||
} |
|||
|
|||
public_code() { |
|||
addcode $1 $2 5 "$3" |
|||
} |
|||
|
@ -0,0 +1,12 @@ |
|||
|
|||
public_forward() { |
|||
if [ "$if" != "none" ]; then |
|||
error "Keyword >>forward<< not allowed" \ |
|||
"in an interface section." |
|||
return |
|||
fi |
|||
[ "$interface" != all ] && return |
|||
addcode up 9 5 "echo 1 > /proc/sys/net/ipv4/ip_forward" |
|||
addcode down 9 5 "echo 0 > /proc/sys/net/ipv4/ip_forward" |
|||
} |
|||
|
@ -0,0 +1,69 @@ |
|||
|
|||
public_essid() { |
|||
addcode up 4 5 "iwconfig $if essid $*" |
|||
} |
|||
|
|||
public_nwid() { |
|||
addcode up 4 5 "iwconfig $if nwid $*" |
|||
} |
|||
|
|||
public_domain() { |
|||
addcode up 4 5 "iwconfig $if domain $*" |
|||
} |
|||
|
|||
public_freq() { |
|||
addcode up 4 5 "iwconfig $if freq $*" |
|||
} |
|||
|
|||
public_channel() { |
|||
addcode up 4 5 "iwconfig $if channel $*" |
|||
} |
|||
|
|||
public_sens() { |
|||
addcode up 4 5 "iwconfig $if sens $*" |
|||
} |
|||
|
|||
public_mode() { |
|||
addcode up 4 4 "iwconfig $if mode $*" |
|||
} |
|||
|
|||
public_ap() { |
|||
addcode up 4 5 "iwconfig $if ap $*" |
|||
} |
|||
|
|||
public_nick() { |
|||
addcode up 4 5 "iwconfig $if nick $*" |
|||
} |
|||
|
|||
public_rate() { |
|||
addcode up 4 5 "iwconfig $if rate $*" |
|||
} |
|||
|
|||
public_rts() { |
|||
addcode up 4 5 "iwconfig $if rts $*" |
|||
} |
|||
|
|||
public_frag() { |
|||
addcode up 4 5 "iwconfig $if frag $*" |
|||
} |
|||
|
|||
public_key() { |
|||
addcode up 4 5 "iwconfig $if key $*" |
|||
} |
|||
|
|||
public_power() { |
|||
addcode up 4 5 "iwconfig $if power $*" |
|||
} |
|||
|
|||
public_txpower() { |
|||
addcode up 4 5 "iwconfig $if txpower $*" |
|||
} |
|||
|
|||
public_retry() { |
|||
addcode up 4 5 "iwconfig $if retry $*" |
|||
} |
|||
|
|||
public_commit() { |
|||
addcode up 4 9 "iwconfig $if commit" |
|||
} |
|||
|