?mode=patch&uid=2006092710562627885
Open Patch: 2006092710562627885 (by blindcoder)
+ blindcoder
Votecheck 'core-strong': Missing 1 qualified vote(s) (clifford, fake, teha)
package/base/sysfiles/stone_mod_network.sh
package/base/sysfiles/ifup.sh
package/base/sysfiles/etc_networks.txt
package/base/sysfiles/rocknet_modules_script.sh
package/base/sysfiles/rocknet_config
package/base/sysfiles/rocknet_modules_base.sh
package/base/sysfiles/rocknet.sh
package/base/sysfiles/rocknet_getprofile
package/base/sysfiles/rocknet_modules_dns.sh
package/base/sysfiles/rocknet_README
package/base/sysfiles/network.init
package/base/sysfiles/rocknet_modules_sysctl.sh
package/base/sysfiles/system.init
package/base/sysfiles/sysfiles.conf
package/base/rocknet/rocknet_modules_base.sh
package/base/rocknet/rocknet.desc
package/base/rocknet/rocknet_README
package/base/rocknet/etc_networks.txt
package/base/rocknet/rocknet_getprofile
package/base/rocknet/rocknet_modules_sysctl.sh
package/base/rocknet/rocknet.conf
package/base/rocknet/stone_mod_network.sh
package/base/rocknet/rocknet_config
package/base/rocknet/rocknet_modules_dns.sh
package/base/rocknet/rocknet_modules_script.sh
package/base/rocknet/network.init
package/base/rocknet/ifup.sh
package/base/rocknet/rocknet.sh
Benjamin Schieder:
forcefully extract a rocknet packgae from the sysfiles package
This is in preparation of /etc/net integration
this version also makes the appropriate changes in sysfiles.conf
Benjamin Schieder:
forcefully extract a rocknet packgae from the sysfiles package
This is in preparation of /etc/net integration
--- package/base/sysfiles/stone_mod_network.sh (Revision 48)
+++ package/base/sysfiles/stone_mod_network.sh (Revision 54)
@@ -1,116 +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/sysfiles/stone_mod_network.sh
-# ROCK Linux is Copyright (C) 1998 - 2006 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 https://rocklinux.org/ and the Documentation/TEAM
-# file for details.
-#
-# --- ROCK-COPYRIGHT-NOTE-END ---
-#
-# [MAIN] 20 network Network Configuration
-
-set_name() {
- old1="$HOSTNAME" old2="$HOSTNAME.$DOMAINNAME" old3="$DOMAINNAME"
- if [ $1 = HOSTNAME ] ; then
- gui_input "Set a new hostname (without domain part)" \
- "${!1}" "$1"
- else
- gui_input "Set a new domainname (without host part)" \
- "${!1}" "$1"
- fi
- new="$HOSTNAME.$DOMAINNAME $HOSTNAME"
-
- echo "$HOSTNAME" > /etc/HOSTNAME ; hostname "$HOSTNAME"
-
- #ip="`echo $IPADDR | sed 's,[/ ].*,,'`"
- #if grep -q "^$ip\\b" /etc/hosts ; then
- # tmp="`mktemp`"
- # sed -e "/^$ip\\b/ s,\\b$old2\\b[ ]*,,g" \
- # -e "/^$ip\\b/ s,\\b$old1\\b[ ]*,,g" \
- # -e "/^$ip\\b/ s,[ ]\\+,&$new ," < /etc/hosts > $tmp
- # cat $tmp > /etc/hosts ; rm -f $tmp
- #else
- # echo -e "$ip\\t$new" >> /etc/hosts
- #fi
-
- if [ $1 = DOMAINNAME ] ; then
- tmp="`mktemp`"
- grep -vx "search $old3" /etc/resolv.conf > $tmp
- [ -n "$DOMAINNAME" ] && echo "search $DOMAINNAME" >> $tmp
- cat $tmp > /etc/resolv.conf
- rm -f $tmp
- fi
-}
-
-set_dns() {
- gui_input "Set a new (space seperated) list of DNS Servers" "$DNSSRV" "DNSSRV"
- DNSSRV="`echo $DNSSRV`" ; [ -z "$DNSSRV" ] && DNSSRV="none"
-
- tmp="`mktemp`" ; grep -v '^nameserver\b' /etc/resolv.conf > $tmp
- for x in $DNSSRV ; do
- [ "$x" != "none" ] && echo "nameserver $x" >> $tmp
- done
- cat $tmp > /etc/resolv.conf
- rm -f $tmp
-}
-
-HOSTNAME="`hostname`"
-DOMAINNAME="`hostname -d 2> /dev/null`"
-
-tmp="`mktemp`"
-grep '^nameserver ' /etc/resolv.conf | tr '\t' ' ' | tr -s ' ' | \
- sed 's,^nameserver *\([^ ]*\),DNSSRV="$DNSSRV \1",' > $tmp
-DNSSRV='' ; . $tmp ; DNSSRV="`echo $DNSSRV`"
-[ -z "$DNSSRV" ] && DNSSRV="none" ; rm -f $tmp
-
-main_detailed() {
- while
- cmd="gui_menu network 'Network Configuration'"
-
- cmd="$cmd 'Static hostname: $HOSTNAME' 'set_name HOSTNAME'"
- cmd="$cmd 'Static domainname: $DOMAINNAME' 'set_name DOMAINNAME'"
- cmd="$cmd 'Static DNS-Server: $DNSSRV' 'set_dns' '' ''"
-
- cmd="$cmd 'Configure runlevels for network service'"
- cmd="$cmd '$STONE runlevel edit_srv network'"
- cmd="$cmd '(Re-)Start network init script'"
- cmd="$cmd '$STONE runlevel restart network'"
- cmd="$cmd '' ''"
-
- cmd="$cmd 'View/Edit /etc/resolv.conf file' 'gui_edit /etc/resolv.conf /etc/resolv.conf'"
- cmd="$cmd 'View/Edit /etc/hosts file' 'gui_edit /etc/hosts /etc/hosts'"
- cmd="$cmd 'View/Edit /etc/network/config file' 'gui_edit /etc/network/config /etc/network/config'"
-
- cmd="$cmd '' ''"
-
- cmd="$cmd 'Read the /etc/network/README file' 'gui_edit /etc/network/README /etc/network/README'"
-
- eval "$cmd"
- do : ; done
-}
-
-main() {
- while
- cmd="gui_menu network 'Network Configuration'"
-
- cmd="$cmd 'Just edit /etc/network/config' 'gui_edit /etc/network/config /etc/network/config'"
- cmd="$cmd 'Read the /etc/network/README file' 'gui_edit /etc/network/README /etc/network/README'"
- cmd="$cmd 'Detailed Networking configuration' 'exec $0 network main_detailed'"
-
- eval "$cmd"
- do : ; done
-}
-
--- package/base/sysfiles/ifup.sh (Revision 48)
+++ package/base/sysfiles/ifup.sh (Revision 54)
@@ -1,57 +0,0 @@
-#!/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 ] [ -force ]"
- exit 1
-}
-
-force=0
-
-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}
-
-# 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 ',' "$if($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 ',' "$if($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
-
--- package/base/sysfiles/etc_networks.txt (Revision 48)
+++ package/base/sysfiles/etc_networks.txt (Revision 54)
@@ -1,23 +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/sysfiles/etc_networks.txt
-# ROCK Linux is Copyright (C) 1998 - 2006 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 https://rocklinux.org/ and the Documentation/TEAM
-# file for details.
-#
-# --- ROCK-COPYRIGHT-NOTE-END ---
-
-loopback 127.0.0.0
--- package/base/sysfiles/rocknet_modules_script.sh (Revision 48)
+++ package/base/sysfiles/rocknet_modules_script.sh (Revision 54)
@@ -1,19 +0,0 @@
-
-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"
-}
-
--- package/base/sysfiles/rocknet_config (Revision 48)
+++ package/base/sysfiles/rocknet_config (Revision 54)
@@ -1,24 +0,0 @@
-#
-# ROCKNET Example Config File
-#
-# The file /etc/network/README contains a detailed description of most
-# available config directives for this file.
-#
-# Check out the modules in /etc/network/modules/* directly for information
-# about the not so-well documented directives (such as directives from 3rd
-# party modules).
-#
-
-
-### automatically set up interface eth0 on startup
-# auto eth0
-
-### interface eth0 is configured using DHCP
-# interface eth0
-# dhcp
-
-### interface eth1 is configured using a static IP
-# interface eth1
-# ip 192.168.100.99/24
-# gw 192.168.100.1
-
--- package/base/sysfiles/rocknet_modules_base.sh (Revision 48)
+++ package/base/sysfiles/rocknet_modules_base.sh (Revision 54)
@@ -1,55 +0,0 @@
-
-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
- prof="default"
- else
- for x in $prof; do
- [ "$x" = "$profile" ] && ignore=0
- done
- [ "$ignore" = 0 ] && pmatched=1
- fi
-
- if [ "$ignore" = 0 ]; then
- if [ "$interface" = "auto" ]; then
- ignore=1
- for x in "${auto_if[@]}"; do
- [[ "$if" == $x ]] && ignore=0
- done
- else
- [ "$if" = "$interface" ] || ignore=1
- fi
- fi
-
- 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
-}
-
--- package/base/sysfiles/rocknet.sh (Revision 48)
+++ package/base/sysfiles/rocknet.sh (Revision 54)
@@ -1,120 +0,0 @@
-#!/bin/bash
-
-rocknet_debug=0
-rocknet_base="/etc/network"
-rocknet_tmp_base="/var/run/rocknet"
-
-[ -d $rocknet_tmp_base ] || mkdir -p $rocknet_tmp_base
-
-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
-global=1
-retcode=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
-
-pmatched=0 # some profile matched ?
-imatched=0 # some interface matched ?
-
-#
-# 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 "$*"
- retcode=1
-}
-
-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
-do
- (( lineno++ ))
- if [ -n "$cmd" ]; then
- cmd="${cmd//-/_}"
- para="$( echo "$para" | sed 's,[\*\?],\\&,g' )"
- if declare -f public_$cmd > /dev/null
- then
- # 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
- fi
-done < <( sed 's,\(^\|[ \t]\)#.*$,,' < "$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
-)
-
-[ "$pmatched" = 0 -a "$profile" != "default" ] && \
- error "Unknown profile: '$profile'"
-[ "$pmatched" = 1 -a "$imatched" = 0 ] && \
- error "Unknown interface for profile: '$interface'"
-
-exit $retcode
--- package/base/sysfiles/rocknet_getprofile (Revision 48)
+++ package/base/sysfiles/rocknet_getprofile (Revision 54)
@@ -1,36 +0,0 @@
-#!/bin/bash
-#
-# Example for ROCKNET profile auto-detection.
-
-# on default do nothing
-exit 0
-
-echo -n "Trying to auto-detect network profile .. "
-echo default > /etc/network/profile
-
-# we need to activate the interfaces for the test
-ip l set eth0 up &> /dev/null
-ip l set eth1 up &> /dev/null
-
-# use arping to check for a well-known IPs
-(
- if arping -i eth0 -c3 10.0.23.42; then
- echo foo > /etc/network/profile
- fi
-) &> /dev/null &
-
-# maybe we have found that essid
-(
- sleep 2 # give it some time to get the essid
- if iwlist eth1 scan | grep -q 'ESSID:"MyWLAN"'; then
- echo bar > /etc/network/profile
- fi
-) &> /dev/null &
-
-# wait for all childs to finish, output found profile
-wait; cat /etc/network/profile
-
-# deactivate the interfaces, the profile might activate them again
-ip l set eth0 down &> /dev/null
-ip l set eth1 down &> /dev/null
-
--- package/base/sysfiles/rocknet_modules_dns.sh (Revision 48)
+++ package/base/sysfiles/rocknet_modules_dns.sh (Revision 54)
@@ -1,32 +0,0 @@
-
-dns_init() {
- if isfirst "dns"; then
- addcode up 4 1 "echo -n "" > /etc/resolv.conf"
- fi
-}
-
-public_nameserver() {
- addcode up 4 5 "echo nameserver $1 >> /etc/resolv.conf"
- dns_init
-}
-
-public_search() {
- if ! isfirst "dns_search"; then
- error "Keyword >>search<< not allowed multiple times."
- return
- fi
-
- addcode up 4 4 "echo search $* >> /etc/resolv.conf"
- dns_init
-}
-
-public_hostname() {
- addcode up 9 5 "hostname $1"
-}
-
-public_domainname() {
- # THIS IS A HACK
- addcode up 9 5 "sed 's/`hostname`\..* /`hostname`.$1 /' /etc/hosts > \
- /etc/hosts.new ; mv /etc/hosts{.new,}"
-}
-
--- package/base/sysfiles/rocknet_README (Revision 48)
+++ package/base/sysfiles/rocknet_README (Revision 54)
@@ -1,176 +0,0 @@
-
-ROCKNET [by Clifford Wolf]
-===========================
-
-The idea of ROCKNET is to make the network configuration more flexible and
-allow integration of simple firewalling rules, multiple interfaces, multiple
-IPs per interface and multiple profiles. It should be easy to setup very
-complex and very simple setups, should "feel good" when working directly
-with an ASCII editor on the config files and should be easy to integrate in
-a more or less colored configuration GUI (such as stone).
-
-
-Configuration File
-------------------
-
-The network configuration is stored in /etc/network/config. All filenames
-in this file are relative to /etc/network/ if they don't begin with a slash.
-
-An example /etc/network/config follows:
-
- auto eth0 eth1
- forward
-
- interface eth0
- ip 192.168.1.1/24
- ip 192.168.2.1/24
-
- interface eth1
- ip 192.168.100.99/24
- gw 192.168.100.1
-
-Or another /etc/network/config:
-
- auto eth0
-
- interface eth0
- dhcp
- dyndns # update dyndns
- # requires ezipudate
- # and setup in stone
- allow ip 10.10.0.0/24 # office
- allow ip 192.168.0.0/24 # home
- allow tcp 80 # webserver is open
- deny all
-
-Or one using profiles:
-
- auto eth0 eth1(office)
-
- interface eth0(home)
- ip 192.168.69.15/24
-
- interface eth0(office)
- allow ip 10.10.0.0/16 tcp ssh
- deny all
- dhcp
-
- interface eth1(office)
- essid 'Blubb'
- keyc 'I@mCo0l'
- deny all
- dhcp
-
-So there are commands with optional parameter lists. The following commands
-are allowed in the config file:
-
-auto
- Lists those interfaces which should be set up automatically at
- boot up (list evaluated from left to right) and shut down on system
- shutdown (from right to left). All interfaces not listed here must
- be set up or shut down manually using 'ifup' and 'ifdown'.
- Must be used before the first 'interface' directive.
-
-forward
- If used, forwarding between interfaces will be activated at boot up
- and the host may be used as gateway between two networks.
- Must be used before the first 'interface' directive.
-
-interface
- Everything after that statement and before the next interface statement
- is the configuration for that specific interface. All directives within
- an interface section are executed from the first to the last when
- setting up the interface and the reversed order when shutting it down.
-
-dhcp
- Configure the interface using the DHCP protocol.
-
-script
- Execute the specified script with the given parameters. The parameter
- "up" is inserted as first parameter when the interface is set up and
- the parameter "down" is inserted when the interface is shut down.
-
-run-up, run-down
- Run the given command when the interface is set up or shut down
- respectively.
-
-ip, gw
- Set the given ip(s) and gateway when the interface is set up, remove
- all IPs from the interface when the interface is shut down.
-
-allow, deny
- Add the given simple firewalling rules. Those statements are executed
- before the other statements in the interface section when setting up
- the interface and are executed after the other statements when
- shutting down the interface. See section "Simple Firewall" below for
- details.
-
-
-Profiles
---------
-
-Interface names in the 'auto' and the 'interface' statement can be followed
-by a coma-separated list of profile names in parentheses.
-
-In case of the 'auto' statement, only those interfaces are used which do
-have the current profile specified or no profile at all.
-
-In case of the 'interface' statement, an interface section is used if it has
-no profile specified or the current profile is given in the profile list.
-
-An non-existing interface section will be handled as it would be an empty
-interface section. Empty interface sections are silently ignored by "ifup"
-and "ifdown".
-
-The current profile is stored in /etc/network/profile.
-
-
-Command-line Tools
-------------------
-
-There are two simple command line tools for working with ROCKNET: "ifup"
-and "ifdown". The first parameter is the name of the interface which should
-be set up, the second parameter (which is optional) is the profile name to be
-used while reading the configuration. If the 2nd parameter is missing, the
-content of /etc/network/profile is used.
-
-
-Simple Firewall
----------------
-
-When there are any 'allow' or 'deny' statements in an interface section, the
-ifup script automatically adds a chain named 'simple-firewall-<ifname>' to
-the iptables 'filter' table and links that chain into the INPUT chain using
-the incoming interface as condition.
-
-All 'allow' and 'deny' statements add rules to that chain. 'Allow' links
-to the netfilter 'ACCEPT' target and 'deny' to the netfilter 'REJECT' (and
-not 'DROP') target.
-
-When shutting down the interface, the chain 'simple-firewall-<ifname>' is
-simply flushed and removed from the iptables configuration.
-
-
-Tricking with pseudo-interfaces
--------------------------------
-
-It's possible to define non-existing interfaces such as 'iptables' in the
-configuration file. It would result to errors if e.g. the 'ip' statement
-would be used in those interface sections - but it is possible to use the
-'script' statement in those pseudo-interfaces and so e.g. link a complex
-firewall setup into the ROCKNET framework.
-
-
-Compatibility
--------------
-
-The program names "ifup" and "ifdown" are used on many distributions for small
-helpers to set up or shut down interfaces.
-
-The file /etc/network/config has a very similar "feeling" as debians
-/etc/network/interfaces and so it should be pretty easy especially for debian
-users to get used to ROCK Linux based distributions network configuration.
-
-The whole thing is very different from RedHats /etc/sysconfig/network/ and is
-likely to also be different from whatever SuSE is using for the same purpose.
-
--- package/base/sysfiles/network.init (Revision 48)
+++ package/base/sysfiles/network.init (Revision 54)
@@ -1,63 +0,0 @@
-#!/bin/sh
-#
-# --- 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/sysfiles/network.init
-# ROCK Linux is Copyright (C) 1998 - 2006 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 https://rocklinux.org/ and the Documentation/TEAM
-# file for details.
-#
-# --- ROCK-COPYRIGHT-NOTE-END ---
-#
-# Desc: setting up network devices
-# Runlevel: 15 rcX rc3 rc4 rc5
-#
-
-main_begin
-
- block_begin(start, `Setting up network devices.')
- oldprof="$(cat /etc/network/profile 2>/dev/null)"
- oldprof=${oldprof:-default}
- if [ -n "$2" ]; then
- echo $2 > /etc/network/profile
- profile="$(cat /etc/network/profile 2>/dev/null)"
- profile=${profile:-default}
- echo "Active network profile is now $profile (was: $oldprof)."
- elif [ -x /etc/network/getprofile ]; then
- echo "Running network profile autodetection ..."
- /etc/network/getprofile
- profile="$(cat /etc/network/profile 2>/dev/null)"
- profile=${profile:-default}
- echo "Active network profile is now $profile (was: $oldprof)."
- else
- profile="$oldprof"
- fi
- check(`/etc/network/rocknet $profile auto up')
- block_end
-
- block_begin(stop, `Shutting down network devices.')
- profile="$(cat /etc/network/profile 2>/dev/null)"
- profile=${profile:-default}
- check(`/etc/network/rocknet $profile auto down')
- block_end
-
- block_begin(restart, `Reconfiguring network devices.')
- check(`$0 stop')
- check(`$0 start $2')
- block_end
-
-main_end
-
--- package/base/sysfiles/rocknet_modules_sysctl.sh (Revision 48)
+++ package/base/sysfiles/rocknet_modules_sysctl.sh (Revision 54)
@@ -1,12 +0,0 @@
-
-public_forward() {
- if [ "$if" != "none" ]; then
- error "Keyword >>forward<< not allowed" \
- "in an interface section."
- return
- fi
- [ "$interface" != auto ] && 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"
-}
-
--- package/base/sysfiles/system.init (Revision 48)
+++ package/base/sysfiles/system.init (Revision 54)
@@ -157,12 +157,6 @@
check(`cat /var/state/random-seed >/dev/urandom')
fi
- block_split(`Renaming network interfaces')
- if [ -e /etc/iftab ] ; then
- check(`ifrename')
- fi
- block_end
-
block_begin(stop, `Saving /var/log/init.msg and /var/log/boot.msg.')
check(`echo -n >> /var/log/init.msg')
check(`echo -n >> /var/log/boot.msg')
--- package/base/sysfiles/sysfiles.conf (Revision 48)
+++ package/base/sysfiles/sysfiles.conf (Revision 54)
@@ -35,7 +35,6 @@
cp -v "$confdir/$x" "${y//_/$z}"
fi
done
- [ -f etc/HOSTNAME ] || echo localhost > etc/HOSTNAME
chmod +x etc/initscript etc/rc.d/rc
echo "Add missing entries to etc/services .."
@@ -64,20 +63,6 @@
cp -v $confdir/$x etc/stone.d/${x#stone_}
done
- echo "Installing the rock-net tool ..."
- cp -v $confdir/rocknet.sh etc/network/rocknet
- if [ ! -f etc/network/config ]; then
- cp -vf $confdir/rocknet_config etc/network/config
- fi
- chmod +x etc/network/rocknet
- for x in $( cd $confdir; echo rocknet_{*.sh,README,getprofile}; ); do
- dst="${x#rocknet_}"; z="/"; dst="${dst//_/$z}"
- cp -vf $confdir/$x etc/network/$dst
- done
- cp -vf $confdir/ifup.sh sbin/ifup
- chmod +x etc/network/getprofile sbin/ifup
- ln -sf ifup sbin/ifdown
-
echo "Create /etc/issue, /etc/issue.ansi and /etc/issue.net ... "
rocktxt="ROCK Linux $rockver $arch"
. $confdir/issue-std.sh
@@ -128,9 +113,6 @@
echo "Installing 'system' init script ..."
install_init system $confdir/system.init
- echo "Installing 'network' init script ..."
- install_init network $confdir/network.init
-
echo "Exporting LINGUAS environment variable ..."
if [ "$ROCKCFG_LINGUAS" == "all" ] ; then
echo "# export LINGUAS=" > $root/etc/profile.d/linguas
--- package/base/rocknet/rocknet_modules_base.sh (Revision 0)
+++ package/base/rocknet/rocknet_modules_base.sh (Revision 54)
@@ -0,0 +1,55 @@
+
+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
+ prof="default"
+ else
+ for x in $prof; do
+ [ "$x" = "$profile" ] && ignore=0
+ done
+ [ "$ignore" = 0 ] && pmatched=1
+ fi
+
+ if [ "$ignore" = 0 ]; then
+ if [ "$interface" = "auto" ]; then
+ ignore=1
+ for x in "${auto_if[@]}"; do
+ [[ "$if" == $x ]] && ignore=0
+ done
+ else
+ [ "$if" = "$interface" ] || ignore=1
+ fi
+ fi
+
+ 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
+}
+
--- package/base/rocknet/rocknet.desc (Revision 0)
+++ package/base/rocknet/rocknet.desc (Revision 54)
@@ -0,0 +1,39 @@
+
+[COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN ---
+[COPY]
+[COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
+[COPY] Please add additional copyright information _after_ the line containing
+[COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
+[COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
+[COPY]
+[COPY] ROCK Linux: rock-src/package/base/rocknet/rocknet.desc
+[COPY] ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
+[COPY]
+[COPY] This program is free software; you can redistribute it and/or modify
+[COPY] it under the terms of the GNU General Public License as published by
+[COPY] the Free Software Foundation; either version 2 of the License, or
+[COPY] (at your option) any later version. A copy of the GNU General Public
+[COPY] License can be found at Documentation/COPYING.
+[COPY]
+[COPY] Many people helped and are helping developing ROCK Linux. Please
+[COPY] have a look at https://rocklinux.org/ and the Documentation/TEAM
+[COPY] file for details.
+[COPY]
+[COPY] --- ROCK-COPYRIGHT-NOTE-END ---
+
+[I] ROCK Network system
+
+[T] This package contains the ROCK Net network configuration system
+
+[A] Clifford Wolf <[email protected]>
+[M] The ROCK Linux Project
+
+[C] base/system
+
+[L] GPL
+[S] Stable
+[V] 0000 0
+[P] X -1-3---7-9 204.200
+
+[CV-URL] none
+
--- package/base/rocknet/rocknet_README (Revision 0)
+++ package/base/rocknet/rocknet_README (Revision 54)
@@ -0,0 +1,176 @@
+
+ROCKNET [by Clifford Wolf]
+===========================
+
+The idea of ROCKNET is to make the network configuration more flexible and
+allow integration of simple firewalling rules, multiple interfaces, multiple
+IPs per interface and multiple profiles. It should be easy to setup very
+complex and very simple setups, should "feel good" when working directly
+with an ASCII editor on the config files and should be easy to integrate in
+a more or less colored configuration GUI (such as stone).
+
+
+Configuration File
+------------------
+
+The network configuration is stored in /etc/network/config. All filenames
+in this file are relative to /etc/network/ if they don't begin with a slash.
+
+An example /etc/network/config follows:
+
+ auto eth0 eth1
+ forward
+
+ interface eth0
+ ip 192.168.1.1/24
+ ip 192.168.2.1/24
+
+ interface eth1
+ ip 192.168.100.99/24
+ gw 192.168.100.1
+
+Or another /etc/network/config:
+
+ auto eth0
+
+ interface eth0
+ dhcp
+ dyndns # update dyndns
+ # requires ezipudate
+ # and setup in stone
+ allow ip 10.10.0.0/24 # office
+ allow ip 192.168.0.0/24 # home
+ allow tcp 80 # webserver is open
+ deny all
+
+Or one using profiles:
+
+ auto eth0 eth1(office)
+
+ interface eth0(home)
+ ip 192.168.69.15/24
+
+ interface eth0(office)
+ allow ip 10.10.0.0/16 tcp ssh
+ deny all
+ dhcp
+
+ interface eth1(office)
+ essid 'Blubb'
+ keyc 'I@mCo0l'
+ deny all
+ dhcp
+
+So there are commands with optional parameter lists. The following commands
+are allowed in the config file:
+
+auto
+ Lists those interfaces which should be set up automatically at
+ boot up (list evaluated from left to right) and shut down on system
+ shutdown (from right to left). All interfaces not listed here must
+ be set up or shut down manually using 'ifup' and 'ifdown'.
+ Must be used before the first 'interface' directive.
+
+forward
+ If used, forwarding between interfaces will be activated at boot up
+ and the host may be used as gateway between two networks.
+ Must be used before the first 'interface' directive.
+
+interface
+ Everything after that statement and before the next interface statement
+ is the configuration for that specific interface. All directives within
+ an interface section are executed from the first to the last when
+ setting up the interface and the reversed order when shutting it down.
+
+dhcp
+ Configure the interface using the DHCP protocol.
+
+script
+ Execute the specified script with the given parameters. The parameter
+ "up" is inserted as first parameter when the interface is set up and
+ the parameter "down" is inserted when the interface is shut down.
+
+run-up, run-down
+ Run the given command when the interface is set up or shut down
+ respectively.
+
+ip, gw
+ Set the given ip(s) and gateway when the interface is set up, remove
+ all IPs from the interface when the interface is shut down.
+
+allow, deny
+ Add the given simple firewalling rules. Those statements are executed
+ before the other statements in the interface section when setting up
+ the interface and are executed after the other statements when
+ shutting down the interface. See section "Simple Firewall" below for
+ details.
+
+
+Profiles
+--------
+
+Interface names in the 'auto' and the 'interface' statement can be followed
+by a coma-separated list of profile names in parentheses.
+
+In case of the 'auto' statement, only those interfaces are used which do
+have the current profile specified or no profile at all.
+
+In case of the 'interface' statement, an interface section is used if it has
+no profile specified or the current profile is given in the profile list.
+
+An non-existing interface section will be handled as it would be an empty
+interface section. Empty interface sections are silently ignored by "ifup"
+and "ifdown".
+
+The current profile is stored in /etc/network/profile.
+
+
+Command-line Tools
+------------------
+
+There are two simple command line tools for working with ROCKNET: "ifup"
+and "ifdown". The first parameter is the name of the interface which should
+be set up, the second parameter (which is optional) is the profile name to be
+used while reading the configuration. If the 2nd parameter is missing, the
+content of /etc/network/profile is used.
+
+
+Simple Firewall
+---------------
+
+When there are any 'allow' or 'deny' statements in an interface section, the
+ifup script automatically adds a chain named 'simple-firewall-<ifname>' to
+the iptables 'filter' table and links that chain into the INPUT chain using
+the incoming interface as condition.
+
+All 'allow' and 'deny' statements add rules to that chain. 'Allow' links
+to the netfilter 'ACCEPT' target and 'deny' to the netfilter 'REJECT' (and
+not 'DROP') target.
+
+When shutting down the interface, the chain 'simple-firewall-<ifname>' is
+simply flushed and removed from the iptables configuration.
+
+
+Tricking with pseudo-interfaces
+-------------------------------
+
+It's possible to define non-existing interfaces such as 'iptables' in the
+configuration file. It would result to errors if e.g. the 'ip' statement
+would be used in those interface sections - but it is possible to use the
+'script' statement in those pseudo-interfaces and so e.g. link a complex
+firewall setup into the ROCKNET framework.
+
+
+Compatibility
+-------------
+
+The program names "ifup" and "ifdown" are used on many distributions for small
+helpers to set up or shut down interfaces.
+
+The file /etc/network/config has a very similar "feeling" as debians
+/etc/network/interfaces and so it should be pretty easy especially for debian
+users to get used to ROCK Linux based distributions network configuration.
+
+The whole thing is very different from RedHats /etc/sysconfig/network/ and is
+likely to also be different from whatever SuSE is using for the same purpose.
+
--- package/base/rocknet/etc_networks.txt (Revision 0)
+++ package/base/rocknet/etc_networks.txt (Revision 54)
@@ -0,0 +1,23 @@
+# --- 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/sysfiles/etc_networks.txt
+# ROCK Linux is Copyright (C) 1998 - 2006 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 https://rocklinux.org/ and the Documentation/TEAM
+# file for details.
+#
+# --- ROCK-COPYRIGHT-NOTE-END ---
+
+loopback 127.0.0.0
--- package/base/rocknet/rocknet_getprofile (Revision 0)
+++ package/base/rocknet/rocknet_getprofile (Revision 54)
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Example for ROCKNET profile auto-detection.
+
+# on default do nothing
+exit 0
+
+echo -n "Trying to auto-detect network profile .. "
+echo default > /etc/network/profile
+
+# we need to activate the interfaces for the test
+ip l set eth0 up &> /dev/null
+ip l set eth1 up &> /dev/null
+
+# use arping to check for a well-known IPs
+(
+ if arping -i eth0 -c3 10.0.23.42; then
+ echo foo > /etc/network/profile
+ fi
+) &> /dev/null &
+
+# maybe we have found that essid
+(
+ sleep 2 # give it some time to get the essid
+ if iwlist eth1 scan | grep -q 'ESSID:"MyWLAN"'; then
+ echo bar > /etc/network/profile
+ fi
+) &> /dev/null &
+
+# wait for all childs to finish, output found profile
+wait; cat /etc/network/profile
+
+# deactivate the interfaces, the profile might activate them again
+ip l set eth0 down &> /dev/null
+ip l set eth1 down &> /dev/null
+
--- package/base/rocknet/rocknet_modules_sysctl.sh (Revision 0)
+++ package/base/rocknet/rocknet_modules_sysctl.sh (Revision 54)
@@ -0,0 +1,12 @@
+
+public_forward() {
+ if [ "$if" != "none" ]; then
+ error "Keyword >>forward<< not allowed" \
+ "in an interface section."
+ return
+ fi
+ [ "$interface" != auto ] && 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"
+}
+
--- package/base/rocknet/rocknet.conf (Revision 0)
+++ package/base/rocknet/rocknet.conf (Revision 54)
@@ -0,0 +1,60 @@
+# --- 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/sysfiles/sysfiles.conf
+# ROCK Linux is Copyright (C) 1998 - 2006 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 https://rocklinux.org/ and the Documentation/TEAM
+# file for details.
+#
+# --- ROCK-COPYRIGHT-NOTE-END ---
+
+main_rn() {
+ cd $root/
+
+ echo "Creating various etc/* files ..."
+ for x in $( cd $confdir ; echo etc_*.txt ) ; do
+ y="${x%.txt}" ; z="/"
+ if [ -f "${y//_/$z}" ]
+ then
+ echo "Found old ${y//_/$z} (don't overwrite)."
+ touch "${y//_/$z}"
+ else
+ cp -v "$confdir/$x" "${y//_/$z}"
+ fi
+ done
+ [ -f etc/HOSTNAME ] || echo localhost > etc/HOSTNAME
+
+ echo "Installing the rock-net tool ..."
+ cp -v $confdir/rocknet.sh etc/network/rocknet
+ if [ ! -f etc/network/config ]; then
+ cp -vf $confdir/rocknet_config etc/network/config
+ fi
+ chmod +x etc/network/rocknet
+ for x in $( cd $confdir; echo rocknet_{*.sh,README,getprofile}; ); do
+ dst="${x#rocknet_}"; z="/"; dst="${dst//_/$z}"
+ cp -vf $confdir/$x etc/network/$dst
+ done
+ cp -vf $confdir/ifup.sh sbin/ifup
+ chmod +x etc/network/getprofile sbin/ifup
+ ln -sf ifup sbin/ifdown
+
+ echo "Installing 'network' init script ..."
+ install_init network $confdir/network.init
+}
+
+custmain="main_rn"
+autoextract=0
+check_usrlocal=0
+
--- package/base/rocknet/stone_mod_network.sh (Revision 0)
+++ package/base/rocknet/stone_mod_network.sh (Revision 54)
@@ -0,0 +1,116 @@
+# --- 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/sysfiles/stone_mod_network.sh
+# ROCK Linux is Copyright (C) 1998 - 2006 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 https://rocklinux.org/ and the Documentation/TEAM
+# file for details.
+#
+# --- ROCK-COPYRIGHT-NOTE-END ---
+#
+# [MAIN] 20 network Network Configuration
+
+set_name() {
+ old1="$HOSTNAME" old2="$HOSTNAME.$DOMAINNAME" old3="$DOMAINNAME"
+ if [ $1 = HOSTNAME ] ; then
+ gui_input "Set a new hostname (without domain part)" \
+ "${!1}" "$1"
+ else
+ gui_input "Set a new domainname (without host part)" \
+ "${!1}" "$1"
+ fi
+ new="$HOSTNAME.$DOMAINNAME $HOSTNAME"
+
+ echo "$HOSTNAME" > /etc/HOSTNAME ; hostname "$HOSTNAME"
+
+ #ip="`echo $IPADDR | sed 's,[/ ].*,,'`"
+ #if grep -q "^$ip\\b" /etc/hosts ; then
+ # tmp="`mktemp`"
+ # sed -e "/^$ip\\b/ s,\\b$old2\\b[ ]*,,g" \
+ # -e "/^$ip\\b/ s,\\b$old1\\b[ ]*,,g" \
+ # -e "/^$ip\\b/ s,[ ]\\+,&$new ," < /etc/hosts > $tmp
+ # cat $tmp > /etc/hosts ; rm -f $tmp
+ #else
+ # echo -e "$ip\\t$new" >> /etc/hosts
+ #fi
+
+ if [ $1 = DOMAINNAME ] ; then
+ tmp="`mktemp`"
+ grep -vx "search $old3" /etc/resolv.conf > $tmp
+ [ -n "$DOMAINNAME" ] && echo "search $DOMAINNAME" >> $tmp
+ cat $tmp > /etc/resolv.conf
+ rm -f $tmp
+ fi
+}
+
+set_dns() {
+ gui_input "Set a new (space seperated) list of DNS Servers" "$DNSSRV" "DNSSRV"
+ DNSSRV="`echo $DNSSRV`" ; [ -z "$DNSSRV" ] && DNSSRV="none"
+
+ tmp="`mktemp`" ; grep -v '^nameserver\b' /etc/resolv.conf > $tmp
+ for x in $DNSSRV ; do
+ [ "$x" != "none" ] && echo "nameserver $x" >> $tmp
+ done
+ cat $tmp > /etc/resolv.conf
+ rm -f $tmp
+}
+
+HOSTNAME="`hostname`"
+DOMAINNAME="`hostname -d 2> /dev/null`"
+
+tmp="`mktemp`"
+grep '^nameserver ' /etc/resolv.conf | tr '\t' ' ' | tr -s ' ' | \
+ sed 's,^nameserver *\([^ ]*\),DNSSRV="$DNSSRV \1",' > $tmp
+DNSSRV='' ; . $tmp ; DNSSRV="`echo $DNSSRV`"
+[ -z "$DNSSRV" ] && DNSSRV="none" ; rm -f $tmp
+
+main_detailed() {
+ while
+ cmd="gui_menu network 'Network Configuration'"
+
+ cmd="$cmd 'Static hostname: $HOSTNAME' 'set_name HOSTNAME'"
+ cmd="$cmd 'Static domainname: $DOMAINNAME' 'set_name DOMAINNAME'"
+ cmd="$cmd 'Static DNS-Server: $DNSSRV' 'set_dns' '' ''"
+
+ cmd="$cmd 'Configure runlevels for network service'"
+ cmd="$cmd '$STONE runlevel edit_srv network'"
+ cmd="$cmd '(Re-)Start network init script'"
+ cmd="$cmd '$STONE runlevel restart network'"
+ cmd="$cmd '' ''"
+
+ cmd="$cmd 'View/Edit /etc/resolv.conf file' 'gui_edit /etc/resolv.conf /etc/resolv.conf'"
+ cmd="$cmd 'View/Edit /etc/hosts file' 'gui_edit /etc/hosts /etc/hosts'"
+ cmd="$cmd 'View/Edit /etc/network/config file' 'gui_edit /etc/network/config /etc/network/config'"
+
+ cmd="$cmd '' ''"
+
+ cmd="$cmd 'Read the /etc/network/README file' 'gui_edit /etc/network/README /etc/network/README'"
+
+ eval "$cmd"
+ do : ; done
+}
+
+main() {
+ while
+ cmd="gui_menu network 'Network Configuration'"
+
+ cmd="$cmd 'Just edit /etc/network/config' 'gui_edit /etc/network/config /etc/network/config'"
+ cmd="$cmd 'Read the /etc/network/README file' 'gui_edit /etc/network/README /etc/network/README'"
+ cmd="$cmd 'Detailed Networking configuration' 'exec $0 network main_detailed'"
+
+ eval "$cmd"
+ do : ; done
+}
+
--- package/base/rocknet/rocknet_config (Revision 0)
+++ package/base/rocknet/rocknet_config (Revision 54)
@@ -0,0 +1,24 @@
+#
+# ROCKNET Example Config File
+#
+# The file /etc/network/README contains a detailed description of most
+# available config directives for this file.
+#
+# Check out the modules in /etc/network/modules/* directly for information
+# about the not so-well documented directives (such as directives from 3rd
+# party modules).
+#
+
+
+### automatically set up interface eth0 on startup
+# auto eth0
+
+### interface eth0 is configured using DHCP
+# interface eth0
+# dhcp
+
+### interface eth1 is configured using a static IP
+# interface eth1
+# ip 192.168.100.99/24
+# gw 192.168.100.1
+
--- package/base/rocknet/rocknet_modules_dns.sh (Revision 0)
+++ package/base/rocknet/rocknet_modules_dns.sh (Revision 54)
@@ -0,0 +1,32 @@
+
+dns_init() {
+ if isfirst "dns"; then
+ addcode up 4 1 "echo -n "" > /etc/resolv.conf"
+ fi
+}
+
+public_nameserver() {
+ addcode up 4 5 "echo nameserver $1 >> /etc/resolv.conf"
+ dns_init
+}
+
+public_search() {
+ if ! isfirst "dns_search"; then
+ error "Keyword >>search<< not allowed multiple times."
+ return
+ fi
+
+ addcode up 4 4 "echo search $* >> /etc/resolv.conf"
+ dns_init
+}
+
+public_hostname() {
+ addcode up 9 5 "hostname $1"
+}
+
+public_domainname() {
+ # THIS IS A HACK
+ addcode up 9 5 "sed 's/`hostname`\..* /`hostname`.$1 /' /etc/hosts > \
+ /etc/hosts.new ; mv /etc/hosts{.new,}"
+}
+
--- package/base/rocknet/rocknet_modules_script.sh (Revision 0)
+++ package/base/rocknet/rocknet_modules_script.sh (Revision 54)
@@ -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"
+}
+
--- package/base/rocknet/network.init (Revision 0)
+++ package/base/rocknet/network.init (Revision 54)
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# --- 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/sysfiles/network.init
+# ROCK Linux is Copyright (C) 1998 - 2006 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 https://rocklinux.org/ and the Documentation/TEAM
+# file for details.
+#
+# --- ROCK-COPYRIGHT-NOTE-END ---
+#
+# Desc: setting up network devices
+# Runlevel: 15 rcX rc3 rc4 rc5
+#
+
+main_begin
+
+ block_begin(start, `Setting up network devices.')
+ block_split(`Renaming network interfaces')
+ if [ -e /etc/iftab ] ; then
+ check(`ifrename')
+ else
+ true
+ fi
+
+ oldprof="$(cat /etc/network/profile 2>/dev/null)"
+ oldprof=${oldprof:-default}
+ if [ -n "$2" ]; then
+ echo $2 > /etc/network/profile
+ profile="$(cat /etc/network/profile 2>/dev/null)"
+ profile=${profile:-default}
+ echo "Active network profile is now $profile (was: $oldprof)."
+ elif [ -x /etc/network/getprofile ]; then
+ echo "Running network profile autodetection ..."
+ /etc/network/getprofile
+ profile="$(cat /etc/network/profile 2>/dev/null)"
+ profile=${profile:-default}
+ echo "Active network profile is now $profile (was: $oldprof)."
+ else
+ profile="$oldprof"
+ fi
+ check(`/etc/network/rocknet $profile auto up')
+ block_end
+
+ block_begin(stop, `Shutting down network devices.')
+ profile="$(cat /etc/network/profile 2>/dev/null)"
+ profile=${profile:-default}
+ check(`/etc/network/rocknet $profile auto down')
+ block_end
+
+ block_begin(restart, `Reconfiguring network devices.')
+ check(`$0 stop')
+ check(`$0 start $2')
+ block_end
+
+main_end
+
--- package/base/rocknet/ifup.sh (Revision 0)
+++ package/base/rocknet/ifup.sh (Revision 54)
@@ -0,0 +1,57 @@
+#!/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 ] [ -force ]"
+ exit 1
+}
+
+force=0
+
+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}
+
+# 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 ',' "$if($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 ',' "$if($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
+
--- package/base/rocknet/rocknet.sh (Revision 0)
+++ package/base/rocknet/rocknet.sh (Revision 54)
@@ -0,0 +1,120 @@
+#!/bin/bash
+
+rocknet_debug=0
+rocknet_base="/etc/network"
+rocknet_tmp_base="/var/run/rocknet"
+
+[ -d $rocknet_tmp_base ] || mkdir -p $rocknet_tmp_base
+
+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
+global=1
+retcode=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
+
+pmatched=0 # some profile matched ?
+imatched=0 # some interface matched ?
+
+#
+# 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 "$*"
+ retcode=1
+}
+
+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
+do
+ (( lineno++ ))
+ if [ -n "$cmd" ]; then
+ cmd="${cmd//-/_}"
+ para="$( echo "$para" | sed 's,[\*\?],\\&,g' )"
+ if declare -f public_$cmd > /dev/null
+ then
+ # 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
+ fi
+done < <( sed 's,\(^\|[ \t]\)#.*$,,' < "$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
+)
+
+[ "$pmatched" = 0 -a "$profile" != "default" ] && \
+ error "Unknown profile: '$profile'"
+[ "$pmatched" = 1 -a "$imatched" = 0 ] && \
+ error "Unknown interface for profile: '$interface'"
+
+exit $retcode
Eigenschaftsänderungen: package/base/rocknet/rocknet.sh
___________________________________________________________________
Name: svn:executable
+ *
[Download this patch]