Browse Source

Rene Rebe:


			
			
				rocklinux
			
			
		
Rene Rebe 22 years ago
parent
commit
76c6a530ed
3 changed files with 73 additions and 11 deletions
  1. +44
    -8
      package/base/sysfiles/ifup.sh
  2. +27
    -3
      package/base/sysfiles/rocknet.sh
  3. +2
    -0
      package/base/sysfiles/rocknet_modules_base.sh

+ 44
- 8
package/base/sysfiles/ifup.sh

@ -1,20 +1,56 @@
#!/bin/sh
rocknet_tmp_base="/var/run/rocknet"
[ -d $rocknet_tmp_base ] || mkdir -p $rocknet_tmp_base
var_contains() {
local tmp;
eval "tmp=\"\$$1\""
[ "${tmp/$3$2/}" != "$tmp" ]
}
usage() {
echo "Usage: $0 interface [ profile ]"
echo "Usage: $0 interface [ profile ] [ -force ]"
exit 1
}
[ "$1" ] || usage
force=0
if [ "$2" = "" ] ; then
profile="`cat /etc/network/profile 2> /dev/null`"
else
profile="$2"
fi
if="$1" ; shift ; [ "$if" ] || usage
profile=""
action="${0/#*\/if}"
while [ "$1" ] ; do
case $1 in
-force) force=1 ;;
*) [ "$profile" = "" ] && profile="$1" || usage ;;
esac
shift
done
[ "$profile" ] || profile="`cat /etc/network/profile 2> /dev/null`"
profile=${profile:-default}
/etc/network/rocknet "$profile" "$1" "${0#/sbin/if}"
# sanity checks (...)
if [ $force -eq 0 ] ; then
active_interfaces="`cat $rocknet_tmp_base/active-interfaces 2>/dev/null`"
if test $action = "up" && var_contains active_interfaces ',' "$1($profile)"
then
echo "Interface $if($profile) is already listed active, it is probably a good idea to"
echo "take it down before activating it. Use -force to suppress this warning."
exit 2
fi
if test $action = "down" && ! var_contains active_interfaces ',' "$1($profile)"
then
echo "Interface $if($profile) is not listed active, it is probably a good idea to"
echo "activate it before deactivating it. Use -force to suppress this warning."
exit 2
fi
fi
/etc/network/rocknet "$profile" "$if" "$action"
echo "$profile" > /etc/network/profile

+ 27
- 3
package/base/sysfiles/rocknet.sh

@ -13,6 +13,7 @@ code_snipplets_counter=0
lineno=0
ignore=0
global=1
if [ "$3" != "up" -a "$3" != "down" ]; then
echo "Usage: $0 { profile | default } { interface | auto } { up | down }"
@ -61,6 +62,20 @@ status() {
echo "$*"
}
#
# register / unregister active interfaces for user input validation
#
register() {
echo -n "${1}," >> $rocknet_tmp_base/active-interfaces
}
unregister () {
active_interfaces="`cat $rocknet_tmp_base/active-interfaces 2>/dev/null`"
active_interfaces="${active_interfaces//${1},/}"
echo -n "$active_interfaces" > $rocknet_tmp_base/active-interfaces
}
for x in "$rocknet_base"/modules/*.sh; do . "$x"; done
while read cmd para
@ -71,7 +86,14 @@ do
para="$( echo "$para" | sed 's,[\*\?],\\&,g' )"
if declare -f public_$cmd > /dev/null
then
public_$cmd $para
# optimization: Only execute commands when they are
# inside an unignored interface section ...
if [ $cmd = "interface" ] ; then
public_$cmd $para
global=0
elif [ $ignore -eq 0 -o $global -gt 0 ] ; then
public_$cmd $para
fi
else
error "Unknown statement in config file: $cmd"
fi
@ -88,6 +110,8 @@ done < <(
done | sort
)
[ "$pmatched" = 0 ] && error "Unknown profile: $profile"
[ "$imatched" = 0 ] && error "Unknown interface for profile: $interface"
[ "$pmatched" = 0 ] && \
error "Unknown profile: '$profile'"
[ "$pmatched" = 1 -a "$imatched" = 0 ] && \
error "Unknown interface for profile: '$interface'"

+ 2
- 0
package/base/sysfiles/rocknet_modules_base.sh

@ -47,6 +47,8 @@ public_interface() {
if [ "$ignore" = 0 ] ; then
imatched=1
status "Interface / profile matched: $if($prof)"
addcode up 9 9 "register $if\($prof\)"
addcode down 9 9 "unregister $if\($prof\)"
fi
}

Loading…
Cancel
Save