- $Id: AUTHORS,v 1.5 1999/12/11 12:45:13 misiek Exp $
+ $Id: AUTHORS,v 1.6 2001/05/15 16:03:33 baggins Exp $
-In alphabetical order:
+MAINTAINERS
-Artur Frysiak <wiget@pld.org.pl>
- - automake/autoconf support
- - rc-scripts.spec maintaning
+Maintainer of development version (so called ,,totalnew'')
+is Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
-Tomasz K³oczko <kloczek@wun.zie.pg.gda.pl>
- - automake/autoconf updates
- - rc-scripts.spec updates
+AUTHORS/CREDITS
-Jacek Konieczny <jajcus@zeus.polsl.gliwice.pl>
- - LDAP support
+Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+ networking functions, iproute2 support,
+ national language support, scripts for
+ controling tunnels and bridges
-Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
- - networking functions
- - iproute2 support
- - national language support
- - scripts for controling tunnels
+Artur Frysiak <wiget@pld.org.pl>
+ automake/autoconf support, bug fixes
-Grzegorz Stanislawski <stangrze@open.net.pl>
- - great ppp scripts
- - prefix/netmask converting functions
- - bug fixes
+Bartosz Waszak <waszi@pld.org.pl>
+ fixes, devfsd support
+
+Grzegorz Stanislawski <stangrze@open.net.pl>
+ ppp scripts, prefix/netmask converting
+ functions, bug fixes
+
+Jacek Konieczny <jajcus@zeus.polsl.gliwice.pl>
+ LDAP support
+
+Jan Rêkorajski <baggins@pld.org.pl>
+ general, ipv6 and dhcp fixes
+
+Micha³ Kochanowicz <mkochano@pld.org.pl>
+ fixes, progress()
+
+Pawe³ Wilk <siefca@pl.qmail.org>
+ executing scripts on iface up/down
+
+Robert ¦laski <robin@atm.com.pl>
+ ATM support
+
+Sebastian Zagrodzki <s.zagrodzki@mimuw.edu.pl>
+ many fixes
+
+Tomasz K³oczko <kloczek@wun.zie.pg.gda.pl>
+ automake/autoconf updates, bug fixes
+
+Mandrake Software
+RedHat Software, Inc.
-Other guys ....
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
END OF TERMS AND CONDITIONS
\f
- Appendix: How to Apply These Terms to Your New Programs
+ How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Also add information on how to contact you by electronic and paper mail.
--- /dev/null
+ READ THIS BEFORE CHANGEING SOMETHING IN RC-SCRIPTS PACKAGE
+ Arkadiusz Miskiewicz <misiek@pld.org.pl>
+ $Id: DEVELOPMENT,v 1.2 2001/05/15 16:05:05 baggins Exp $
+
+1)
+ consult all major changes with people on pld-rc-scripts@pld.org.pl
+mailing list. This is very important.
+
+2)
+ use 'typeset' for local variables in functions for example:
+
+function_ble ()
+{
+typeset qw er
+qw=$(tty)
+er=/dev/console
+echo "$qw $er"
+}
+
+3)
+ use $() instead `` for command execution for example
+
+something=$(whoami)
+instead of
+something="`whoami`"
+
+4)
+ consider using typeset -i variable for integer variables
+
+5) don't use sed ! It only causes one more Requires.
+ Use awk ' { gsub(/pattern/,"replaced"); print $0; } ' for that.
+ Also try replase grep calls with awk calls.
+
+5)
+ (PL) Tlumaczac komunikaty na PL nalezy uzywac formy bezosobowej np:
+
+uruchamianie uslugi
+zamiast
+uruchamiam usluge
+
#
-# $Id: Makefile.am,v 1.6 2000/05/07 18:59:59 siefca Exp $
+# $Id: Makefile.am,v 1.7 2001/05/15 16:03:33 baggins Exp $
#
SUBDIRS = src ppp sysconfig rc.d doc po
sysconf_DATA = \
adjtime \
- inittab
+ inittab \
+ modules \
+ sysctl.conf
profiledir = @sysconfdir@/profile.d
- $Id: NEWS,v 1.6 2000/03/27 16:07:48 misiek Exp $
+ $Id: NEWS,v 1.7 2001/05/15 16:03:33 baggins Exp $
+
+Features of rc-scripts:
- National Language Support; currently only english and polish
supported. Translators needed.
-
-- PREFIX support (instead of NETMASK) - CIDR specification.
+- LDAP support (for interfaces database). NYF.
+- Full IPv6 support (including PPP).
-- LDAP support (for interfaces database).
+New in 0.3.0:
-- Full IPv6 support (including PPP).
+- fourtun (v4 over v6) tunneling support.
+- support for more dhcp clients (dhcpcd, dhclient, dhcpxd, pump)
+- Logical Volume Manager (LVM) support.
+- /etc/sysctl.conf support.
+- queueing discipline support.
+- IPv6 boot method (v4compat).
+- bridge configuration support.
+- rc.modules scipt and /etc/modules config
+- new ifcfg- config syntax
+
+Note:
+NYF - not yet finished.
+ $Id: README,v 1.7 2001/05/15 16:03:33 baggins Exp $
+
+rc-scripts is a derivative of the initscripts 3.78 release by
+RedHat Software, but with bugs removed and newer features added.
+
+You need packages such as: mktemp, modutils (at least 2.1.121),
+textutils, sh-utils, mawk (at least 1.3.3; other awk
+implementations are not tested), procps, sed, e2fsprogs,
+gettext to use rc-scripts.
+
+If you want to use networking with rc-scripts you need
+compile few features such as:
+
+Networking options --->
+ [*] Kernel/User netlink socket
+ [*] Routing messages
+
+into your kernel and install Alexey Kuznetsov iproute2 package.
+To use IPv6 networking you should compile:
+
+Networking options --->
+ <*/M> The IPv6 protocol (EXPERIMENTAL)
+ [*] IPv6: enable EUI-64 token format
+ [*] IPv6: disable provider based addresses
+
+too. IPX support require ncpfs package; fourtun (v4 over v6
+tunneling) support require fourtun package and fourtun kernel
+module; bridge support require bridge-utils.
+
+Also you should know that format of interface configuration
+files is totally different from these used in RedHat/Mandrake
+initscripts.
+
+If you have some bug reports or suggestions please send email
+to rc-scripts maintainers at <pld-rc-scripts@pld.org.pl> or
+use our Bug Tracking System ( http://bugs.pld.org.pl/ ).
+
+--
+PLD GNU/Linux rc-scripts Team,
- $Id: README,v 1.6 2000/03/15 15:07:46 misiek Exp $
-
-CRITICAL THINGS
-If you want use this rc-scripts remember to compile:
-- Kernel/User netlink socket
-- Routing messages
-support into your kernel. This is very important ! Without
-this network scripts will fail.
-
-STANDARD THINGS
-If you want use IPv6 networking remember to compile:
-- The IPv6 protocol (EXPERIMENTAL)
-- IPv6: enable EUI-64 token format
-- IPv6: disable provider based addresses
-into your kernel (last two options are optional) !
-$Id: TODO,v 1.13 2001/03/05 17:35:01 misiek Exp $
+$Id: TODO,v 1.14 2001/05/15 16:03:33 baggins Exp $
-TODO List:
+Features missing:
+- IPSec (freeswan) support
+- NLS with national characters support
+Important:
+- don't set any flags automaticly; always follow user
+ suggestion (multicast, arp)
+- MTU for ethernet
+- merge baggins changes in atm-rc (added support for RFC1483/2684 Bridged
+ protocol)
+
+Not realy important but mayby nice:
+- Add checing for preveliges during restarting
+ and if thay are not enought say fuck off in a
+ nice way.
+
+
+Other:
+- maybe merge ATM rc scripts
+
+We are waiting for suggestions.
#!/bin/sh
-# $Id: autogen.sh,v 1.5 2000/01/31 14:30:11 misiek Exp $
+# $Id: autogen.sh,v 1.6 2001/05/15 16:03:33 baggins Exp $
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
-PKG_NAME="PLD/Linux rc-scripts"
+PKG_NAME="PLD GNU/Linux rc-scripts"
(test -f $srcdir/configure.in \
&& test -d $srcdir/src) || {
-dnl $Id: configure.in,v 1.38 2001/05/13 17:10:14 baggins Exp $
+dnl $Id: configure.in,v 1.39 2001/05/15 16:03:33 baggins Exp $
AC_INIT()
PACKAGE=rc-scripts
-VERSION=0.2.11
-ALL_LINGUAS="pl de"
+VERSION=0.3.0
+ALL_LINGUAS="pl"
SHSCRIPTS="rc.d/rc \
rc.d/init.d/allowlogin \
rc.d/rc.init \
rc.d/rc.local \
rc.d/rc.shutdown \
- rc.d/rc.sysinit"
+ rc.d/rc.sysinit \
+ sysconfig/network-scripts/ifdown \
+ sysconfig/network-scripts/ifdown-br \
+ sysconfig/network-scripts/ifdown-post \
+ sysconfig/network-scripts/ifdown-ppp \
+ sysconfig/network-scripts/ifdown-sl \
+ sysconfig/network-scripts/ifup \
+ sysconfig/network-scripts/ifup-aliases \
+ sysconfig/network-scripts/ifup-br \
+ sysconfig/network-scripts/ifup-ipx \
+ sysconfig/network-scripts/ifup-plip \
+ sysconfig/network-scripts/ifup-post \
+ sysconfig/network-scripts/ifup-ppp \
+ sysconfig/network-scripts/ifup-routes \
+ sysconfig/network-scripts/ifup-sl \
+ sysconfig/network-scripts/tnldown \
+ sysconfig/network-scripts/tnlup \
+ "
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
initlog \- log messages and events to the system logger
.SH SYNOPSIS
.B initlog
-[\-cefnprs] [\-\-cmd=ARG] [\-\-event=ARG] [\-\-facility=ARG]
+[\-cefnpqrs] [\-\-cmd=ARG] [\-\-event=ARG] [\-\-facility=ARG]
[\-\-name=ARG] [\-\-priority=ARG] [\-\-run=ARG] [\-\-string=ARG]
.SH DESCRIPTION
\fBinitlog\fR logs messages and events to the system logger.
-It is mainly designed for use in init scripts.
+It is mainly designed for use in init scripts. initlog
+reads a configuration file
+.I /etc/initlog.conf
+by default, to determine its settings. Any line preceded with a
+.I #
+is a comment, and the following configuration directives
+are recognized:
+.TP
+.I facility <logging facility>
+Sets the default logging facility
+.TP
+.I priority <logging priority>
+Sets the default logging priority
+.TP
+.I ignore <regexp>
+Messages that match the regular expression will not be logged.
+.TP
+initlog behavior can also be configured by command-line options.
.SS OPTIONS
.TP
Log at the specified syslog priority. The default
is \fBnotice\fR (see syslog(3)).
.TP
+.I "\-q"
+Do not print the program's output, unless it exits
+with a non-zero exit code.
+.TP
.I "\-r, \-\-run=[program]"
Execute the specified program, with an open file
descriptor so that the program can pass back
commands to initlog.
.TP
-.I "\-s, \-\-string=[string]
+.I "\-s, \-\-string=[string]"
Log the specified string to the logger.
+.TP
+.I "\-\-conf=[file]"
+Specifies an alternate configuration file.
+.SH FILES
+.I /etc/initlog.conf
.SH "SEE ALSO"
syslog(3), logger(1)
-$Id: net-scripts.txt,v 1.4 1999/10/07 00:49:51 kloczek Exp $
+$Id: net-scripts.txt,v 1.5 2001/05/15 16:03:36 baggins Exp $
rc-scripts files:
========================================
/etc/sysconfig/network-scripts/ifup-post
- Called when any network device EXCEPT a SLIP device comes
+ Called when any network device EXCEPT a SLIP (with dip) device comes
up. Calls /etc/sysconfig/network-scripts/ifup-routes to
bring up static routes that depend on that device. Calls
/sbin/network-scripts/ifup-aliases to bring up
Base items:
DEVICE=<name of physical device (except dynamically-allocated PPP
devices where it is the "logical name")
- IPADDR=
- IPV6ADDRS=<blank separated list of ipv6 addresses>
- PREFIX=
+ IPADDR= IP_AOPTS= IP_ROPTS=
+ IPADDR1= IP_AOPTS1= IP_ROPTS1=
+ IP_ADDRx= IP_AOPTSx= IP_ROPTSx=
+ IP4_PRIM_IF= IP4_SRC_IF=
+ IP6_PRIM_IF= IP6_SRC_IF=
GATEWAY=
ONBOOT=yes|no
USERCTL=yes|no
- BOOTPROTO=none|bootp|dhcp
+ BOOTMETHOD=none|bootp|dhcp|pump
- If BOOTPROTO is not "none", then the only other item that
+ If BOOTMETHOD is not "none", then the only other item that
must be set is the DEVICE item; all the rest will be determined
by the boot protocol. No "dummy" entries need to be created.
- Base items being deprecated:
- NETWORK=<will be calculated automatically with ifcalc>
- BROADCAST=<will be calculated automatically with ifcalc>
-
Ethernet-only items:
{IPXNETNUM,IPXPRIMARY,IPXACTIVE}_{802_2,802_3,ETHERII,SNAP}
configuration matrix for IPX. Only used if IPX is active.
In principal, I'm not aware of anything that would keep
the logical PPP device names from being "worldnet" or
"myISP" instead of ppp0-pppN)
- REMIP=<remote ip address, normally unspecified>
+ REMIP=<remote ip4 address, normally unspecified>
+ REMIP6=<remote ip6 address, normally unspecified>
MTU=
MRU=
DISCONNECTTIMEOUT=<number of seconds, default currently 5>
List of variables which should be exported to chat script.
Used mostly for passing USERNAME and PASSWORD into it. (see below)
(PLD rc-scripts specific option)
+ PEERDNS=yes|no
+ IPV6_PPP=yes|no
+ use IPv6 for ppp
+ IPV6_CP_USEV4=yes|no
+ use local IPv4 mapped addresses as IPv6 addresses
+ IPV6_CP_PERSISTENT=yes|no
+ use EUI-48 addresses as IPv6 addresses
+ or by default use address specified by IP6_PRIM_IF and REMIP6
<anything>=<anything>
Variable name and it's value for use by chat script.
Note: You don't have to define variables here, if they are defined
-$Id: sysconfig.txt,v 1.3 1999/07/13 12:49:35 misiek Exp $
+$Id: sysconfig.txt,v 1.4 2001/05/15 16:03:36 baggins Exp $
Files in /etc/sysconfig
=======================
/etc/sysconfig/network:
NETWORKING=yes|no
- IPV6NETWORKING=yes|no
+ IPV4_NETWORKING=yes|no
+ IPV6_NETWORKING=yes|no
HOSTNAME=<fqdn by default, but whatever hostname you want>
Note: for compatibility with some old software people might
install (like trn), the /etc/HOSTNAME file should contain the
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
-# $Id: inittab,v 1.4 1999/07/31 11:24:17 misiek Exp $
+# $Id: inittab,v 1.5 2001/05/15 16:03:33 baggins Exp $
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
7:2345:respawn:/sbin/mingetty tty7
8:2345:respawn:/sbin/mingetty tty8
+# Examples
+# 9:2345:respawn:/sbin/mingetty --mono tty9
+# 10:2345:respawn:/sbin/mingetty --remote-host=some.host.in.net.pl tty10
+
# Run xdm in runlevel 5
#x:5:respawn:/usr/bin/X11/xdm -nodaemon
#!/bin/csh
#
-# $Id: lang.csh,v 1.3 1999/12/15 18:41:05 misiek Exp $
+# $Id: lang.csh,v 1.4 2001/05/15 16:03:33 baggins Exp $
#
test -f /etc/sysconfig/i18n
setenv TERM=$SYSTERM
endif
-# # Set console font map.
-# if ($?UNIMAP) then
-# loadunimap $UNIMAP
-# endif
+ if ($?_XKB_CHARSET) then
+ setenv _XKB_CHARSET
+ endif
- if ($?SYSFONTACM) then
- switch ($SYSFONTACM)
- case iso01*|iso02*|iso15*|koi*|latin2-ucw*:
- if ( "$TERM" == "linux" ) then
- if ( ls -l /proc/$$/fd/0 2>/dev/null | grep -- '-> /dev/tty[0-9]*$' >/dev/null 2>&1) then
- echo -n -e '\033(K' > /proc/$$/fd/0
- endif
- endif
- breaksw
- endsw
+ if ($?INPUTRC) then
+ setenv INPUTRC
endif
- if ($?SYSTERM) then
- switch ($SYSTERM)
- case linux-lat:
- setenv LESSCHARSET=latin1
- setenv INPUTRC=/etc/inputrc
- breaksw
- endsw
+ if ($?LESSCHARSET) then
+ setenv LESSCHARSET
+ else if ($TERM == linux-lat) then
+ setenv LESSCHARSET latin1
endif
+
endif
#
# Copyright (c) 1999 Free Software Fundation, Inc.
# Artur Frysiak <wiget@pld.org.pl>
-# $Id: makepot.pl,v 1.4 2000/06/25 14:40:35 waszi Exp $
+# $Id: makepot.pl,v 1.5 2001/05/15 16:03:33 baggins Exp $
+# Changes:
+# 2000-08-25 Arkadiusz Miskiewicz <misiek@pld.org.pl>
+# - support for $(nls "xyz"), progress "xyz" and '' instead of "".
#
my %pot;
open (POTSRC, "< " . $filename) || die "Can't open " . $filename;
foreach (<POTSRC>) {
chop;
- if (/(run_cmd|nls|show)\s[\sa-zA-Z0-9-]*"(?!\`nls\s\")([^"]*)"/g) {
+ if ((/(run_cmd|nls|show|progress)\s[\sa-zA-Z0-9-]*"(?!(\`|\$\()nls\s\")([^"]*)"/g) or (/(run_cmd|nls|show|progress)\s[\sa-zA-Z0-9-]*'(?!(\`|\$\()nls\s\")([^"]*)'/g)) {
# potentry($1,$lnr,$filename) if defined $1;
potentry($2,$lnr,$filename) if defined $2;
potentry($3,$lnr,$filename) if defined $3;
--- /dev/null
+# /etc/modules: kernel modules to load at boot time.
+# $Id: modules,v 1.2 2001/05/15 16:05:05 baggins Exp $
+#
+# This file should contain the names of kernel modules that are
+# to be loaded at boot time, one per line. Comments begin with
+# a `#', and everything on the line after them are ignored.
+
+# loop
-# $Id: rc-scripts.spec.in,v 1.51 2001/03/05 17:34:13 misiek Exp $
+# $Id: rc-scripts.spec.in,v 1.52 2001/05/15 16:03:33 baggins Exp $
Summary: inittab and /etc/rc.d scripts
Summary(de): inittab und /etc/rc.d Scripts
Summary(fr): inittab et scripts /etc/rc.d
%attr(755,root,root) %dir %{_sysconfdir}/sysconfig
%attr(755,root,root) %dir %{_sysconfdir}/sysconfig/interfaces
%attr(755,root,root) %dir %{_sysconfdir}/sysconfig/interfaces/data
+%attr(755,root,root) %dir %{_sysconfdir}/sysconfig/interfaces/up.d
+%attr(755,root,root) %dir %{_sysconfdir}/sysconfig/interfaces/down.d
+%attr(750,root,root) %{_sysconfdir}/sysconfig/interfaces/up.d/*
+%attr(750,root,root) %{_sysconfdir}/sysconfig/interfaces/down.d/*
%attr(755,root,root) %dir %{_sysconfdir}/ppp
%attr(755,root,root) %{_sysconfdir}/ppp/*
%attr(755,root,root) %dir %{_sysconfdir}/sysconfig/network-scripts
%config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/sysconfig/timezone
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/adjtime
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/inittab
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/initlog.conf
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules
%attr(640,root,root) %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/sysconfig/system
%{_mandir}/man1/*
rc_SCRIPTS = \
rc \
rc.local \
+ rc.modules \
rc.sysinit \
rc.shutdown \
rc.init
# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
#
-# $Id: functions,v 1.63 2001/05/13 17:10:17 baggins Exp $
+# $Id: functions,v 1.64 2001/05/15 16:03:38 baggins Exp $
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Hacked by: Greg Galloway and Marc Ewing
INIT_COL=67
# Source configuration if available - may override default values
-[ -f /etc/sysconfig/system ] && . /etc/sysconfig/system
+[ -r /etc/sysconfig/system ] && . /etc/sysconfig/system
[ -z "$COLUMNS" ] && COLUMNS=80
# A function to start a program (now it's usefull on read-only filesystem too)
daemon()
{
- typeset nicelevel exit_code errors prog
- typeset -i nicelevel=0
+ typeset errors="" prog=""
typeset -i exit_code=0
[ -z "$DEFAULT_SERVICE_RUN_NICE_LEVEL" ] && DEFAULT_SERVICE_RUN_NICE_LEVEL=0
# Test syntax. Don't use -o instead || here - this will broke ksh --misiek
success () { return 0; }
failure () { return 1; }
-# Will be removed in the future
+# TO BE REMOVED SOON. --misiek
msg_Network_Down () { msg_network_down "$*"; }
msg_Already_Running () { msg_already_running "$*"; }
msg_Not_Running () { msg_not_running "$*"; }
#
-# $Id: functions.network,v 1.48 2001/05/13 18:39:36 kloczek Exp $
+# $Id: functions.network,v 1.49 2001/05/15 16:03:38 baggins Exp $
#
# This is not a shell script; it provides functions to network scripts
# that source it.
# This will work only after starting interface to which LDAP server is connected
find_ldap_interfaces()
{
-is_yes "$USE_LDAP" && [ -x /usr/bin/ldapsearch ] || exit 1
+typeset BSWITH QUERY
+is_no "$USE_LDAP" && return 0
+
if [ -n "$LDAP_BASE_DN" ] ; then
BSWITCH="-b$LDAP_BASE_DN"
else
# find aliases for device
find_ldap_aliases()
{
-is_yes "$USE_LDAP" && [ -x /usr/bin/ldapsearch ] || exit 1
+typeset BSWITH QUERY
+is_no "$USE_LDAP" && return 0
+
if [ -n "$LDAP_BASE_DN" ] ; then
BSWITCH="-b$LDAP_BASE_DN"
else
get_ldap_config ()
{
-if is_yes "$USE_LDAP" && [ -x /usr/bin/ldapsearch ]; then
- exit 1
-fi
+typeset BSWITH QUERY IPV6_ADDR IPADDR_ALIASES FIELD VALUE VAR
+is_no "$USE_LDAP" && return 0
# Initialise fields which can have multiple values:
IPV6_ADDR=""
fi
}
-# PLD/Linux network functions
+# PLD GNU/Linux network functions
# Copyright (C) 1999, 2000 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
-# All functions must be called "name_of_function on" or "name_of_function off"
-
# Setup Network Address Translation (NAT)
setup_nat()
{
+typeset src via dst
if [ -r /etc/sysconfig/static-nat ]; then
grep "^[0-9]" /etc/sysconfig/static-nat | while read src via dst; do
if [ "$1" = "on" ]; then
fi
}
-# network router discovery daemon
-rdisc()
+# Setup static ARP
+static_arp()
{
-if is_yes "$IPV6_NETWORKING"; then
- [ -z "$IPV6_RDISC_MODE" ] && IPV6_RDISC_MODE=host
- if is_yes "$IPV6_RDISC"; then
- RDISC_OPTS="-fs"
- case "$1" in
- on|start)
- [ "$IPV6_RDISC_MODE" = "router" ] && \
- RDISC_OPTS="$RDISC_OPTS -r"
- run_cmd "Starting network router discovery daemon" \
- /usr/sbin/rdisc $RDISC_OPTS
- ;;
- off|stop)
- msg_stopping "network router discovery daemon"
- killproc rdisc -HUP
- ;;
- esac
- fi
+typeset rc arpdev host hwaddr flags neflags
+if is_yes "$STATIC_ARP" && [ -r /etc/ethers ]; then
+ if [ -x /sbin/arp ]; then
+ run_cmd "Setting static ARP entries" /sbin/arp -f /etc/ethers
+ else
+ show "Setting static ARP entries"; busy
+ rc=0
+ arpdev=$(ip link show | awk -F':' '(/UP/) && ! (/NOARP/) && ! (/lo:/) && ! (/NONE:/) { print $2; exit }')
+ if [ -z "$arpdev" ]; then
+ rc=1
+ else
+ # ip supports only ip addresses
+ grep "^[0-9]" /etc/ethers | \
+ while read host hwaddr flags; do
+ case "$flags" in
+ *temp*)
+ neflags="nud stale"
+ ;;
+ *)
+ neflags="nud permanent"
+ ;;
+ esac
+ if ! /sbin/ip neigh add $host lladdr $hwaddr $neflags dev $arpdev; then
+ rc=1
+ fi
+ done
+ fi
+ if [ "$rc" -gt 0 ]; then
+ fail
+ fi
+ fi
fi
}
-# proc_net <zmien> <start/stop> <co ustaw> <co default> <nazwa_zmiennej> [komunikat]
-# proc_net ipv4/ip_forward start 1 0 IPV4_FORWARDING "IPv4 forwarding"
-#
-# wy¶wietli siê komunikat "Setting IPv4 forwarding to 1"
-# je¶li nie podano komunikatu nic nie jest wy¶wietlane
-
-proc_net()
+static_rarp()
{
-WHAT="$1"
-TODO="$2"
-SET="$3"
-DEF="$4"
-VAR="$5"
-MESSAGE="$6"
-eval VARD=\$${VAR}
-
-if [ -n "$VARD" -a -e /proc/sys/net/$WHAT ]; then
- if [ "$TODO" = "start" ]; then
- is_no "$VARD" && [ "$SET" = "1" ] && SET="$(($SET - 1))"
- is_yes "$VARD" && [ "$SET" = "0" ] && SET="$(($SET + 1))"
- if [ -n "$MESSAGE" ]; then
- show "`nls 'Setting %s to %s' "$MESSAGE" "$SET"`"; busy
- if (echo "$SET" > /proc/sys/net/$WHAT) 2> /dev/null; then
- deltext; ok
- else
- deltext; fail
- fi
- else
- echo "$SET" > /proc/sys/net/$WHAT
- fi
- elif [ "$TODO" = "stop" ]; then
- if [ -n "$MESSAGE" ]; then
- show "`nls 'Setting %s to %s' "$MESSAGE" "$DEF"`"; busy
- if (echo "$DEF" > /proc/sys/net/$WHAT) 2> /dev/null; then
- deltext; ok
- else
- deltext; fail
- fi
- fi
+if is_yes "$STATIC_RARP"; then
+ if [ ! -e /proc/net/rarp ]; then
+ _modprobe single -k rarp
+ fi
+ if [ -r /etc/ethers -a -x /sbin/rarp ]; then
+ /sbin/rarp -f /etc/ethers
fi
fi
-return 0
}
-ipv4_dynamic_ip_patch()
+setup_forwarding ()
{
-if [ "$IPV4_DYNAMIC_IP_PATCH" != "default" -a -n "$IPV4_DYNAMIC_IP_PATCH" ] ||
- [ ! -e /proc/sys/net/ipv4/ip_dynaddr ]; then
- case "$IPV4_DYNAMIC_IP_PATCH_VALUE" in
- [1-9]) ;;
- *) IPV4_DYNAMIC_IP_PATCH_VALUE=7 ;;
- esac
+if is_yes "$IPV4_NETWORKING" && is_yes "$IPV4_FORWARDING" && [ -f /proc/sys/net/ipv4/ip_forward ];
+then
+ if [ "$1" = "on" ]; then
+ run_cmd "Enabling IPv4 packed forwarding" sysctl -w net.ipv4.ip_forward=1
+ else
+ run_cmd "Disabling IPv4 packed forwarding" sysctl -w net.ipv4.ip_forward=0
+ fi
+fi
- if is_yes "$IPV4_DYNAMIC_IP_PATCH" && [ "$1" = "on" ]; then
- show "Enabling dynamic IP patch"
- busy
- if echo $IPV4_DYNAMIC_IP_PATCH_VALUE > /proc/sys/net/ipv4/ip_dynaddr; then
- deltext
- ok
- else
- deltext
- fail
- fi
+if is_yes "$IPV6_NETWORKING" && is_yes "$IPV6_FORWARDING" && [ -f /proc/sys/net/ipv6/conf/all/forwarding ];
+then
+ if [ "$1" = "on" ]; then
+ run_cmd "Enabling IPv6 packed forwarding" sysctl -w net.ipv6.conf.all.forwarding=1
else
- show "Disabling dynamic IP patch"
- busy
- if echo 0 > /proc/sys/net/ipv4/ip_dynaddr; then
- deltext
- ok
- else
- deltext
- fail
- fi
+ run_cmd "Disabling IPv6 packed forwarding" sysctl -w net.ipv6.conf.all.forwarding=0
fi
fi
}
-ipv4_local_port_range()
+# Set up all IP && IP parameter variables
+setup_ip_param ()
{
-if [ "$IPV4_LOCAL_PORT_RANGE" != "default" -a -n "$IPV4_LOCAL_PORT_RANGE" ] || \
- [ ! -e /proc/sys/net/ipv4/ip_local_port_range ]; then
- if is_yes "$IPV4_LOCAL_PORT_RANGE" && [ "$1" = "on" ]; then
- show "Setting local port range"; busy
- if echo "$IPV4_LOCAL_PORT_RANGE" > /proc/sys/net/ipv4/ip_local_port_range; then
- deltext
- ok
- else
- deltext
- fail
- fi
- else
- show "Setting default local port range"; busy
- if echo "1024 4999" > /proc/sys/net/ipv4/ip_local_port_range; then
- deltext
- ok
- else
- deltext
- fail
- fi
- fi
+# detect network device type (ie. dummy, eth for dummy0, eth0 ..)
+DEVICETYPE=$(echo $DEVICE | awk ' { gsub(/[0-9]*$/,NUL); print $0 } ')
+# real name of device (ie. is eth0 for eth0,eth0:1,eth0:alias)
+DEVICE=$(echo $DEVICE | awk ' { gsub(/:.*$/,NUL); print $0 } ')
+
+eval IP4ADDR="\$IPADDR${IP4_PRIM_IF:-}"
+eval IP4ADDROPT="\$IP_AOPTS${IP4_PRIM_IF:-}"
+eval IP4ROUTEOPT="\$IP_ROPTS${IP4_PRIM_IF:-}"
+eval IP6ADDR="\$IPV6_ADDR${IP6_PRIM_IF:-}"
+eval IP6ADDROPT="\$IPV6_AOPTS${IP6_PRIM_IF:-}"
+eval IP4SRCADDR="\$IPADDR${IP4_SRC_IF}"
+[ -n "$IP4SRCADDR" ] && IP4SRCADDR="src $IP4SRCADDR"
+eval IP6SRCADDR="\$IPADDR${IP6_SRC_IF}"
+[ -n "$IP6SRCADDR" ] && IP6SRCADDR="src $IP4SRCADDR"
+
+# If tunnel device then add onlink option in routing
+[ -n "$MODE" ] && TNLOPTS="onlink"
+
+# new rc-scripts 0.4.x option
+if [ -z "$HANDLING" ]; then
+ typeset -i HANDLING=0
+fi
+
+# set handling for bridge
+case "$DEVICETYPE" in
+ br|atm|lec)
+ HANDLING=1
+ ;;
+esac
+
+# Multicast ready devices
+if is_yes "$MULTICAST"; then
+ MULTICAST="on"
+else
+ case "$DEVICETYPE" in
+ eth|br)
+ MULTICAST="on"
+ ;;
+ *)
+ MULTICAST="off"
+ ;;
+ esac
+fi
+
+# ARP ready devices
+if is_yes "$ARP"; then
+ ARP="on"
+else
+ case "$DEVICETYPE" in
+ eth|br|lec|atm)
+ ARP="on"
+ ;;
+ *)
+ ARP="off"
+ ;;
+ esac
fi
+
}
-ipv4_anti_spoofing()
+check_device_down ()
{
-if [ "$IPV4_ANTI_SPOOFING" != "default" -a -n "$IPV4_ANTI_SPOOFING" ] || \
- [ ! -e /proc/sys/net/ipv4/conf/all/rp_filter ]; then
- if is_yes "$IPV4_ANTI_SPOOFING" && [ "$1" = "on" ]; then
- show "Setting up IP spoofing protection"; busy
- if (for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 1 > $f; done); then
- deltext
- ok
- else
- deltext
- fail
- fi
+ if (ip link show dev ${DEVICE} 2> /dev/null | grep -q UP); then
+ return 1
else
- show "Setting down IP spoofing protection"; busy
- if (for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > $f; done); then
- deltext
- ok
- else
- deltext
- fail
- fi
+ return 0
+ fi
+}
+
+setup_ip_gw_ro ()
+{
+# IPv4 gateway
+if is_yes "$IPV4_NETWORKING"; then
+ if [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
+ # set up default gateway
+ if [ -n "${GATEWAY}" ]; then
+ ip -4 route add default via ${GATEWAY} dev ${DEVICE} ${IP4SRCADDR} ${TNLOPTS}
+ DEFGW=${GATEWAY}
+ elif [ "${GATEWAYDEV}" = "${DEVICE}" ]; then
+ ip -4 route add default dev ${DEVICE} ${IP4SRCADDR} ${TNLOPTS}
+ fi
fi
fi
+
+# IPv6 gateway && IPv6 globalroute
+if is_yes "$IPV6_NETWORKING"; then
+ if is_no "${IPV6_FORWARDING}" ; then
+ if [ -z "${GATEWAY6DEV}" -o "${GATEWAY6DEV}" = "${DEVICE}" ]; then
+ # set up default gateway
+ if [ -n "${GATEWAY6}" ]; then
+ ip -6 route add default via ${GATEWAY6} dev ${DEVICE} ${IP6SRCADDR}
+ DEFGW6=${GATEWAY6}
+ elif [ "${GATEWAY6DEV}" = "${DEVICE}" ]; then
+ ip -6 route add default dev ${DEVICE} ${IP6SRCADDR}
+ fi
+ fi
+ else
+ if [ -z "${IPV6_GLOBALROUTEDEV}" -o "${IPV6_GLOBALROUTEDEV}" = "${DEVICE}" ]; then
+ # set up default route
+ if [ -n "${IPV6_GLOBALROUTEGW}" ]; then
+ ip -6 route add 2000::/3 via ${IPV6_GLOBALROUTEGW} dev ${DEVICE} ${IP6SRCADDR}
+ elif [ "${IPV6_GLOBALROUTEDEV}" = "${DEVICE}" ]; then
+ ip -6 route add 2000::/3 via dev ${DEVICE} ${IP6SRCADDR}
+ fi
+ fi
+ fi
+fi
}
#
# eg. unreachable or blackhole routes
# (c) 1999 Jacek Konieczny <jajcus@pld.org.pl>
#
-setup_routes(){
-
- if [ -f /etc/sysconfig/static-routes ]; then
- if [ "$1" = "on" -o "$1" = "yes" ] ; then
- egrep "^(none)|(any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
- /sbin/ip route add $args
- done
- else
- egrep "^(none)|(any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
- /sbin/ip route del $args 2>/dev/null
- done
- fi
+setup_routes()
+{
+typeset args
+if [ -f /etc/sysconfig/static-routes ]; then
+ if [ "$1" = "on" -o "$1" = "yes" ] ; then
+ egrep "^(none)|(any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
+ /sbin/ip route add $args
+ done
+ else
+ egrep "^(none)|(any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
+ /sbin/ip route del $args 2>/dev/null
+ done
fi
+fi
}
# Add ONLY IPv4 address (IPv6 address is added automaticly)
set_up_loopback()
{
-ip link set dev lo up arp on
-ip addr add 127.0.0.1/8 dev lo
+if is_yes "$IPV4_NETWORKING"; then
+ ip addr add 127.0.0.1/8 dev lo
+fi
+ip link set dev lo arp on up
}
set_down_loopback()
{
-ip addr flush dev lo 2> /dev/null
+ip addr flush dev lo 2>&1 | grep -v "Nothing to flush"
ip link set dev lo down
}
-static_arp()
+modprobe_net()
{
-if is_yes "$STATIC_ARP"; then
- if [ -r /etc/ethers -a -x /sbin/arp ]; then
- /sbin/arp -f /etc/ethers
- fi
+if is_yes "$IPV6_NETWORKING" && is_module "ipv6"; then
+ _modprobe single -k ipv6
fi
-}
-static_rarp()
-{
-if is_yes "$STATIC_RARP"; then
- if [ ! -e /proc/net/rarp ]; then
- modprobe rarp
- fi
- if [ -r /etc/ethers -a -x /sbin/rarp ]; then
- /sbin/rarp -f /etc/ethers
- fi
-fi
-}
-
-modprobe_net()
-{
-if is_yes "$IPV6_NETWORKING" && [ "`ls -R /lib/modules/\`uname -r\`/ 2>/dev/null | grep ipv6.o`" != "" ]; then
- modprobe -s -k net-pf-10
- if is_yes "$IPV6_TUNNELCONFIG" && [ "`ls -R /lib/modules/\`uname -r\`/ 2>/dev/null | grep ipip.o`" != "" ]; then
- modprobe -s -k ipip
- fi
+if is_yes "$IPX" && is_module "ipx"; then
+ _modprobe single -k ipx
fi
}
# folowing function calculates network prefix from given network mask
# (c) 1999 Grzegorz Stanislawski <stangrze@open.net.pl>
#
-calcprefix() {
+calcprefix()
+{
typeset OISF len olen bad prefix
OISF=$IFS
IFS="."
# folowing function calculates network mask from given prefix
# (c) 1999 Grzegorz Stanislawski <stangrze@open.net.pl>
#
-calcnetmask() {
+calcnetmask()
+{
typeset prefix a MASK
MASK=""
if [ "`echo "${1}" | grep "^[0-9]"`" = "" ]; then
# Retrievies PPPD PID and real interface name from /var/run/ppp-*.pid
get_ppp_device_and_pid () {
- if [ -f "/var/run/ppp-$DEVICE.pid" ] ; then
- eval `{
- read PID ; echo "PID='$PID'"
- read REALDEVICE ; echo "REALDEVICE=$REALDEVICE"
- } < "/var/run/ppp-$DEVICE.pid"`
- fi
- if [ -z "$REALDEVICE" ] ; then
- REALDEVICE=$DEVICE
- fi
+if [ -f "/var/run/ppp-$DEVICE.pid" ] ; then
+ eval `{
+ read PID ; echo "PID='$PID'"
+ read REALDEVICE ; echo "REALDEVICE=$REALDEVICE"
+ } < "/var/run/ppp-$DEVICE.pid"`
+fi
+if [ -z "$REALDEVICE" ] ; then
+ REALDEVICE=$DEVICE
+fi
}
# This must be last line !
# vi:syntax=sh:tw=78:ts=8:sw=4
+
#
# probe: true
-# $Id: network,v 1.43 2001/05/13 18:39:36 kloczek Exp $
+# $Id: network,v 1.44 2001/05/15 16:03:38 baggins Exp $
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
# NLS
NLS_DOMAIN="rc-scripts"
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network-scripts/.functions
-[ ! -f /etc/sysconfig/network ] && exit 0
+if [ ! -f /etc/sysconfig/network ]; then
+ nls "%s is missing. Can't continue." "/etc/sysconfig/network"
+ exit 1
+fi
. /etc/sysconfig/network
# Check that networking is up.
is_no "${NETWORKING}" && exit 0
-[ -x /sbin/ip ] || exit 0
+# Will be removed in the future
+if is_yes "$NETWORKING" ; then
+ if [ -z "$IPV4_NETWORKING" ] ; then
+ echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
+ echo "Please upgrade your config"
+ echo "Assuming you want IPv4 networking"
+ IPV4_NETWORKING=yes
+ fi
+fi
+
+if [ ! -x /sbin/ip ]; then
+ nls "%s is missing. Can't continue." "/sbin/ip"
+ exit 1
+fi
######
# initialize networking:
# - setup lo interface
network_init()
{
+# Kernel network parameters
+run_cmd "Setting network parameters" sysctl -p /etc/sysctl.conf
+
# Set UP loopback interface
set_up_loopback
# Modprobe needed devices
modprobe_net
-# Spoofing protection && dynamic IP && port range
-ipv4_anti_spoofing on
-ipv4_dynamic_ip_patch on
-ipv4_local_port_range on
-
-# Others proc/sys/net
-proc_networking start
-
-# Setup NAT rules
+# Setup configuration
+setup_forwarding on
setup_nat on
setup_routes on
# Setup IPX
if is_yes "$IPX"; then
- if [ ! -z $IPXAUTOPRIMARY ] ; then
+ if [ -n $IPXAUTOPRIMARY ] ; then
+ if is_yes "$IPXAUTOPRIMARY"; then
+ IPXAUTOPRIMARY="on"
+ else
+ IPXAUTOPRIMARY="off"
+ fi
/usr/bin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
fi
- if [ ! -z $IPXAUTOFRAME ] ; then
+ if [ -n $IPXAUTOFRAME ] ; then
+ if is_yes "$IPXAUTOFRAME"; then
+ IPXAUTOFRAME="on"
+ else
+ IPXAUTOFRAME="off"
+ fi
/usr/bin/ipx_configure --auto_interface=$IPXAUTOFRAME
fi
- if [ ! -z "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
+ if [ -n "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
/usr/bin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
fi
fi
# Set static ARP table
static_arp
-
-# Start rdisc daemon
-rdisc on
}
######
# - down lo interface.
network_deinit()
{
+setup_forwarding off
setup_routes off
# Set down NAT rules
setup_nat off
-# Shut down rdisc daemon
-rdisc off
-
-# Spoofing protection && dynamic IP && port range
-ipv4_anti_spoofing off
-ipv4_dynamic_ip_patch off
-ipv4_local_port_range off
-
-# Others proc/sys/net
-proc_networking stop
-
# Set DOWN loopback interface
set_down_loopback
}
-proc_networking()
-{
-TODO="$1"
-
-# IPv4 forwarding
-proc_net ipv4/ip_forward $TODO 1 0 IPV4_FORWARDING "IPv4 forwarding"
-# IPv6 forwarding
-if is_yes "$IPV6_NETWORKING"; then
- proc_net ipv6/conf/all/forwarding $TODO 1 0 IPV6_FORWARDING "IPv6 forwarding"
-fi
-# Others proc/net
-proc_net ipv4/conf/all/accept_redirects $TODO 1 0 IPV4_ACCEPT_ICMP_REDIR ""
-proc_net ipv4/conf/all/accept_source_route $TODO 1 1 IPV4_ACCEPT_SOURCE_ROUTE ""
-proc_net ipv4/conf/all/log_martians $TODO 1 0 IPV4_LOG_MARTIANS ""
-proc_net ipv4/conf/all/mc_forwarding $TODO 1 0 IPV4_MULTICAST ""
-proc_net ipv4/conf/all/proxy_arp $TODO 1 0 IPV4_PROXY_ARP ""
-proc_net ipv4/conf/all/secure_redirects $TODO 1 1 IPV4_ACCEPT_ICMP_REDIR_GATE ""
-proc_net ipv4/conf/all/send_redirects $TODO 1 1 IPV4_SEND_ICMP_REDIR ""
-proc_net ipv4/icmp_echo_ignore_all $TODO 1 0 IPV4_IGN_ALL_ICMP ""
-proc_net ipv4/icmp_echo_ignore_broadcasts $TODO 1 1 IPV4_IGN_CAST_ICMP ""
-proc_net ipv4/ip_no_pmtu_disc $TODO 1 0 IPV4_MTU_DISCOVERY ""
-proc_net ipv4/ip_masq_debug $TODO 1 0 IPV4_MASQ_DEBUGGING ""
-proc_net ipv4/tcp_retrans_collapse $TODO 0 1 IPV4_RETRANS_COLLAPSE ""
-proc_net ipv4/tcp_sack $TODO 0 1 IPV4_NO_SELECT_ACK ""
-proc_net ipv4/tcp_timestamps $TODO 0 1 IPV4_NO_TIMESTAMPS ""
-proc_net ipv4/tcp_stdurg $TODO 1 0 IPV4_RFC793 ""
-proc_net ipv4/tcp_syncookies $TODO 1 0 IPV4_SYN_COOKIES ""
-proc_net ipv4/tcp_window_scaling $TODO 1 0 IPV4_NO_WINDOW_SCALING ""
-# ... and proc/net/ipv6 goodies
-proc_net ipv6/conf/default/autoconf $TODO 0 1 IPV6_AUTOCONF ""
-proc_net ipv6/conf/default/autoconf_route $TODO 0 1 IPV6_AUTOCONF_ROUTE ""
-}
-
# find all the interfaces besides loopback.
# ignore aliases, alternative configurations, and editor backup files
-
-interfaces=$( (cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
+interfaces=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
-interfaces_boot=$( (cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
+interfaces_boot=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
egrep -v '(ifcfg-lo|ifcfg-sit|ifcfg-atm|ifcfg-lec|ifcfg-nas|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
xargs egrep -l "ONBOOT=[^n][^o]" | \
awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
-interfaces_sit_boot=$( (cd /etc/sysconfig/interfaces && ls -1 ifcfg-sit* | \
+interfaces_sit_boot=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg-sit* | \
egrep 'ifcfg-[a-z0-9]+$' | xargs egrep -l "ONBOOT=[^n][^o]" | \
awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
-tunnels=$( (cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \
+tunnels=$((cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \
xargs egrep -l "ONBOOT=[^n][^o]" | \
awk ' { gsub(/tnlcfg-/,NIL); print $0 } ') 2> /dev/null)
network_init
for i in $interfaces_boot $interfaces_sit_boot ; do
- /sbin/ifup $i boot
+ run_cmd -a "$(nls 'Bringing up interface') $i" /sbin/ifup $i boot
done
- for i in `find_ldap_interfaces` ; do
- /sbin/ifup $i boot
+ for i in $(find_ldap_interfaces) ; do
+ run_cmd -a "$(nls 'Bringing up interface from LDAP') $i" /sbin/ifup $i boot
done
for i in $tunnels; do
- /sbin/tnlup $i boot
- /sbin/ifup tnlcfg-$i boot
+ run_cmd -a "$(nls 'Setting tunnel') $i" /sbin/tnlup $i boot
+ run_cmd -a "$(nls 'Bringing up tunnel interface') $i" /sbin/ifup tnlcfg-$i boot
done
network_postinit
touch /var/lock/subsys/network
;;
stop)
+ # If we go to runlevel 0, 1 or 6 then umount all network fs
+ if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
+ if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
+ then
+ /etc/rc.d/init.d/netfs stop
+ else
+ netmtab=$(awk '{ if ($3 ~ /^(nfs|smbfs|ncpfs)$/ ) print $3}' /proc/mounts)
+ if (echo "$netmtab" | grep -q nfs); then
+ run_cmd "Unmounting NFS filesystems" umount -fat nfs
+ fi
+ if (echo "$netmtab" | grep -q smbfs); then
+ run_cmd "Unmounting SMB filesystems" umount -at smbfs
+ fi
+ if (echo "$netmtab" | grep -q ncpfs); then
+ run_cmd "Unmounting NCP filesystems" umount -at ncpfs
+ fi
+ fi
+ fi
+
for i in $tunnels; do
- /sbin/ifdown tnlcfg-$i boot
- /sbin/tnldown $i boot
+ run_cmd -a "$(nls 'Shutting down tunnel interface') $i" /sbin/ifdown tnlcfg-$i boot
+ run_cmd -a "$(nls 'Removing tunnel') $i" /sbin/tnldown $i boot
done
- for i in `find_ldap_interfaces` ; do
- /sbin/ifdown $i boot
+ for i in $(find_ldap_interfaces) ; do
+ run_cmd -a "$(nls 'Shutting down interface from LDAP') $i" /sbin/ifdown $i boot
done
for i in $interfaces_sit_boot $interfaces_boot ; do
- /sbin/ifdown $i boot
+ run_cmd -a "$(nls 'Shutting down interface') $i" /sbin/ifdown $i boot
+ done
+
+ for i in $(ip link show | awk -F":" ' (/UP/) && ($2 !~ "lo") { gsub(/@.*/,NIL); print $2; } ') ; do
+ show "Shutting down unconfigured interface %s" "$i"
+ ip addr flush dev $i 2>&1 | grep -v "Nothing to flush"
+ if (ip link set $i down); then ok; else fail; fi
done
network_deinit
echo "lo $interfaces"
nls "Configured tunnels:"
echo "$tunnels"
-
+ echo
+ nls "Currently inactive devices and tunnels:"
+ /sbin/ip link show | awk -F":" '(/^[0-90-90-9]:/) && ! (/UP/) { print $2 }' | xargs
nls "Currently active devices and tunnels:"
/sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs
;;
#!/bin/sh
#
-# single Script for setting up administrative/rescue shell.
+# single Script for sedding up administrative/rescue shell.
#
# chkconfig: 1 00 00
# description: This file is executed by init when it goes into runlevel \
# Note that the file systems are kept mounted. \
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
-# Modified for PLD Linux by Grzegorz Stanislawski
-# Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+# Changes: Grzegorz Stanislawski <stangrze@open.net.pl>
+# Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
#
-# $Id: single,v 1.10 2000/11/16 16:01:18 baggins Exp $
+# $Id: single,v 1.11 2001/05/15 16:03:38 baggins Exp $
# Set the path.
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# make sure modprobe is working
if [ -f /proc/sys/kernel/modprobe ]; then
- echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
+ sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
fi
# If they want to run something in single user mode, might as well run it...
# chkconfig: 345 <startr_level> <stop_level>
#
# description: <service> long service description
+#
+# $Id: template.init,v 1.5 2001/05/15 16:03:38 baggins Exp $
# Source function library
[ -f /etc/sysconfig/<service> ] && . /etc/sysconfig/<service>
# Check that networking is up.
-if is_no "${NETWORKING}"; then
- # nls "ERROR: Networking is down. %s can't be run." <service>
- msg_Network_Down <service>
- exit 1
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network ]; then
+ # nls "ERROR: Networking is down. %s can't be run." <service>
+ msg_network_down <service>
+ exit 1
+ fi
+else
+ exit 0
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/<service>
else
# show "%s service is already running." <service>
- msg_Already_Running <service>
+ msg_already_running <service>
exit 1
fi
;;
if [ -f /var/lock/subsys/<service> ]; then
msg_stopping <service>
killproc <service>
- rm -f /var/lock/subsys/<service> >/dev/null 2>&1
+ RETVAL=$?
+ rm -f /var/lock/subsys/<service>
else
# show "%s service is not running." <service>
- msg_Not_Running <service>
+ msg_not_running <service>
exit 1
fi
;;
# show "Reload %s service" <service>
msg_reloading <service>
killproc <service> -HUP
+ RETVAL=$?
else
# show "%s service is not running." <service>
- msg_Not_Running <service>
- exit 1
+ msg_not_running <service>
+ RETVAL=1
fi
;;
force-reload)
# if program allows reloading without stopping
$0 reload
- exit $?
# or if it doesn't
$0 stop && $0 start
- exit $?
;;
status)
status <service>
- exit $?
+ RETVAL=$?
;;
*)
# show "Usage: %s {start|stop|status|restart|reload|force-reload}" $0
- msg_Usage "$0 {start|stop|status|restart|reload|force-reload}"
+ msg_usage "$0 {start|stop|status|restart|reload|force-reload}"
exit 1
esac
# responsible for the very first setup of basic
# things, such as setting the hostname.
#
-# $Id: rc,v 1.27 2001/05/13 17:10:16 baggins Exp $
+# $Id: rc,v 1.28 2001/05/15 16:03:36 baggins Exp $
#
# Original Author:
# Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
#
+# avoid being interrupted by child or keyboard
+trap ":" INT QUIT TSTP
+
+# Save argument
+argv1="$1"
+
+# Get terminal size of standard input of the system console
+[ -z "$CONSOLE" ] && CONSOLE=/dev/console
+set -- $(stty size < $CONSOLE)
+ LINES=$1
+COLUMNS=$2
+export LINES COLUMNS CONSOLE
+
# NLS
if [ -f /etc/sysconfig/i18n ]; then
. /etc/sysconfig/i18n
fi
# Now find out what the current and what the previous runlevel are.
-argv1="$1"
-set `/sbin/runlevel`
+set $(/sbin/runlevel)
runlevel=$2
previous=$1
export runlevel previous
+# if previous runlevel = current runlevel do nothing
+[ "$runlevel" = "$previous" ] && exit 0
+
# if runlevel is 0 (halt) or 6 (reboot) change to first
# virtual console, and send messages to /dev/console
# (it can be serial console too)
-if [ "$runlevel" = "0" ] || [ "$runlevel" = "6" ]; then
- [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo > /dev/console
- exec 0<> /dev/console 1>&0 2>&0
+if [ "$COLUMNS" -gt 0 ]; then
+ if [ "$runlevel" = "0" -o "$runlevel" = "6" ]; then
+ CONSOLE=/dev/tty1
+ [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo > $CONSOLE
+ exec 0<> /dev/console 1>&0 2>&0
+ fi
else
-# if previous runlevel = current runlevel do nothing
- [ "$runlevel" = "$previous" ] && exit 0
+ # Serial: columns and lines are not defined
+ LINES=24
+ COLUMNS=80
fi
# See if we want to be in user confirmation mode
stty onlcr -ixon 0>&1
# Get first argument. Set new runlevel to this argument.
-[ "$1" != "" ] && runlevel="$argv1"
+[ -n "$1" ] && runlevel="$argv1"
# Tell linuxconf what runlevel we are in
[ -d /var/run -a -w /var/run ] && echo "/etc/rc.d/rc$runlevel.d" > /var/run/runlevel.dir
# Say something ;)
-af2="`termput setaf 2`"
-af6="`termput setaf 6`"
-af7="`termput setaf 7`"
-text="`nls '%sResource Manager: %sEntering runlevel number' "$af2" "$af7"`"
-text_size="`nls '%sResource Manager: %sEntering runlevel number' "" ""`"
-resp_size="`nls 'DONE'`"
+af2=$(termput setaf 2)
+af6=$(termput setaf 6)
+af7=$(termput setaf 7)
+text="$(termput op)$(nls '%sResource Manager: %sEntering runlevel number' "$af2" "$af7")"
+text_size="$(nls '%sResource Manager: %sEntering runlevel number' "" "")"
+resp_size="$(nls 'DONE')"
echo -n "$text"
awk "BEGIN { for (j=length(\"$text_size\"); j<$INIT_COL+${#resp_size}-${#runlevel}; j++) printf \".\" }"
echo "${af6}[${af2} $runlevel ${af6}]${af7}"
fi
# Say something ;)
-text="`nls '%sResource Manager: %sRunlevel has been reached' "$af2" "$af7"`"
-text_size="`nls '%sResource Manager: %sRunlevel has been reached' "" ""`"
+text="$(nls '%sResource Manager: %sRunlevel has been reached' "$af2" "$af7")"
+text_size="$(nls '%sResource Manager: %sRunlevel has been reached' "" "")"
echo -n "$text"
awk "BEGIN { for (j=length(\"$text_size\"); j<$INIT_COL+${#resp_size}-${#runlevel}; j++) printf \".\" }"
echo "${af6}[${af2} $runlevel ${af6}]${af7}"
unset af2 af6 af7
+exit 0
+
# This must be last line !
# vi:syntax=sh:tw=78:ts=8:sw=4
--- /dev/null
+#!/bin/sh
+# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
+# Modified:
+# Arkadiusz Miskiewicz <misiek@pld.org.pl>
+#
+# rc.modules: launch modules specified in /etc/modules
+# $Id: rc.modules,v 1.2 2001/05/15 16:05:06 baggins Exp $
+
+[ -f /etc/modules ] || exit 0
+
+. /etc/rc.d/init.d/functions
+
+# Loop over every line in /etc/modules.
+(egrep -v "^(#|[[:blank:]]*#)" /etc/modules; echo) | # make sure there is a LF at the end
+while read module args
+do
+ [ -z "$module" ] && continue
+ _modprobe single -k $module
+done
+
# shutdwn Common script for system halt/reboot.
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
-# Modified for PLD Linux by Grzegorz Stanislawski
-# Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+# Changes: Grzegorz Stanislawski <stangrze@open.net.pl>
+# Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
#
-# $Id: rc.shutdown,v 1.14 2001/05/13 17:10:16 baggins Exp $
+# $Id: rc.shutdown,v 1.15 2001/05/15 16:03:36 baggins Exp $
# Set the path.
PATH=/sbin:/bin:/usr/bin:/usr/sbin
# Turn off swap, then unmount file systems.
run_cmd "Turning off swap and accounting" swapoff -a
-[ -x /sbin/accton ] && /sbin/accton
+[ -x /sbin/accton ] && LC_ALL=C /sbin/accton 2>&1 | grep -v "not implemented"
if [ -x /sbin/quotaoff ]; then
run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a
sig=-15
retry=3
force=
-remaining=`awk '!/(^#| proc | loopfs | devfs | devpts | shm |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts`
+remaining=$(awk '!/(^#| proc | loopfs | devfs | devpts | shm |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts)
while [ -n "$remaining" -a "$retry" -gt 0 ]
do
show "Unmounting file systems" ; busy
- if ERRORS=`LC_ALL=C exec umount -a $FORCE -t noproc 2>&1` ; then
+ if ERRORS=$(LC_ALL=C exec umount -a $FORCE -t noproc 2>&1) ; then
ok
else
fail
fi
sleep 2
- remaining=`awk '!/(^#| proc | loopfs | devfs | devpts | shm |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts`
+ remaining=$(awk '!/(^#| proc | loopfs | devfs | devpts | shm |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts)
[ -z "$remaining" ] && break
/sbin/fuser -k -m $sig $remaining > /dev/null
sleep 5
if [ -f /proc/mdstat ] ; then
mddevs=$(awk '/^md.* active/ {print $1}' /proc/mdstat)
for mddev in $mddevs ; do
- MESSAGE="`nls 'Turning off RAID for %s' "$mddev"`"
+ MESSAGE="$(nls 'Turning off RAID for %s' "$mddev")"
run_cmd "$MESSAGE" raidstop /dev/$mddev
done
unset mddev mddevs
fi
show "Remounting remaining filesystems ro mode"; busy
-if ( mount | awk '/ext2/ { print $3 }' | \
+if ( mount | awk '/ext2|ext3|reiserfs|xfs|jfs/ { print $3 }' | \
while read line; do
mount -n -o ro,remount $line; done ); then
ok
#!/bin/sh
#
# /etc/rc.d/rc.sysinit - run once at boot time
-# $Id: rc.sysinit,v 1.77 2001/05/13 17:10:16 baggins Exp $
+# $Id: rc.sysinit,v 1.78 2001/05/15 16:03:36 baggins Exp $
#
# Taken in part from Miquel van Smoorenburg's bcheckrc.
# Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
export PATH
# NLS
-if [ -f /etc/sysconfig/i18n ]; then
+if [ -r /etc/sysconfig/i18n ]; then
. /etc/sysconfig/i18n
[ -n "$LANG" ] && export LANG || unset LANG
[ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
. /etc/rc.d/init.d/functions
# Read network config data.
-if [ -f /etc/sysconfig/network ]; then
+if [ -r /etc/sysconfig/network ]; then
. /etc/sysconfig/network
else
NETWORKING=no
fi
# Read system config data.
-if [ -f /etc/sysconfig/system ]; then
+if [ -r /etc/sysconfig/system ]; then
. /etc/sysconfig/system
else
RUN_SULOGIN_ON_ERR=yes
fi
# Print welcome message
-echo -e "\t\t\t`termput setaf 6`Powered by `termput setaf 2`PLD GNU/Linux`termput setaf 7`"
+nls "\t\t\t%sPowered by %sPLD GNU/Linux%s" "$(termput setaf 6)" "$(termput setaf 2)" "$(termput setaf 7)"
if is_yes "$PROMPT"; then
- echo -en "\t\t`nls 'Press'` '`termput setaf 1`I`termput setaf 7`' `nls 'to enter interactive startup.'`"
+ nls -n "\t\t Press %sI%s to enter interactive startup." "$(termput setaf 1)" "$(termput setaf 7)"
echo
sleep 1
fi
# Set console loglevel
/bin/dmesg -n $CONSOLE_LOGLEVEL
-# Turn off sysrq
-if [ -f /proc/sys/kernel/sysrq ] && is_no "$MAGIC_SYSRQ"; then
- echo "0" > /proc/sys/kernel/sysrq
- run_cmd "Turning off Magic SysRq key" /bin/true
-fi
-
-# Turn off Stop-A
-if [ -f /proc/sys/kernel/stop-a ] && is_no "$STOP_A"; then
- echo "0" > /proc/sys/kernel/stop-a
- run_cmd "Turning off Stop-A/Break-A" /bin/true
-fi
+# Configure Linux kernel
+run_cmd "Configuring kernel parameters" /sbin/sysctl -p /etc/sysctl.conf
# Set the system clock.
ARC=0
CLOCKFLAGS="$CLOCKFLAGS --utc";
CLOCKDEF="$CLOCKDEF (utc)";
;;
-# new hwclock remembers if it was called with --utc or
-# --localtime, and reuses it, so we should tell it
-# explictly what to do
- *)
+ *)
CLOCKFLAGS="$CLOCKFLAGS --localtime";
- CLOCKDEF="$CLOCKDEF (utc)";
+ CLOCKDEF="$CLOCKDEF (local)";
;;
esac
# Check if timezone definition is available
if [ -e /etc/localtime ] ; then
- if run_cmd "Setting clock$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
- show "Today's date: `LC_CTYPE=C date`"; ok
+ if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
+ show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
fi
else
TIME_SETUP_DELAYED=yes
fi
# Start up swapping.
-run_cmd "`nls 'Activating swap partitions'`" swapon -a
+run_cmd "Activating swap partitions" swapon -a
# Set the hostname.
-run_cmd "`nls 'Host:'` ${HOSTNAME}" hostname ${HOSTNAME}
+run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
# Set the NIS domain name
if [ -n "$NISDOMAIN" ]; then
- run_cmd "`nls 'NIS Domain:'` ${NISDOMAIN}" domainname $NISDOMAIN
+ run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
else
domainname ""
fi
-# Setup hdparm thingy (if exists)
-[ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
+# Setup hdparm thing (if exists and is needed)
+if ! grep -iq nohdparm /proc/cmdline; then
+ [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
+fi
if [ -f /fsckoptions ]; then
- fsckoptions=`cat /fsckoptions`
+ fsckoptions=$(cat /fsckoptions)
else
fsckoptions=''
fi
# A return of 2 or higher means there were serious problems.
if [ $rc -gt 1 ]; then
# don't use '\n' in nls macro !
- echo "\n\n"
+ echo
+ echo
nls "*** An error occurred during the file system check."
nls "*** Dropping you to a shell; the system will reboot"
nls "*** when you leave the shell."
echo
- PS1="`nls '(Repair filesystem)# '`"; export PS1
+ PS1="$(nls '(Repair filesystem)# ')"; export PS1
if is_yes "$RUN_SULOGIN_ON_ERR"; then
sulogin
else
fi
# check for arguments
-if grep -i nopnp /proc/cmdline >/dev/null ; then
+if grep -iq nopnp /proc/cmdline; then
PNP=
else
PNP=yes
# Update quotas if fsck was run on /.
if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck ]; then
- run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
+ run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vug /
fi
# /etc/nologin when starting system
ok
fi
+# The root filesystem is now read-write, so we can now log via
+# syslog() directly..
+if [ -n "$IN_INITLOG" ]; then
+ IN_INITLOG=""
+fi
+
echo ${HOSTNAME} > /etc/HOSTNAME
# Clear mtab
# Enter root and /proc into mtab.
mount -f /
mount -f /proc
+[ -f /proc/bus/usb/devices ] && mount -f -t usbdevfs usbdevfs /proc/bus/usb
if [ ! -f /proc/modules ]; then
USEMODULES=
-elif ! grep -i nomodules /proc/cmdline >/dev/null ; then
+elif ! grep -iq nomodules /proc/cmdline; then
USEMODULES=y
else
USEMODULES=
rm -f /lib/modules/preferred
rm -f /lib/modules/default
if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
- if is_yes "$SET_SLINKS"; then
- # Get ready for kmod if module support in the kernel
- if [ -z `uname -r | grep "-"` ]; then
- # we're using a new kernel, no preferred needed
- mver=`uname -r`
- else
- ktag="`cat /proc/version`"
- mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
- if [ -n "$mtag" ]; then
- mver=$(echo $mtag | \
- awk ' { gsub(/\/lib\/modules\//,NIL); \
- gsub(/.rhkmvtag/,NIL); \
- gsub(/[ ].*$/,NIL); \
- print $0 } ')
- fi
- if [ -n "$mver" ]; then
- ln -sf /lib/modules/$mver /lib/modules/default
- fi
- fi
+ if is_yes "$SET_SLINKS"; then
+ # Get ready for kmod if module support in the kernel
+ if [ -z $(uname -r | grep "-") ]; then
+ # we're using a new kernel, no preferred needed
+ mver=$(uname -r)
+ else
+ ktag="$(cat /proc/version)"
+ mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
+ if [ -n "$mtag" ]; then
+ mver=$(echo $mtag | awk ' { gsub(/\/lib\/modules\//,NIL); gsub(/.rhkmvtag/,NIL); gsub(/[ ].*$/,NIL); print $0 } ')
fi
- [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
- ln -sf /boot/module-info-$mver /boot/module-info
- [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
- ln -sf /boot/System.map-$mver /boot/System.map
-
- # Run depmod if:
- # a) user requested or RUN_DEPMOD="";
- # b) modules.dep is missing
- # c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
-
- # NOTE: Please keep in mind that is_no() does NOT check if argument
- # means "no". It checks if it not means "yes". Please see misiek's
- # note in init.d/functions. This means that passing value which mean
- # neither "yes" nor "no" will return "true", beacause it does not mean
- # "yes". Weird, isn't it? :)
-
- if ! is_no "$RUN_DEPMOD" || [ "$RUN_DEPMOD" = "ifmissing" ] || [ -z "$RUN_DEPMOD" ]; then
- if [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] ||\
- is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ] ||\
- [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] ||\
- [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ]
- then
- run_cmd "Finding module dependencies" depmod -a
- fi
+ if [ -n "$mver" ]; then
+ ln -sf /lib/modules/$mver /lib/modules/default
fi
+ fi
+
+ [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
+ ln -sf /boot/module-info-$mver /boot/module-info
+ [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
+ ln -sf /boot/System.map-$mver /boot/System.map
+ fi
+fi
+
+# Run depmod if RUN_DEPMOD != "no" and:
+# a) user requested or RUN_DEPMOD="";
+# b) modules.dep is missing
+# c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
+if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
+ if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ] || \
+ [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] ||\
+ [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] ||\
+ [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ]; then
+ run_cmd "Finding module dependencies" depmod -a
+ fi
fi
+if [ -f /proc/sys/kernel/modprobe ]; then
+ if [ -n "$USEMODULES" ]; then
+ sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
+ else
+ # We used to set this to NULL, but that causes
+ # 'failed to exec' messages"
+ sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
+ fi
+fi
+
+# Load modules
+if [ -x /etc/rc.d/rc.modules ]; then
+ /etc/rc.d/rc.modules
+fi
+
# load sound modules
if [ -n "$USEMODULES" ] && is_yes "$LOAD_SOUND"; then
if grep -s -q "^alias sound-slot-0" /etc/modules.conf ; then
fi
fi
-if [ -f /proc/sys/kernel/modprobe ]; then
- # /proc/sys/kernel/modprobe indicates built-in kmod instead
- echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
-fi
-
-# Load modules
-if [ -f /etc/rc.d/rc.modules ]; then
- /etc/rc.d/rc.modules
-fi
-
# Add raid devices
if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
- show "Starting up RAID devices."; started
rc=0
- for i in `grep "raiddev" /etc/raidtab | awk '{print $2}'`
+ for i in $(grep "raiddev" /etc/raidtab | awk '{print $2}')
do
- RAIDDEV=`basename $i`
- RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat`
+ RAIDDEV=$(basename $i)
+ RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat)
+ show "Starting up RAID device %s" $RAIDDEV
+ busy
if [ -z "$RAIDSTAT" ]; then
# Try raidstart first...if that fails then
- # fall back to raid0run.
+ # fall back to raid0run and if that fails, too
+ # fall back to raidadd, raidrun.
RESULT=1
if [ -x /sbin/raidstart ]; then
/sbin/raidstart $i
fi
if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
/sbin/raid0run $i
+ RESULT=$?
+ fi
+ if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
+ /sbin/raidadd $i
+ /sbin/raidrun $i
+ RESULT=$?
fi
+ if [ $RESULT -gt 0 ]; then
+ rc=1
+ fail
+ else
+ ok
+ fi
+ else
+ ok
fi
done
# A non-zero return means there were problems.
if [ $rc -gt 0 ]; then
show "Starting up RAID devices."; fail
- echo "\n\n"
+ echo
+ echo
nls "*** An error occurred during the RAID startup"
nls "*** Dropping you to a shell; the system will reboot"
nls "*** when you leave the shell."
echo
- PS1="`nls '(RAID Repair)# '`"; export PS1
+ PS1="$(nls '(RAID Repair)# ')"; export PS1
if is_yes "$RUN_SULOGIN_ON_ERR"; then
sulogin
else
show "Starting up RAID devices."; ok
fi
+# Find and activate volume groups
+if [ -e /proc/lvm -a -x /sbin/vgscan -a -x /sbin/vgchange ]; then
+ run_cmd "Scanning for LVM volume groups" /sbin/vgscan && \
+ run_cmd "Activating LVM volume groups" /sbin/vgchange -a y
+fi
+
# Check filesystems
-if [ ! -f /fastboot ]; then
+if ! grep -q nofsck /proc/cmdline && [ ! -f /fastboot ]; then
show "Checking filesystems."; started
initlog -c "fsck -C -T -R -A -a $fsckoptions"
# A return of 2 or higher means there were serious problems.
if [ $rc -gt 1 ]; then
- echo "\n\n"
+ echo
+ echo
nls "*** An error occurred during the file system check."
nls "*** Dropping you to a shell; the system will reboot"
nls "*** when you leave the shell."
echo
- PS1="`nls '(Repair filesystem)# '`"; export PS1
+ PS1="$(nls '(Repair filesystem)# ')"; export PS1
if is_yes "$RUN_SULOGIN_ON_ERR"; then
sulogin
else
run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
run_cmd "Automatic reboot in progress." reboot
elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
- run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
+ if [ -x /sbin/convertquota ]; then
+ if [ -f /quota.user ]; then
+ /sbin/convertquota -u / && rm -f /quota.user
+ fi
+ if [ -f /quota.group ]; then
+ /sbin/convertquota -g / && rm -f /quota.group
+ fi
+ fi
+ run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -u -g -R -a
fi
fi
# Set the clock if timezone definition wasn't available (eg. /usr not mounted)
if is_yes "$TIME_SETUP_DELAYED"; then
- if run_cmd "Setting clock$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
- show "Today's date: `LC_CTYPE=C date`"; ok
+ if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
+ show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
fi
fi
fi
if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
- show "`nls 'Setting %s seconds for kernel reboot after panic.' "$PANIC_REBOOT_TIME"`"; busy
- if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then ok; else fail; fi
+ show "Setting %s seconds for kernel reboot after panic." "$PANIC_REBOOT_TIME"; busy
+ if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME 2> /dev/null); then ok; else fail; fi
fi
# Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
# there could be a new kernel version. remove old psdevtab database
rm -f /etc/psdevtab
-# If needed increase number of available system files
-# There are two versions of each setting, because file names
-# changed between Linux 2.0 and 2.2
-if [ -n "$VFS_FILE_MAX" ] ; then
- if [ -f /proc/sys/kernel/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
- echo $VFS_FILE_MAX >/proc/sys/kernel/file-max
- fi
- if [ -f /proc/sys/fs/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
- echo $VFS_FILE_MAX >/proc/sys/fs/file-max
- fi
-fi
-if [ -n "$VFS_INODE_MAX" ] ; then
- if [ -f /proc/sys/kernel/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
- echo $VFS_INODE_MAX >/proc/sys/kernel/inode-max
- fi
- if [ -f /proc/sys/fs/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
- echo $VFS_INODE_MAX >/proc/sys/fs/inode-max
- fi
-fi
-
-
# Now that we have all of our basic modules loaded and the kernel going,
# let's dump the syslog ring somewhere so we can find it later
dmesg > /var/log/dmesg
# Now that we have all of our basic modules loaded and the kernel going,
# let's dump the syslog ring somewhere so we can find it later
-kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1
+kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
} &
if is_yes "$PROMPT"; then
/sbin/getkey i && touch /var/run/confirm
fi
wait
+echo
# This must be last line !
# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: setsysfont,v 1.5 1999/08/02 13:04:45 kloczek Exp $
+# $Id: setsysfont,v 1.6 2001/05/15 16:03:33 baggins Exp $
#
[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
if [ -n "$SYSFONT" ]; then
consolechars -f $SYSFONT
elif [ -n "$CONSOLEFONT" ]; then
- consolechars -f $CONSOLEFONT
+ consolechars -m ${CONSOLEMAP:-trivial.trans} -f $CONSOLEFONT
fi
- if [ "$CONSOLEMAP" != "" ]; then
- consolechars -m $CONSOLEMAP
- fi
- if [ "$KEYTABLE" != "" ]; then
- loadkeys $KEYTABLE
+ if [ -n "$KEYTABLE" ]; then
+ loadkeys $KEYTABLE < /dev/tty0 > /dev/tty0
fi
@SET_MAKE@
+DEFS = @DEFS@ -D_GNU_SOURCE=1
+
sysconf_DATA = \
initlog.conf
#include <ctype.h>
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
int main(int argc, char **argv) {
char foo[2];
+ char *list;
+ int alarmlen=0;
int tp_if,tp_of,tp_lf;
int x;
if (argc>1) {
- for (x=0;argv[1][x];x++) argv[1][x]=toupper(argv[1][x]);
+ if (argv[1][0]=='-' && isdigit(argv[1][1])) {
+ alarmlen = atoi(argv[1]+1);
+ list = argv[2];
+ } else {
+ list = argv[1];
+ }
+ for (x=0;list[x];x++) list[x]=toupper(list[x]);
}
foo[0]=foo[1]='\0';
signal(SIGTERM,reset_term);
+ alarm(alarmlen);
+ signal(SIGALRM,reset_term);
tcgetattr(0,&tp);
tp_if=tp.c_iflag;
tp_of=tp.c_oflag;
foo[0]=toupper(foo[0]);
/* Die if we get a control-c or control-d */
if (foo[0]==3 || foo[0]==4) reset_term(1);
- if ((!argv[1]) || strstr(argv[1],foo)) {
+ if ((!list) || strstr(list,foo)) {
reset_term(0);
}
}
-/* $Id: initlog.c,v 1.3 1999/12/15 18:41:08 misiek Exp $ */
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libintl.h>
#define SYSLOG_NAMES
#include <syslog.h>
+#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/un.h>
#include <sys/wait.h>
#define _(String) gettext((String))
dup2(fd,0);
dup2(fd,1);
dup2(fd,2);
+ close(fd);
/* kid */
execlp("minilogd","minilogd",NULL);
perror("exec");
}
}
+int trySocket() {
+ int s;
+ struct sockaddr_un addr;
+
+ s = socket(AF_LOCAL, SOCK_DGRAM, 0);
+ if (s<0)
+ return 1;
+
+ bzero(&addr,sizeof(addr));
+ addr.sun_family = AF_LOCAL;
+ strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
+
+ if (connect(s,(struct sockaddr *) &addr,sizeof(addr))<0) {
+ if (errno == EPROTOTYPE) {
+ DDEBUG("connect failed (EPROTOTYPE), trying stream\n");
+ close(s);
+ s = socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (connect(s,(struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ DDEBUG("connect failed: %s\n",strerror(errno));
+ close(s);
+ return 1;
+ }
+ close(s);
+ return 0;
+ }
+ close(s);
+ DDEBUG("connect failed: %s\n",strerror(errno));
+ return 1;
+ } else {
+ close(s);
+ return 0;
+ }
+}
+
int logLine(struct logInfo *logEnt) {
/* Logs a line... somewhere. */
int x;
/* Don't log empty or null lines */
if (!logEnt->line || !strcmp(logEnt->line,"\n")) return 0;
- if ( ((stat(_PATH_LOG,&statbuf)==-1) ||(access("/",W_OK)==-1))
+
+ if ( ((stat(_PATH_LOG,&statbuf)==-1) || trySocket())
&& startDaemon()
) {
DDEBUG("starting daemon failed, pooling entry %d\n",logEntries);
struct logInfo logentry;
if (cmd) {
- logentry.cmd = strdup((char *)basename(cmd));
+ logentry.cmd = strdup(basename(cmd));
if ((logentry.cmd[0] =='K' || logentry.cmd[0] == 'S') && ( 30 <= logentry.cmd[1] <= 39 )
&& ( 30 <= logentry.cmd[2] <= 39 ) )
logentry.cmd+=3;
struct logInfo logentry;
if (cmd) {
- logentry.cmd = strdup((char *)basename(cmd));
+ logentry.cmd = strdup(basename(cmd));
if ((logentry.cmd[0] =='K' || logentry.cmd[0] == 'S') && ( 30 <= logentry.cmd[1] <= 39 )
&& ( 30 <= logentry.cmd[2] <= 39 ) )
logentry.cmd+=3;
} else {
readConfiguration("/etc/initlog.conf");
}
+ if (cmd) {
+ while (isspace(*cmd)) cmd++;
+ }
if (lpri!=-1) logpriority=lpri;
if (lfac!=-1) logfacility=lfac;
if (cmdevent) {
logEvent(cmdname,cmdevent,logstring);
} else if (logstring) {
logString(cmdname,logstring);
- } else if ( cmd ) {
+ } else if ( cmd && *cmd) {
return(runCommand(cmd,reexec,quiet,debug));
} else {
if (!silent)
int debug;
+int recvsock;
+
+void alarm_handler(int x) {
+ alarm(0);
+ close(recvsock);
+ recvsock = -1;
+}
+
void freeBuffer() {
struct sockaddr_un addr;
int sock;
addr.sun_family = AF_LOCAL;
strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
/* wait for klogd to hit syslog */
- sleep(1);
- sock = socket(AF_LOCAL, SOCK_STREAM,0);
+ sleep(2);
+ sock = socket(AF_LOCAL, SOCK_DGRAM,0);
conn=connect(sock,(struct sockaddr *) &addr,sizeof(addr));
while (x<buflines) {
if (!conn) write(sock,buffer[x],strlen(buffer[x])+1);
void runDaemon(int sock) {
struct sockaddr_un addr;
- int x,len,addrlen,recvsock,done=0;
+ int x,len,addrlen,done=0;
char *message;
struct stat s1,s2;
struct pollfd pfds;
done = 0;
/* Get stat info on /dev/log so we can later check to make sure we
* still own it... */
- stat(_PATH_LOG,&s1);
+ if (stat(_PATH_LOG,&s1) != 0)
+ memset(&s1, '\0', sizeof(struct stat));
while (!done) {
pfds.fd = sock;
pfds.events = POLLIN|POLLPRI;
if ( (x>0) && pfds.revents & (POLLIN | POLLPRI)) {
message = calloc(8192,sizeof(char));
recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen);
+ alarm(2);
+ signal(SIGALRM, alarm_handler);
len = read(recvsock,message,8192);
- if (buffer)
- buffer = realloc(buffer,(buflines+1)*sizeof(char *));
- else
- buffer = malloc(sizeof(char *));
+ alarm(0);
+ close(recvsock);
if (len>0) {
- message[strlen(message)]='\n';
- buffer[buflines]=message;
- buflines++;
- close(recvsock);
+ if (buflines < 200000) {
+ if (buffer)
+ buffer = realloc(buffer,(buflines+1)*sizeof(char *));
+ else
+ buffer = malloc(sizeof(char *));
+ message[strlen(message)]='\n';
+ buffer[buflines]=message;
+ buflines++;
+ }
}
else {
- close(recvsock);
recvsock=-1;
}
}
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <libintl.h>
-#include <locale.h>
/* this will be running setgid root, so be careful! */
-void usage(void) {
+static void
+usage(void) {
fprintf(stderr, "usage: netreport [-r]\n");
exit(1);
}
char netreport_name[64];
int netreport_file;
- if (argc > 2) usage();
+ if (argc > 2) {
+ usage();
+ }
- if ((argc > 1) && !strcmp(argv[1], "-r")) {
- action = DEL;
+ if (argc > 1) {
+ if (strcmp(argv[1], "-r") == 0) {
+ action = DEL;
+ } else {
+ usage();
+ }
}
- sprintf(netreport_name, "/var/run/netreport/%d", getppid());
+ snprintf(netreport_name, sizeof(netreport_name),
+ "/var/run/netreport/%d", getppid());
if (action == ADD) {
- netreport_file = creat(netreport_name, 0);
- if (netreport_file < 0) {
+ netreport_file = open(netreport_name,
+ O_EXCL|O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, 0);
+ if (netreport_file == -1) {
if (errno != EEXIST) {
perror("Could not create netreport file");
exit (1);
unlink(netreport_name);
}
- exit(0);
+ return 0;
}
* one argument: the logical name of the device to bring up. Does not
* detach until the interface is up or has permanently failed to come up.
*
- * Copyright 1999 Red Hat, Inc.
+ * Copyright 1999-2001 Red Hat, Inc.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
#include <sys/wait.h>
#include <termios.h>
#include <net/if.h>
-
+#include <glib.h>
#include "shvar.h"
+#define IFCFGPREFIX "/etc/sysconfig/network-scripts/ifcfg-"
+#define IFUP_PPP "/etc/sysconfig/network-scripts/ifup-ppp"
+
static int theSigterm = 0;
static int theSigint = 0;
static int theSighup = 0;
static int theSigio = 0;
static int theSigchld = 0;
static int theSigalrm = 0;
+static int pipeArray[2];
+// patch to respect the maxfail parameter to ppp
+// Scott Sharkey <ssharkey@linux-no-limits.com>
+static int dialCount = 0;
static int theChild;
-
-
-static void
-cleanExit(int exitCode);
-
-
+static void failureExit(int exitCode);
static void
-forward_signal(int signo) {
+interrupt_child(int signo) {
kill(theChild, SIGINT);
}
-
-
-
static void
set_signal(int signo, void (*handler)(int)) {
struct sigaction act;
-
act.sa_handler = handler;
act.sa_flags = SA_RESTART;
sigemptyset(&act.sa_mask);
sigaction(signo, &act, NULL);
}
+/* Create a pipe, and fork off a child. This is the end of the road for
+ * the parent, which will wait for an exit status byte on the pipe (which
+ * is written by the child). */
+static void
+detach(char *device) {
+ pid_t childpid;
+ unsigned char exitCode;
+ int fd;
+ if (pipe(pipeArray) == -1)
+ exit(25);
-static void
-detach(int now, int parentExitCode, char *device) {
- static int pipeArray[2];
- char exitCode;
+ childpid = fork();
+ if (childpid == -1)
+ exit(26);
- if (now) {
- /* execute -- ignore errors in case called more than once */
- exitCode = parentExitCode;
- write(pipeArray[1], &exitCode, 1);
- close(pipeArray[1]);
+ if (childpid != 0) {
+ /* The parent only cares about notifications from the child. */
+ close (pipeArray[1]);
- } else {
- /* set up */
- int child;
-
- if (pipe(pipeArray)) exit (25);
-
- child = fork();
- if (child < 0) exit(26);
- if (child) {
- /* parent process */
- close (pipeArray[1]);
-
- /* forward likely signals to the main process; we will
- * react later
- */
- theChild = child;
- set_signal(SIGINT, forward_signal);
- set_signal(SIGTERM, forward_signal);
- set_signal(SIGHUP, forward_signal);
-
- while (read (pipeArray[0], &exitCode, 1) < 0) {
- switch (errno) {
- case EINTR: continue;
- default: exit (27); /* this will catch EIO in particular */
- }
+ /* Certain signals are meant for our child, the watcher process. */
+ theChild = childpid;
+ set_signal(SIGINT, interrupt_child);
+ set_signal(SIGTERM, interrupt_child);
+ set_signal(SIGHUP, interrupt_child);
+
+ /* Read the pipe until the child gives us an exit code as a byte. */
+ while (read (pipeArray[0], &exitCode, 1) == -1) {
+ switch (errno) {
+ case EINTR: continue;
+ default: exit (27); /* this will catch EIO in particular */
}
- switch (exitCode) {
- case 0:
- break;
+ }
+ switch (exitCode) {
+ case 0:
+ break;
case 33:
- fprintf(stderr, "%s already up, initiating redial\n", device);
- break;
+ fprintf(stderr, "%s already up, initiating redial\n", device);
+ break;
case 34:
- fprintf(stderr, "Failed to activate %s, retrying in the background\n", device);
- break;
+ fprintf(stderr, "Failed to activate %s, retrying in the background\n", device);
+ break;
default:
- fprintf(stderr, "Failed to activate %s with error %d\n", device, exitCode);
- break;
- }
- exit(exitCode);
-
- } else {
- /* child process */
- close (pipeArray[0]);
- /* become a daemon */
- close (0);
- close (1);
- close (2);
- setsid();
- setpgid(0, 0);
- }
+ fprintf(stderr, "Failed to activate %s with error %d\n", device, exitCode);
+ break;
+ }
+ exit(exitCode);
}
-}
+ /* We're in the child process, which only writes the exit status
+ * of the pppd process to its parent (i.e., it reads nothing). */
+ close (pipeArray[0]);
+
+ /* Redirect stdio to /dev/null. */
+ fd = open("/dev/null", O_RDONLY);
+ dup2(fd, STDIN_FILENO);
+ close(fd);
+ fd = open("/dev/null", O_WRONLY);
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+ close(fd);
+ /* Become session and process group leader. */
+ setsid();
+ setpgid(0, 0);
+}
+
+/* Do magic with the pid file (/var/run/pppwatch-$DEVICE.pid):
+ * Try to open it for writing. If it exists, send a SIGHUP to whatever PID
+ * is already listed in it and remove it. Repeat until we can open it.
+ * Write out our PID, and return. */
static void
doPidFile(char *device) {
- static char *pidFileName = NULL;
- char *pidFilePath;
- int fd; FILE *f;
+ static char pidFilePath[PATH_MAX] = "";
+ int fd = -1;
+ FILE *f = NULL;
pid_t pid = 0;
- if (pidFileName) {
- /* remove it */
- pidFilePath = alloca(strlen(pidFileName) + 25);
- sprintf(pidFilePath, "/var/run/pppwatch-%s.pid", pidFileName);
- unlink(pidFilePath); /* not much we can do in case of error... */
- }
-
- if (device) {
- /* create it */
- pidFileName = device;
- pidFilePath = alloca(strlen(pidFileName) + 25);
- sprintf(pidFilePath, "/var/run/pppwatch-%s.pid", pidFileName);
-restart:
- fd = open(pidFilePath, O_WRONLY|O_TRUNC|O_CREAT|O_EXCL,
- S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH);
-
- if (fd == -1) {
- /* file already existed, or terrible things have happened... */
- fd = open(pidFilePath, O_RDONLY);
- if (fd == -1)
- cleanExit(36); /* terrible things have happened */
- /* already running, send a SIGHUP (we presume that they
- * are calling ifup for a reason, so they probably want
- * to redial) and then exit cleanly and let things go
- * on in the background
- */
- f = fdopen(fd, "r");
- if (!f) cleanExit(37);
- fscanf(f, "%d", &pid);
- fclose(f);
- if (pid) {
- if (kill(pid, SIGHUP)) {
- unlink(pidFilePath);
- goto restart;
- } else {
- cleanExit(33);
- }
- }
+ if (device == NULL) {
+ /* Remove an existing pid file -- we're exiting. */
+ if(strlen(pidFilePath) > 0) {
+ unlink(pidFilePath);
}
+ } else {
+ /* Set up the name of the pid file, used only the first time. */
+ snprintf(pidFilePath, sizeof(pidFilePath), "/var/run/pppwatch-%s.pid",
+ device);
+
+ /* Create the pid file. */
+ do {
+ fd = open(pidFilePath, O_WRONLY|O_TRUNC|O_CREAT|O_EXCL|O_NOFOLLOW,
+ S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH);
+ if(fd == -1) {
+ /* Try to open the file for read. */
+ fd = open(pidFilePath, O_RDONLY);
+ if(fd == -1)
+ failureExit(36); /* This is not good. */
+
+ /* We're already running, send a SIGHUP (we presume that they
+ * are calling ifup for a reason, so they probably want to
+ * redial) and then exit cleanly and let things go on in the
+ * background. Muck with the filename so that we don't go
+ * deleting the pid file for the already-running instance.
+ */
+ f = fdopen(fd, "r");
+ if(f == NULL)
+ failureExit(37);
+
+ pid = 0;
+ fscanf(f, "%d", &pid);
+ fclose(f);
+
+ if(pid) {
+ /* Try to kill it. */
+ if (kill(pid, SIGHUP) == -1) {
+ /* No such pid, remove the bogus pid file. */
+ unlink(pidFilePath);
+ } else {
+ /* Got it. Don't mess with the pid file on
+ * our way out. */
+ memset(pidFilePath, '\0', sizeof(pidFilePath));
+ failureExit(33);
+ }
+ }
+ }
+ } while(fd == -1);
f = fdopen(fd, "w");
- if (!f)
- cleanExit(31);
+ if(f == NULL)
+ failureExit(31);
fprintf(f, "%d\n", getpid());
fclose(f);
}
}
-
-
-
-
-int
-fork_exec(int wait, char *path, char *arg1, char *arg2, char *arg3)
+/* Fork off and exec() a child process. If reap_child is non-zero,
+ * wait for the child to exit and return 0 if it ran successfully,
+ * otherwise return 0 right away and let the SIGCHLD handler deal. */
+static int
+fork_exec(gboolean reap, char *path, char *arg1, char *arg2, char *arg3)
{
- pid_t child;
+ pid_t childpid;
int status;
sigset_t sigs;
- if (!(child = fork())) {
- /* child */
+ childpid = fork();
+ if (childpid == -1)
+ exit(26);
- /* don't leave signals blocked for pppd */
+ if (childpid == 0) {
+ /* Do the exec magic. Prepare by clearing the signal mask for pppd. */
sigemptyset(&sigs);
sigprocmask(SIG_SETMASK, &sigs, NULL);
- if (!wait) {
- /* make sure that pppd is in its own process group */
+ if (!reap) {
+ /* Make sure that the pppd is the leader for its process group. */
setsid();
setpgid(0, 0);
}
_exit (1);
}
- if (wait) {
- wait4 (child, &status, 0, NULL);
+ if (reap) {
+ waitpid (childpid, &status, 0);
if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)) {
return 0;
} else {
}
}
+/* Relay the pppd's exit code up to the parent -- can only be called once,
+ * because the parent exits as soon as it reads a byte. */
+static void
+relay_exitcode(unsigned char code)
+{
+ unsigned char exitCode;
+ exitCode = code;
+ write(pipeArray[1], &exitCode, 1);
+ close(pipeArray[1]);
+}
-
+/* Unregister with netreport, relay a status byte to the parent, clean up
+ * the pid file, and bail. */
static void
-cleanExit(int exitCode) {
- fork_exec(1, "/sbin/netreport", "-r", NULL, NULL);
- detach(1, exitCode, NULL);
+failureExit(int exitCode) {
+ fork_exec(TRUE, "/sbin/netreport", "-r", NULL, NULL);
+ relay_exitcode(exitCode);
doPidFile(NULL);
exit(exitCode);
}
-
-
+/* Keeps track of which signals we've seen so far. */
static void
-signal_handler (int signum) {
+signal_tracker (int signum) {
switch(signum) {
- case SIGTERM:
- theSigterm = 1; break;
- case SIGINT:
- theSigint = 1; break;
- case SIGHUP:
- theSighup = 1; break;
- case SIGIO:
- theSigio = 1; break;
- case SIGCHLD:
- theSigchld = 1; break;
- case SIGALRM:
- theSigalrm = 1; break;
+ case SIGTERM:
+ theSigterm = 1; break;
+ case SIGINT:
+ theSigint = 1; break;
+ case SIGHUP:
+ theSighup = 1; break;
+ case SIGIO:
+ theSigio = 1; break;
+ case SIGCHLD:
+ theSigchld = 1; break;
+ case SIGALRM:
+ theSigalrm = 1; break;
}
}
-
+/* Return a shvarFile for this interface, taking into account one level of
+ * inheritance (eeewww). */
static shvarFile *
-shvarfilesGet(char *interfaceName) {
- shvarFile *ifcfg;
- char *ifcfgName, *ifcfgParentName, *ifcfgParentDiff;
- static char ifcfgPrefix[] = "/etc/sysconfig/network-scripts/ifcfg-";
+shvarfilesGet(const char *interfaceName) {
+ shvarFile *ifcfg = NULL;
+ char ifcfgName[PATH_MAX];
+ char *ifcfgParentDiff = NULL;
- ifcfgName = alloca(sizeof(ifcfgPrefix)+strlen(interfaceName)+1);
- sprintf(ifcfgName, "%s%s", ifcfgPrefix, interfaceName);
+ /* Start with the basic configuration. */
+ snprintf(ifcfgName, sizeof(ifcfgName), "%s%s", IFCFGPREFIX, interfaceName);
ifcfg = svNewFile(ifcfgName);
- if (!ifcfg) return NULL;
+ if (ifcfg == NULL)
+ return NULL;
- /* Do we have a parent interface to inherit? */
- ifcfgParentDiff = strchr(interfaceName, '-');
+ /* Do we have a parent interface (i.e., for ppp0-blah, ppp0) to inherit? */
+ ifcfgParentDiff = strchr(ifcfgName + sizeof(IFCFGPREFIX), '-');
if (ifcfgParentDiff) {
- /* allocate more than enough memory... */
- ifcfgParentName = alloca(sizeof(ifcfgPrefix)+strlen(interfaceName)+1);
- strcpy(ifcfgParentName, ifcfgPrefix);
- strncat(ifcfgParentName, interfaceName, ifcfgParentDiff-interfaceName);
- ifcfg->parent = svNewFile(ifcfgParentName);
+ *ifcfgParentDiff = '\0';
+ ifcfg->parent = svNewFile(ifcfgName);
}
- /* don't keep the file descriptors around, they can become
- * stdout for children
- */
- close (ifcfg->fd); ifcfg->fd = 0;
+ /* This is very unclean, but we have to close the shvar descriptors in
+ * case they've been numbered STDOUT_FILENO or STDERR_FILENO, which would
+ * be disastrous if inherited by a child process. */
+ close (ifcfg->fd);
+ ifcfg->fd = 0;
+
if (ifcfg->parent) {
- close (ifcfg->parent->fd); ifcfg->parent->fd = 0;
+ close (ifcfg->parent->fd);
+ ifcfg->parent->fd = 0;
}
return ifcfg;
}
-
-
-static char *
-pppLogicalToPhysical(int *pppdPid, char *logicalName) {
- char *mapFileName;
- char buffer[20]; /* more than enough space for ppp<n> */
+/* Convert a logical interface name to a real one by reading the lock
+ * file created by pppd. */
+static void
+pppLogicalToPhysical(int *pppdPid, char *logicalName, char **physicalName) {
+ char mapFileName[PATH_MAX];
+ char buffer[20];
char *p, *q;
- int f, n;
+ int fd, n;
char *physicalDevice = NULL;
- mapFileName = alloca (strlen(logicalName)+20);
- sprintf(mapFileName, "/var/run/ppp-%s.pid", logicalName);
- if ((f = open(mapFileName, O_RDONLY)) >= 0) {
- n = read(f, buffer, 20);
+ snprintf(mapFileName, sizeof(mapFileName), "/var/run/ppp-%s.pid",
+ logicalName);
+ fd = open(mapFileName, O_RDONLY);
+ if (fd != -1) {
+ n = read(fd, buffer, sizeof(buffer));
+ close(fd);
if (n > 0) {
buffer[n] = '\0';
- /* get past pid */
- p = buffer; while (*p && *p != '\n') p++; *p = '\0'; p++;
- if (pppdPid) *pppdPid = atoi(buffer);
- /* get rid of \n */
- q = p; while (*q && *q != '\n' && q < buffer+n) q++; *q = '\0';
- if (*p) physicalDevice = strdup(p);
+ /* Split up the file at the first line break -- the PID is on the
+ * first line. */
+ if((p = strchr(buffer, '\n')) != NULL) {
+ *p = '\0';
+ p++;
+ if (pppdPid) {
+ *pppdPid = atoi(buffer);
+ }
+ /* The physical device name is on the second line. */
+ if((q = strchr(p, '\n')) != NULL) {
+ *q = '\0';
+ physicalDevice = strdup(p);
+ }
+ }
}
- close(f);
}
- return physicalDevice;
+ if (physicalDevice) {
+ if (physicalName) {
+ *physicalName = physicalDevice;
+ } else {
+ free(physicalDevice);
+ }
+ } else {
+ if (physicalName) {
+ *physicalName = NULL;
+ }
+ }
}
-
-static int
-interfaceStatus(char *device) {
- int sock = 0;
- int pfs[] = {AF_INET, AF_IPX, AF_AX25, AF_APPLETALK, 0};
+/* Return a boolean value indicating if the interface is up. If not, or
+ * if we don't know, return FALSE. */
+static gboolean
+interfaceIsUp(char *device) {
+ int sock = -1;
+ int family[] = {PF_INET, PF_IPX, PF_AX25, PF_APPLETALK, 0};
int p = 0;
struct ifreq ifr;
- int retcode = 0;
+ gboolean retcode = FALSE;
- while (!sock && pfs[p]) {
- sock = socket(pfs[p++], SOCK_DGRAM, 0);
+ /* Create a socket suitable for doing routing ioctls. */
+ for (p = 0; (sock == -1) && family[p]; p++) {
+ sock = socket(family[p], SOCK_DGRAM, 0);
}
- if (!sock) return 0;
+ if (sock == -1)
+ return FALSE;
+ /* Populate the request structure for getting the interface's status. */
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, device, IFNAMSIZ);
+ strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name) - 1);
+ ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
- if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
- retcode = 0;
+ /* We return TRUE iff the ioctl succeeded and the interface is UP. */
+ if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) {
+ retcode = FALSE;
} else if (ifr.ifr_flags & IFF_UP) {
- retcode = 1;
+ retcode = TRUE;
}
close(sock);
+
return retcode;
}
-
-/* very, very minimal hangup function. This is just to attempt to
- * hang up a device that should already be hung up, so it does not
- * need to be bulletproof.
- */
-void
+/* Very, very minimal hangup function. This just attempts to hang up a device
+ * that should already be hung up, so it does not need to be bulletproof. */
+static void
hangup(shvarFile *ifcfg) {
int fd;
- char *filename;
- struct termios ots, ts;
-
- filename = svGetValue(ifcfg, "MODEMPORT");
- if (!filename) return;
- fd = open(filename, O_RDWR|O_NOCTTY|O_NONBLOCK);
- if (fd == -1) goto clean;
- if (tcgetattr(fd, &ts)) goto clean;
- ots = ts;
- write(fd, "\r", 1); /* tickle modems that do not like dropped DTR */
- usleep(1000);
- cfsetospeed(&ts, B0);
- tcsetattr(fd, TCSANOW, &ts);
- usleep(100000);
- tcsetattr(fd, TCSANOW, &ots);
-
-clean:
- free(filename);
+ char *line;
+ struct termios original_ts, ts;
+
+ line = svGetValue(ifcfg, "MODEMPORT");
+ if (line == NULL)
+ return;
+
+ fd = open(line, O_RDWR | O_NOCTTY | O_NONBLOCK);
+ if (fd != -1) {
+ if (tcgetattr(fd, &ts) != -1) {
+ original_ts = ts;
+ write(fd, "\r", 1); /* tickle modems that do not like dropped DTR */
+ usleep(1000);
+ cfsetospeed(&ts, B0);
+ tcsetattr(fd, TCSANOW, &ts);
+ usleep(100000);
+ tcsetattr(fd, TCSANOW, &original_ts);
+ }
+ close(fd);
+ }
+ free(line);
}
-
-
-
-
-
-
-
-
int
main(int argc, char **argv) {
- int status, waited;
+ int status;
+ pid_t waited;
char *device, *real_device, *physicalDevice = NULL;
- char *theBoot = NULL;
+ char *boot = NULL;
shvarFile *ifcfg;
- sigset_t sigs;
+ sigset_t blockedsigs, unblockedsigs;
int pppdPid = 0;
int timeout = 30;
char *temp;
- struct timeval tv;
- int dieing = 0;
+ gboolean dying = FALSE;
int sendsig;
- int connectedOnce = 0;
+ gboolean connectedOnce = FALSE;
+ int maxfail = 0; // MAXFAIL Patch <ssharkey@linux-no-limits.com>
if (argc < 2) {
fprintf (stderr, "usage: ppp-watch [ifcfg-]<logical-name> [boot]\n");
exit(30);
}
- if (!strncmp(argv[1], "ifcfg-", 6)) {
+ if (strncmp(argv[1], "ifcfg-", 6) == 0) {
device = argv[1] + 6;
} else {
device = argv[1];
}
- detach(0, 0, device); /* prepare */
+ detach(device); /* Prepare a child process to monitor pppd. When we
+ return, we'll be in the child. */
- if (argc > 2 && !strcmp("boot", argv[2])) {
- theBoot = argv[2];
+ if ((argc > 2) && (strcmp("boot", argv[2]) == 0)) {
+ boot = argv[2];
}
ifcfg = shvarfilesGet(device);
- if (!ifcfg) cleanExit(28);
+ if (ifcfg == NULL)
+ failureExit(28);
real_device = svGetValue(ifcfg, "DEVICE");
- if (!real_device) real_device = device;
+ if (real_device == NULL)
+ real_device = device;
doPidFile(real_device);
- set_signal(SIGTERM, signal_handler);
- set_signal(SIGINT, signal_handler);
- set_signal(SIGHUP, signal_handler);
- set_signal(SIGIO, signal_handler);
- set_signal(SIGCHLD, signal_handler);
- if (theBoot) {
- set_signal(SIGALRM, signal_handler);
- alarm(30);
+ /* We'll want to know which signal interrupted our sleep below, so
+ * attach a signal handler to these. */
+ set_signal(SIGTERM, signal_tracker);
+ set_signal(SIGINT, signal_tracker);
+ set_signal(SIGHUP, signal_tracker);
+ set_signal(SIGIO, signal_tracker);
+ set_signal(SIGCHLD, signal_tracker);
+
+ /* We time out only if we're being run at boot-time. */
+ if (boot) {
+ temp = svGetValue(ifcfg, "BOOTTIMEOUT");
+ if (temp) {
+ timeout = atoi(temp);
+ if (timeout < 1) timeout = 1;
+ free(temp);
+ } else {
+ timeout = 30;
+ }
+ set_signal(SIGALRM, signal_tracker);
+ alarm(timeout);
}
- fork_exec(1, "/sbin/netreport", NULL, NULL, NULL);
+ /* Register us to get a signal when something changes. Yes, that's vague. */
+ fork_exec(TRUE, "/sbin/netreport", NULL, NULL, NULL);
+
+ /* Reset theSigchld, which should have been triggered by netreport. */
theSigchld = 0;
- /* don't set up the procmask until after we have received the netreport
- * signal
- */
- sigemptyset(&sigs);
- sigaddset(&sigs, SIGTERM);
- sigaddset(&sigs, SIGINT);
- sigaddset(&sigs, SIGHUP);
- sigaddset(&sigs, SIGIO);
- sigaddset(&sigs, SIGCHLD);
- if (theBoot) sigaddset(&sigs, SIGALRM);
- sigprocmask(SIG_BLOCK, &sigs, NULL);
-
- /* prepare for sigsuspend later */
- sigfillset(&sigs);
- sigdelset(&sigs, SIGTERM);
- sigdelset(&sigs, SIGINT);
- sigdelset(&sigs, SIGHUP);
- sigdelset(&sigs, SIGIO);
- sigdelset(&sigs, SIGCHLD);
- if (theBoot) sigdelset(&sigs, SIGALRM);
-
- fork_exec(0, "/etc/sysconfig/network-scripts/ifup-ppp", "daemon", device, theBoot);
+ /* We don't set up the procmask until after we have received the netreport
+ * signal. Do so now. */
+ sigemptyset(&blockedsigs);
+ sigaddset(&blockedsigs, SIGTERM);
+ sigaddset(&blockedsigs, SIGINT);
+ sigaddset(&blockedsigs, SIGHUP);
+ sigaddset(&blockedsigs, SIGIO);
+ sigaddset(&blockedsigs, SIGCHLD);
+ if (boot) {
+ sigaddset(&blockedsigs, SIGALRM);
+ }
+ sigprocmask(SIG_BLOCK, &blockedsigs, NULL);
+
+ sigfillset(&unblockedsigs);
+ sigdelset(&unblockedsigs, SIGTERM);
+ sigdelset(&unblockedsigs, SIGINT);
+ sigdelset(&unblockedsigs, SIGHUP);
+ sigdelset(&unblockedsigs, SIGIO);
+ sigdelset(&unblockedsigs, SIGCHLD);
+ if (boot) {
+ sigdelset(&unblockedsigs, SIGALRM);
+ }
+ sigprocmask(SIG_UNBLOCK, &unblockedsigs, NULL);
+
+ /* Initialize the retry timeout using the RETRYTIMEOUT setting. */
temp = svGetValue(ifcfg, "RETRYTIMEOUT");
if (temp) {
timeout = atoi(temp);
timeout = 30;
}
- while (1) {
- sigsuspend(&sigs);
+ /* Start trying to bring the interface up. */
+ fork_exec(FALSE, IFUP_PPP, "daemon", device, boot);
+
+ while (TRUE) {
+ /* Wait for a signal. */
+ if (!theSigterm &&
+ !theSigint &&
+ !theSighup &&
+ !theSigio &&
+ !theSigchld &&
+ !theSigalrm) {
+ sigsuspend(&unblockedsigs);
+ }
+ /* If we got SIGTERM or SIGINT, give up and hang up. */
if (theSigterm || theSigint) {
theSigterm = theSigint = 0;
- if (dieing) sendsig = SIGKILL;
- else sendsig = SIGTERM;
- dieing = 1;
+ /* If we've already tried to exit this way, use SIGKILL instead
+ * of SIGTERM, because pppd's just being stubborn. */
+ if (dying) {
+ sendsig = SIGKILL;
+ } else {
+ sendsig = SIGTERM;
+ }
+ dying = TRUE;
+
+ /* Get the pid of our child pppd. */
+ pppLogicalToPhysical(&pppdPid, real_device, NULL);
+
+ /* We don't know what our child pid is. This is very confusing. */
+ if (!pppdPid) {
+ failureExit(35);
+ }
- if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; }
- physicalDevice = pppLogicalToPhysical(&pppdPid, real_device);
- if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; }
- if (!pppdPid) cleanExit(35);
+ /* Die, pppd, die. */
kill(pppdPid, sendsig);
if (sendsig == SIGKILL) {
- kill(-pppdPid, SIGTERM); /* give it a chance to die nicely */
+ kill(-pppdPid, SIGTERM); /* Give it a chance to die nicely, then
+ kill its whole process group. */
usleep(2500000);
kill(-pppdPid, sendsig);
hangup(ifcfg);
- cleanExit(32);
+ failureExit(32);
}
}
+ /* If we got SIGHUP, reload and redial. */
if (theSighup) {
theSighup = 0;
- if (ifcfg->parent) svCloseFile(ifcfg->parent);
+
+ /* Free and reload the configuration structure. */
+ if (ifcfg->parent)
+ svCloseFile(ifcfg->parent);
svCloseFile(ifcfg);
ifcfg = shvarfilesGet(device);
- physicalDevice = pppLogicalToPhysical(&pppdPid, real_device);
- if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; }
+
+ /* Get the PID of our child pppd. */
+ pppLogicalToPhysical(&pppdPid, real_device, NULL);
kill(pppdPid, SIGTERM);
- /* redial when SIGCHLD arrives, even if !PERSIST */
- connectedOnce = 0;
- timeout = 0; /* redial immediately */
+
+ /* We'll redial when the SIGCHLD arrives, even if PERSIST is
+ * not set (the latter handled by clearing the "we've connected
+ * at least once" flag). */
+ connectedOnce = FALSE;
+
+ /* We don't want to delay before redialing, either, so cut
+ * the retry timeout to zero. */
+ timeout = 0;
}
+ /* If we got a SIGIO (from netreport, presumably), check if the
+ * interface is up and return zero (via our parent) if it is. */
if (theSigio) {
theSigio = 0;
- if (connectedOnce) {
- if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; }
- temp = svGetValue(ifcfg, "DISCONNECTTIMEOUT");
- if (temp) {
- timeout = atoi(temp);
- free(temp);
- } else {
- timeout = 2;
- }
- }
- physicalDevice = pppLogicalToPhysical(NULL, real_device);
+
+ pppLogicalToPhysical(NULL, real_device, &physicalDevice);
if (physicalDevice) {
- if (interfaceStatus(physicalDevice)) {
- /* device is up */
- detach(1, 0, NULL);
- connectedOnce = 1;
+ if (interfaceIsUp(physicalDevice)) {
+ /* The interface is up, so report a success to a parent if
+ * we have one. Any errors after this we just swallow. */
+ relay_exitcode(0);
+ connectedOnce = TRUE;
}
+ free(physicalDevice);
}
}
+ /* If we got a SIGCHLD, then pppd died (possibly because we killed it),
+ * and we need to restart it after timeout seconds. */
if (theSigchld) {
theSigchld = 0;
- waited = wait3(&status, 0, NULL);
- if (waited < 0) continue;
- /* now, we need to kill any children of pppd still in pppd's
+ /* Find its pid, which is also its process group ID. */
+ waited = waitpid(-1, &status, 0);
+ if (waited == -1) {
+ continue;
+ }
+
+ /* Now, we need to kill any children of pppd still in pppd's
* process group, in case they are hanging around.
* pppd is dead (we just waited for it) but there is no
* guarantee that its children are dead, and they will
* hold the modem if we do not get rid of them.
- * We have kept the old pid/pgrp around in pppdPid.
- */
+ * We have kept the old pid/pgrp around in pppdPid. */
if (pppdPid) {
kill(-pppdPid, SIGTERM); /* give it a chance to die nicely */
usleep(2500000);
}
pppdPid = 0;
- if (!WIFEXITED(status)) cleanExit(29);
- if (dieing) cleanExit(WEXITSTATUS(status));
+ /* Bail if the child exitted abnormally or we were already
+ * signalled to kill it. */
+ if (!WIFEXITED(status)) {
+ failureExit(29);
+ }
+ if (dying) {
+ failureExit(WEXITSTATUS(status));
+ }
- /* error conditions from which we do not expect to recover
- * without user intervention -- do not fill up the logs.
- */
+ /* Error conditions from which we do not expect to recover
+ * without user intervention -- do not fill up the logs. */
switch (WEXITSTATUS(status)) {
case 1: case 2: case 3: case 4: case 6:
case 7: case 9: case 14: case 17:
- cleanExit(WEXITSTATUS(status));
+ failureExit(WEXITSTATUS(status));
break;
default:
break;
}
+ /* We default to retrying the connect phase for backward
+ * compatibility, unless RETRYCONNECT is false. */
+ if ((WEXITSTATUS(status) == 8) &&
+ !svTrueValue(ifcfg, "RETRYCONNECT", TRUE)) {
+ failureExit(WEXITSTATUS(status));
+ }
+
+ /* If we've never connected, or PERSIST is set, dial again, up
+ * to MAXFAIL times. */
if ((WEXITSTATUS(status) == 8) ||
- !connectedOnce || svTrueValue(ifcfg, "PERSIST", 0)) {
+ !connectedOnce ||
+ svTrueValue(ifcfg, "PERSIST", FALSE)) {
+ /* If we've been connected (i.e., if we didn't force a redial,
+ * but the connection went down) wait for DISCONNECTTIMEOUT
+ * seconds before redialing. */
+ if (connectedOnce) {
+ connectedOnce = FALSE;
+ temp = svGetValue(ifcfg, "DISCONNECTTIMEOUT");
+ if (temp) {
+ timeout = atoi(temp);
+ free(temp);
+ } else {
+ timeout = 2;
+ }
+ }
+ sigprocmask(SIG_UNBLOCK, &blockedsigs, NULL);
+ sleep(timeout);
+ sigprocmask(SIG_BLOCK, &blockedsigs, NULL);
+ if (!theSigterm &&
+ !theSighup &&
+ !theSigio &&
+ !theSigchld &&
+ !theSigalrm) {
+ fork_exec(FALSE, IFUP_PPP, "daemon", device, boot);
+ }
+ /* Reinitialize the retry timeout. */
temp = svGetValue(ifcfg, "RETRYTIMEOUT");
if (temp) {
timeout = atoi(temp);
} else {
timeout = 30;
}
- if (connectedOnce) {
- memset(&tv, 0, sizeof(tv));
- tv.tv_sec = timeout;
- select(0, NULL, NULL, NULL, &tv);
+// Scott Sharkey <ssharkey@linux-no-limits.com>
+// MAXFAIL Patch...
+ temp = svGetValue(ifcfg, "MAXFAIL");
+ if (temp) {
+ maxfail = atoi(temp);
+ free(temp);
+ } else {
+ maxfail = 0;
}
- fork_exec(0, "/etc/sysconfig/network-scripts/ifup-ppp", "daemon", device, theBoot);
+ if ( maxfail != 0 ) {
+ dialCount++;
+ if ( dialCount < maxfail ) {
+ fork_exec(FALSE, IFUP_PPP, "daemon", device, boot);
+ } else {
+ failureExit(WEXITSTATUS(status));
+ }
+ } else {
+ fork_exec(FALSE, IFUP_PPP, "daemon", device, boot);
+ }
} else {
- cleanExit(WEXITSTATUS(status));
+ failureExit(WEXITSTATUS(status));
}
}
+ /* We timed out, and we're running at boot-time. */
if (theSigalrm) {
- detach(1, 34, NULL);
+ failureExit(34);
}
}
}
-/* $Id: process.c,v 1.3 1999/12/15 18:41:08 misiek Exp $ */
#include <errno.h>
#include <fcntl.h>
int forkCommand(char **args, int *outfd, int *errfd, int *cmdfd, int quiet) {
/* Fork command 'cmd', returning pid, and optionally pointer
* to open file descriptor fd */
- int fdin, fdout, fderr, fdcmd, pid;
+ int fdout, fderr, fdcmd, pid;
int outpipe[2], errpipe[2], fdpipe[2];
int ourpid;
if (!quiet)
fderr=dup(2);
}
- fdcmd = fdpipe[1];
- if (cmdfd)
- *cmdfd = fdpipe[0];
+
+ if (cmdfd) {
+ *cmdfd = fdpipe[0];
+ fdcmd = fdpipe[1];
+ } else {
+ fdcmd = open("/dev/null",O_WRONLY);
+ }
ourpid = getpid();
if ((pid = fork())==-1) {
perror("fork");
* fucks up and we segfault or something, we don't kill rc.sysinit. */
if ( (cmdfd&&!pid) || (pid &&!cmdfd)) {
/* parent */
- close(fdin);
close(fdout);
close(fderr);
close(fdcmd);
return pid;
} else {
/* kid */
+ int sc_open_max;
+
if (outfd) {
if ( (dup2(fdout,1)==-1) ) {
perror("dup2");
close(*errfd);
if (cmdfd)
close(*cmdfd);
+
+ /* close up extra fds, and hope this doesn't break anything */
+ sc_open_max = sysconf(_SC_OPEN_MAX);
+ if(sc_open_max > 1) {
+ int fd;
+ for(fd = 3; fd < sc_open_max; fd++) {
+ if (!(cmdfd && fd == CMD_FD))
+ close(fd);
+ }
+ }
+
execvp(args[0],args);
perror("execvp");
exit(-1);
}
args[pid] = NULL;
if (strcmp(args[0],"sh") && strcmp(args[0],"/bin/sh"))
- cmdname = (char *)basename(args[0]);
+ cmdname = basename(args[0]);
else
- cmdname = (char *)basename(args[1]);
+ cmdname = basename(args[1]);
if ((cmdname[0] =='K' || cmdname[0] == 'S') && ( '0' <= cmdname[1] <= '9' )
&& ( '0' <= cmdname[2] <= '9' ) )
cmdname+=3;
-/* copied from rp3 -- DO NOT EDIT HERE, ONLY COPY FROM rp3 */
/*
* shvar.c
*
* Furthermore, they are only intended for one level of inheritance;
* the value setting algorithm assumes this.
*
- * Copyright 1999 Red Hat, Inc.
+ * Copyright 1999,2000 Red Hat, Inc.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
*
*/
-#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include "shvar.h"
-/* Open the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svNewFile(char *name)
+/* Open the file <name>, returning a shvarFile on success and NULL on failure.
+ Add a wrinkle to let the caller specify whether or not to create the file
+ (actually, return a structure anyway) if it doesn't exist. */
+static shvarFile *
+svOpenFile(const char *name, gboolean create)
{
shvarFile *s = NULL;
int closefd = 0;
- s = calloc(sizeof(shvarFile), 1);
- if (!s) return NULL;
+ s = g_malloc0(sizeof(shvarFile));
s->fd = open(name, O_RDWR); /* NOT O_CREAT */
if (s->fd == -1) {
/* try read-only */
s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
- if (s->fd) closefd = 1;
+ if (s->fd != -1) closefd = 1;
}
- s->fileName = strdup(name);
+ s->fileName = g_strdup(name);
if (s->fd != -1) {
struct stat buf;
- char *tmp;
+ char *p, *q;
if (fstat(s->fd, &buf) < 0) goto bail;
- s->arena = calloc(buf.st_size, 1);
- if (!s->arena) goto bail;
+ s->arena = g_malloc0(buf.st_size + 1);
+
if (read(s->fd, s->arena, buf.st_size) < 0) goto bail;
- /* Yes, I know that strtok is evil, except that this is
- * precisely what it was intended for in the first place...
- */
- tmp = strtok(s->arena, "\n");
- while (tmp) {
- s->lineList = g_list_append(s->lineList, tmp);
- tmp = strtok(NULL, "\n");
+
+ /* we'd use g_strsplit() here, but we want a list, not an array */
+ for(p = s->arena; (q = strchr(p, '\n')) != NULL; p = q + 1) {
+ s->lineList = g_list_append(s->lineList, g_strndup(p, q - p));
}
+
+ /* closefd is set if we opened the file read-only, so go ahead and
+ close it, because we can't write to it anyway */
if (closefd) {
close(s->fd);
s->fd = -1;
}
+
+ return s;
}
- return s;
+ if (create) {
+ return s;
+ }
bail:
if (s->fd != -1) close(s->fd);
- if (s->arena) free (s->arena);
- if (s->fileName) free (s->fileName);
- free (s);
+ if (s->arena) g_free (s->arena);
+ if (s->fileName) g_free (s->fileName);
+ g_free (s);
return NULL;
}
+/* Open the file <name>, return shvarFile on success, NULL on failure */
+shvarFile *
+svNewFile(const char *name)
+{
+ return svOpenFile(name, FALSE);
+}
+
+/* Create a new file structure, returning actual data if the file exists,
+ * and a suitable starting point if it doesn't. */
+shvarFile *
+svCreateFile(const char *name)
+{
+ return svOpenFile(name, TRUE);
+}
+
/* remove escaped characters in place */
static void
unescape(char *s) {
/* create a new string with all necessary characters escaped.
* caller must free returned string
*/
-static const char escapees[] = "\"'\\$~`"; /* must be escaped */
-static const char spaces[] = " \t"; /* only require "" */
+static const char escapees[] = "\"'\\$~`"; /* must be escaped */
+static const char spaces[] = " \t|&;()<>"; /* only require "" */
static char *
-escape(char *s) {
+escape(const char *s) {
char *new;
int i, j, mangle = 0, space = 0;
int newlen, slen;
if (!esclen) esclen = strlen(escapees);
if (!splen) splen = strlen(spaces);
- for (i = 0; i < esclen; i++) {
- if (strchr(s, escapees[i])) mangle++;
- }
- for (i = 0; i < splen; i++) {
- if (strchr(s, spaces[i])) space++;
+ slen = strlen(s);
+
+ for (i = 0; i < slen; i++) {
+ if (strchr(escapees, s[i])) mangle++;
+ if (strchr(spaces, s[i])) space++;
}
if (!mangle && !space) return strdup(s);
- slen = strlen(s);
newlen = slen + mangle + 3; /* 3 is extra ""\0 */
- new = calloc(newlen, 1);
+ new = g_malloc0(newlen);
if (!new) return NULL;
- new[0] = '"';
- for (i = 0, j = 1; i < slen; i++, j++) {
+ j = 0;
+ new[j++] = '"';
+ for (i = 0; i < slen; i++) {
if (strchr(escapees, s[i])) {
new[j++] = '\\';
}
- new[j] = s[i];
+ new[j++] = s[i];
}
- new[j] = '"';
+ new[j++] = '"';
+ g_assert(j == slen + mangle + 2); /* j is the index of the '\0' */
return new;
}
* be freed by the caller.
*/
char *
-svGetValue(shvarFile *s, char *key)
+svGetValue(shvarFile *s, const char *key)
{
char *value = NULL;
char *line;
char *keyString;
int len;
- assert(s);
- assert(key);
+ g_assert(s);
+ g_assert(key);
- keyString = calloc (strlen(key) + 2, 1);
- if (!keyString) return NULL;
+ keyString = g_malloc0(strlen(key) + 2);
strcpy(keyString, key);
keyString[strlen(key)] = '=';
len = strlen(keyString);
for (s->current = s->lineList; s->current; s->current = s->current->next) {
line = s->current->data;
if (!strncmp(keyString, line, len)) {
- value = strdup(line + len);
+ value = g_strdup(line + len);
unescape(value);
break;
}
}
- free(keyString);
+ g_free(keyString);
if (value) {
if (value[0]) {
return value;
} else {
- free (value);
+ g_free(value);
return NULL;
}
}
* return <default> otherwise
*/
int
-svTrueValue(shvarFile *s, char *key, int def)
+svTrueValue(shvarFile *s, const char *key, int def)
{
char *tmp;
int returnValue = def;
(!strcasecmp("f", tmp)) ||
(!strcasecmp("n", tmp)) ) returnValue = 0;
- free (tmp);
+ g_free (tmp);
return returnValue;
}
*
*/
void
-svSetValue(shvarFile *s, char *key, char *value)
+svSetValue(shvarFile *s, const char *key, const char *value)
{
- char *val1 = NULL, *val2 = NULL;
+ char *newval = NULL, *val1 = NULL, *val2 = NULL;
char *keyValue;
- assert(s);
- assert(key);
+ g_assert(s);
+ g_assert(key);
/* value may be NULL */
- if (value) value = escape(value);
- keyValue = malloc (strlen(key) + (value?strlen(value):0) + 2);
- if (!keyValue) return;
- sprintf(keyValue, "%s=%s", key, value?value:"");
+ if (value) newval = escape(value);
+ keyValue = g_strdup_printf("%s=%s", key, newval ? newval : "");
val1 = svGetValue(s, key);
- if (val1 && value && !strcmp(val1, value)) goto bail;
+ if (val1 && newval && !strcmp(val1, newval)) goto bail;
if (s->parent) val2 = svGetValue(s->parent, key);
- if (!value) {
+ if (!newval || !newval[0]) {
/* delete value somehow */
if (val2) {
/* change/append line to get key= */
}
if (!val1) {
- if (val2 && !strcmp(val2, value)) goto end;
+ if (val2 && !strcmp(val2, newval)) goto end;
/* append line */
s->lineList = g_list_append(s->lineList, keyValue);
s->freeList = g_list_append(s->freeList, keyValue);
}
/* deal with a whole line of noops */
- if (val1 && !strcmp(val1, value)) goto end;
+ if (val1 && !strcmp(val1, newval)) goto end;
/* At this point, val1 && val1 != value */
- if (val2 && !strcmp(val2, value)) {
+ if (val2 && !strcmp(val2, newval)) {
/* delete line */
s->lineList = g_list_remove_link(s->lineList, s->current);
g_list_free_1(s->current);
}
end:
- if (value) free(value);
+ if (newval) free(newval);
if (val1) free(val1);
if (val2) free(val2);
return;
svCloseFile(shvarFile *s)
{
- assert(s);
+ g_assert(s);
if (s->fd != -1) close(s->fd);
- free(s->arena);
+ g_free(s->arena);
for (s->current = s->freeList; s->current; s->current = s->current->next) {
- free(s->current->data);
+ g_free(s->current->data);
}
- free(s->fileName);
+ g_free(s->fileName);
g_list_free(s->freeList);
g_list_free(s->lineList); /* implicitly frees s->current */
- free(s);
+ g_free(s);
return 0;
}
-/* copied from rp3 -- DO NOT EDIT HERE, ONLY COPY FROM rp3 */
/*
* shvar.h
*
};
+/* Create the file <name>, return shvarFile on success, NULL on failure */
+shvarFile *
+svCreateFile(const char *name);
+
/* Open the file <name>, return shvarFile on success, NULL on failure */
shvarFile *
-svNewFile(char *name);
+svNewFile(const char *name);
/* Get the value associated with the key, and leave the current pointer
* pointing at the line containing the value. The char* returned MUST
* be freed by the caller.
*/
char *
-svGetValue(shvarFile *s, char *key);
+svGetValue(shvarFile *s, const char *key);
/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
* return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
* return <def> otherwise
*/
int
-svTrueValue(shvarFile *s, char *key, int def);
+svTrueValue(shvarFile *s, const char *key, int def);
/* Set the variable <key> equal to the value <value>.
* If <key> does not exist, and the <current> pointer is set, append
* to the top of the file.
*/
void
-svSetValue(shvarFile *s, char *key, char *value);
+svSetValue(shvarFile *s, const char *key, const char *value);
/* Write the current contents iff modified. Returns -1 on error
#include <sys/stat.h>
#include <unistd.h>
-/* this will be running setuid root, so be careful! */
-
-void usage(void) {
- fprintf(stderr, "usage: usernetctl <interface-config> <up|down|report>\n");
- exit(1);
-}
-
+/* This will be running setuid root, so be careful! */
static char * safeEnviron[] = {
"PATH=/bin:/sbin:/usr/bin:/usr/sbin",
"HOME=/root",
#define NOT_FOUND 0
#define FOUND_TRUE 1
+static void
+usage(void) {
+ fprintf(stderr, "usage: usernetctl <interface-config> <up|down|report>\n");
+ exit(1);
+}
-int testSafe(char * ifaceConfig) {
+static size_t
+testSafe(char *ifaceConfig) {
struct stat sb;
- /* these shouldn't be symbolic links -- anal, but that's fine w/ me */
+ /* These shouldn't be symbolic links -- anal, but that's fine w/ mkj. */
if (lstat(ifaceConfig, &sb)) {
fprintf(stderr, "failed to stat %s: %s\n", ifaceConfig,
strerror(errno));
exit(1);
}
- /* safety checks */
+ /* Safety/sanity checks. */
if (!S_ISREG(sb.st_mode)) {
fprintf(stderr, "%s is not a normal file\n", ifaceConfig);
exit(1);
}
-int userCtl(char * file) {
- char * contents;
- char * chptr;
- char * end;
- int fd;
- int size;
+static int
+userCtl(char *file) {
+ char *contents = NULL;
+ char *chptr = NULL;
+ char *next = NULL;
+ int fd = -1, retval = NOT_FOUND;
+ size_t size = 0;
size = testSafe(file);
- contents = alloca(size + 2);
+ contents = malloc(size + 2);
- if ((fd = open(file, O_RDONLY)) < 0) {
+ if ((fd = open(file, O_RDONLY)) == -1) {
fprintf(stderr, "failed to open %s: %s\n", file, strerror(errno));
exit(1);
}
contents[size] = '\n';
contents[size + 1] = '\0';
- /* each pass parses a single line (until an answer is found), contents
- itself points to the beginning of the current line */
+ /* Each pass parses a single line (until an answer is found), The contents
+ pointer itself points to the beginning of the current line. */
while (*contents) {
chptr = contents;
while (*chptr != '\n') chptr++;
- end = chptr + 1;
+ next = chptr + 1;
while (chptr >= contents && isspace(*chptr)) chptr--;
*(++chptr) = '\0';
}
if (!strcmp(contents, "yes") || !strcmp(contents, "true"))
- return FOUND_TRUE;
+ retval = FOUND_TRUE;
else
- return FOUND_FALSE;
+ retval = FOUND_FALSE;
+
+ break;
}
- contents = end;
+ contents = next;
}
- return NOT_FOUND;
-}
+ free(contents);
+ return retval;
+}
-int main(int argc, char ** argv) {
+int
+main(int argc, char ** argv) {
char * ifaceConfig;
char * chptr;
char * cmd;
if (argc != 3) usage();
if (!strcmp(argv[2], "up")) {
- cmd = "/sbin/ifup";
+ cmd = "./ifup";
} else if (!strcmp(argv[2], "down")) {
- cmd = "/sbin/ifdown";
+ cmd = "./ifdown";
} else if (!strcmp(argv[2], "report")) {
report = 1;
} else {
usage();
}
- if (chdir("/etc/sysconfig/interfaces")) {
- fprintf(stderr, "error switching to /etc/sysconfig/interfaces: "
+ if (chdir("/etc/sysconfig/network-scripts")) {
+ fprintf(stderr, "error switching to /etc/sysconfig/network-scripts: "
"%s\n", strerror(errno));
exit(1);
}
ifaceConfig = temp;
}
-
+ if(getuid() != 0)
switch (userCtl(ifaceConfig)) {
char *dash;
sysconfigdir = @sysconfigdir@
sysconfig_DATA = \
- system \
clock \
+ system \
network \
static-routes \
static-nat \
+# $Id: clock,v 1.2 2001/05/15 16:03:42 baggins Exp $
# Should the hardware clock be kept in Coordinated Universal Time
# (instead of local time).
UTC=false
interfacesdir = @sysconfigdir@/interfaces
interfaces_DATA = \
+ ifcfg-br0 \
ifcfg-description \
ifcfg-ppp0.callback \
ifcfg-ppp0.leased1 \
--- /dev/null
+# $Id: ifcfg-br0,v 1.2 2001/05/15 16:05:07 baggins Exp $
+#
+DEVICE=br0
+IPADDR=195.164.211.2
+ONBOOT=yes
+BRIDGE_DEVS="eth0 eth1"
+SPANNING_TREE=yes
-# $Id: ifcfg-description,v 1.12 2000/11/17 12:11:34 misiek Exp $
- DEVICE=<real device name>:<aliasnumber>
-or
- DEVICE=<name>
- [ BOOTPROTO={none|bootp|dhcp} ]
-if BOOTPROTO = dhcp ; then
- [ DHCPOPTIONS={-D|-H|-R}
-fi
-IPADDR=<IPv4 addres>
-[ IPADDR_ALIASES="<IPv4 addres1>/<prefix len> <IPv4 addres2>/<prefix len> <...>/<..>" ]
-IPV6_ADDR="<IPv6 addres1>/<prefix len> <IPv6 addres2>/<prefix len> <...>"
-[ PREFIX= ]
-[ NETWORK= ]
-[ BROADCAST= ]
+# $Id: ifcfg-description,v 1.13 2001/05/15 16:03:43 baggins Exp $
+DEVICE=<name>
+[ BOOTMETHOD={none|bootp|dhcp|pump} ]
+ You can specify which dhcp client to use with the DHCP_CLIENT, if
+ the DHCP_CLIENT is not specified we trying to launch in order :
+ /sbin/dhcpcd
+ /sbin/dhclient
+ /sbin/dhcpxd
+ /sbin/pump
+ if you have a preferred client define the DHCP_CLIENT variable.
+ You can also pass some options to dhcl client via DHCP_OPTIONS.
+
+[ BOOTMETHOD6={none|dhcp6|v4compat}
+ dhcp6 method isn't supported, yet.
+ v4compat uses available IPv4 addresses (ie. from DHCPv4)
+ and then convert them to IPv6 (IPv4-compatible) to use with
+ automatic tunnels
+
+
+IPADDR="(IPv4 or IPv6 address)/prefix"
+IP_AOPTS="broadcast xxx etc" (by default broadcast is autocalculated)
+IP_ROPTS=""
+
+IPADDR1=
+IP_AOPTS1= options for ip addr add
+IP_ROPTS1= options for ip route add (currently used only for IP4_PRIM_IF)
+
+IP4_PRIM_IF="1" # number of primary IPv4 interface (IPADDRx)
+IP4_SRC_IF="1" # number of IPv4 address for ip's ,,src'' parameter
+IP6_PRIM_IF="" #
+IP6_SRC_IF="" #
+
[ ONBOOT={no|yes} ]
-[ MULTICAST={|no|yes} ]
-[ ARP={no|yes} ]
-[ SRC_ADDR=<IPv4 addres> ]
-[ IPV6_AUTOCONF={no|yes} ]
-
-[ IPXFRAMETYPE={802.2|802.2TR|802.3|EtherII|SNAP} ]
-[ IPXNETWORK= ]
-[ IPXPRIMARY={no|yes} ]
-
+[ MULTICAST={|no|yes} ] - for eth automamaticly set to yes
+[ ARP={no|yes} ] - for eth automamaticly set to yes
+[ IPV6_DISABLE_AUTOCONF={yes|no} ] - disable IPv6 autoconfiguration
+
+[ IPX=yes|no ]
+if IPX=yes ; then
+
+ IPXNETNUM_{802_2,802_2TR,802_3,EtherII,SNAP}
+ IPXPRIMARY_{802_2,802_2TR,802_3,EtherII,SNAP}=yes|no
+ IPXACTIVE_{802_2,802_2TR,802_3,EtherII,SNAP}=yes|no
+fi
+
[ MTU= ]
[ METRIC= ]
[ QDISC= ]
+[ DEFAULTHANDLING=yes|no ] (used in configuration for ATM interfaces,
+ obsolete variable)
+[ HANDLING=0|1|2|3 ] (0 is default; used ie. in ATM configuration, for
+ details see ifup script)
+
if DEVICE=eth* ; then
[ MEDIA={auto|10baseT|10base2|AUI} ]
[ MAC=<hw addres> ]
-elif DEVICE=ppp* || DEVICE=slip* ; then
+elif DEVICE=ppp* || DEVICE=sl* ; then
PERSIST=yes|no
MODEMPORT=<device, say /dev/modem>
if DEVICE=ppp* ; then
AUTH=yes|no
+ PEERDNS=yes|no
DEFROUTE=yes|no
ESCAPECHARS=yes|no
HARDFLOWCTL=yes|no (yes imples "modem crtscts" options)
PPPOPTIONS=<arbitrary option string>
PAPNAME=<"name $PAPNAME" on pppd command line>
- REMIP=<remote ip address, normally unspecified>
+ REMIP=<remote ip4 address, normally unspecified>
+ REMIP6=<remote ip6 address, normally unspecified>
MRU=
DISCONNECTTIMEOUT=<number of seconds, default currently 5>
RETRYTIMEOUT=<number of seconds, default currently 60>
INITSCRIPT=<modem command>
DATAFORCHAT=<list of variables>
<anything>=<anything> (for chat script)
+ IPV6_PPP=yes|no (use IPv6 for ppp ?)
+ if IPV6_PPP = yes ; then
+ IPV6_CP_USEV4=yes|no (use local IPv4 mapped addresses
+ as IPv6 addresses)
+ IPV6_CP_PERSISTENT=yes|no (use EUI-48 addresses
+ as IPv6 addresses; not
+ supported on Linux, yet)
+ or by default use address specified by IP6_PRIM_IF
+ and REMIP6
+ fi
+ fi
+ if DEVICE=sl* ; then (SLIP)
+ DIRECT_CONNECT=yes|no (dirrect connection via slattach ?)
+ PROTOCOL=slip|cslip|adaptive
+ REMIP=<remote ip4 address>
+ REMIP6=<remote ip6 address, normally unspecified>
+ fi
+
+elif DEVICE=br* ; then /* Bridge */
+
+ BRIDGE_DEVS=<list of devices betwen which do bridging>
+ Note: separation configuration for devices in this list
+ should be avoided !
+ AGEING=<ethernet (MAC) address ageing time in seconds>
+ GCINT=<garbage collection interval time for the bridge in seconds>
+
+ SPANNING_TREE=yes|no (enable SPT - Spanning Tree Protocol)
+ if SPANNING_TREE=yes ; then
+ BRIDGEPRIO=<bridge's priority; 0-65535; less == better>
+ FD=<bridge forward delay time in seconds>
+ HELLO=<bridge hello time in seconds>
+ MAXAGE=<maximum message age in seconds>
+ PATHCOST_PORT=<port number>
+ PATHCOST=<cost of the port specified in PATHCOST_PORT>
+ Note: both PATHCOST_PORT and PATHCOST must be
+ specified to set cost of port
+ PORTPRIO_PORT=<port>
+ PORTPRIO=<port priority used by port selection algorithms;
+ a number between 0 and 255>
+ Note: see note above
fi
fi
{
echo "This will be executed after downing device !"
}
-
# (c) 1999 Grzegorz Stanislawski <stangrze@open.net.pl>
-# $Id: ifcfg-ppp0.leased1,v 1.4 2000/04/21 17:39:40 jajcus Exp $
+# $Id: ifcfg-ppp0.leased1,v 1.5 2001/05/15 16:03:43 baggins Exp $
# config file for setting up hardwired (leased) serial line.
# This configuration uses chats with modem, so You have to have an inteligent
# modem (AT commands compatible).
DEVICE=ppp0
CHATSCRIPT=/etc/sysconfig/interfaces/data/chat-ppp0.leased1
ONBOOT=yes
-IPADDR=192.168.255.254
+IPADDR=192.168.255.254/30
REMIP=192.168.255.253
-PREFIX=30
HARDFLOWCTL=yes
MODEMPORT=/dev/ttyS1
LINESPEED=115200
# (c) 1999 Grzegorz Stanislawski <stangrze@open.net.pl>
-# $Id: ifcfg-ppp0.leased2,v 1.3 1999/07/13 12:49:36 misiek Exp $
+# $Id: ifcfg-ppp0.leased2,v 1.4 2001/05/15 16:03:43 baggins Exp $
# config file for setting up hardwired (leased) serial line.
# This config assumes "transparent" modem (in ex. goramo), null modem
# cable or current loop.
# if You don't have any jumper YOU HAVE BEEN WARNED.
DEVICE=ppp0
ONBOOT=yes
-IPADDR=192.168.255.254
+IPADDR=192.168.255.254/30
REMIP=192.168.255.253
-PREFIX=30
HARDFLOWCTL=yes
MODEMPORT=/dev/ttyS1
LINESPEED=115200
-# $Id: ifcfg-sl0,v 1.2 1999/07/13 12:49:36 misiek Exp $
+# $Id: ifcfg-sl0,v 1.3 2001/05/15 16:03:43 baggins Exp $
#
DEVICE=sl0
IPADDR=195.164.211.2
LINESPEED=57600
REMIP=194.181.19.1
MTU=296
-DEFROUTE=yes
PROTOCOL=slip
# say no for dip && modem connection
# say yes for direct connection to for example router via slattach
-# $Id: tnlcfg-description,v 1.2 1999/09/15 10:15:35 misiek Exp $
+# $Id: tnlcfg-description,v 1.3 2001/05/15 16:03:43 baggins Exp $
#
# In this file you can also put all configuration data instead
# of using second file named ifcfg-tunnel_name.
MODE={ipip|gre|sit|ipxip}
+ONBOOT=yes|no
DEVICE=<device name>
-if MODE=ipxip ; then
+if MODE=ipxip ; then
?
-else MODE=ipip || MODE=gre || MODE=sit ; then
+elif MODE=ipip || MODE=gre || MODE=sit ; then
REMOTEADDR=<IPv4 addres>
[ LOCALADDR=<IPv4 addres> ]
[ TTL= ]
[ TOS= ]
- [ SEQ={no|yes} ]
- [ ISEQ={no|yes} ]
- [ OSEQ={no|yes} ]
- [ KEY= ]
- [ IKEY= ]
- [ OKEY= ]
- [ CSUM={no|yes} ]
- [ ICSUM={no|yes} ]
- [ OCSUM={no|yes} ]
[ PMTUDISC={no|yes} ]
+
+ if MODE=gre ; then
+
+ [ KEY= ]
+ [ IKEY= ]
+ [ OKEY= ]
+ [ ISEQ={no|yes} ]
+ [ ISEQ={no|yes} ]
+ [ OSEQ={no|yes} ]
+ [ CSUM={no|yes} ]
+ [ ICSUM={no|yes} ]
+ [ OCSUM={no|yes} ]
+
+ fi
+
+
+else MODE=four ; then
+
+ REMOTEADDR=<IPv6 addres>
+ LOCALADDR=<IPv6 addres>
+
+ [ PRIORITY= ]
+ [ HOPLIMIT= ]
+ [ ENCAPLIMIT= ]
+
fi
+ONBOOT=yes
MODE=sit
DEVICE=icm
REMOTEADDR=193.219.28.246
-# $Id: network,v 1.13 2001/05/13 18:39:37 kloczek Exp $
+# $Id: network,v 1.14 2001/05/15 16:03:42 baggins Exp $
######################################################################
# MAIN PART
-# Do you need networking ?
+# Do you need IPv4 or IPv6 networking ?
NETWORKING=yes
-# Do you need IPv6 networking, too ?
-IPV6_NETWORKING=no
+# Do you need IPv4 networking ?
+IPV4_NETWORKING=yes
+
+# Do you want IPv4 forwarding ?
+IPV4_FORWARDING=no
# Set hostname here (only hostname)
HOSTNAME=pldmachine
# Set domainname here
NISDOMAIN=
+# IPv4 gateway
GATEWAY=
GATEWAYDEV=
-GATEWAY6=
-GATEWAY6DEV=
-
# Do you want to use IPX networking ?
IPX=no
IPXAUTOPRIMARY=
IPXINTERNALNETNUM=
IPXINTERNALNODENUM=
+# Do you need IPv6 networking ?
+IPV6_NETWORKING=no
+
+# Do you want IPv6 forwarding ?
+IPV6_FORWARDING=no
+
+# Enable tunnel interfaces configuration ?
+IPV6_TUNNELCONFIG=no
+
+# IPv6 gateway
+GATEWAY6=
+GATEWAY6DEV=
+
+# Global route for IPv6 host with IPv6 forwarding
+IPV6_GLOBALROUTEGW=
+IPV6_GLOBALROUTEDEV=
+
# Reading configuration from LDAP
# Do you want to use LDAP?
# Do you want set static RARP table (based on /etc/ethers config file) ?
STATIC_RARP=no
-######################################################################
-# IPv4 goodies
-
-# Do you want enable IPv4 forwarding ?
-IPV4_FORWARDING=no
-
-# Do you want to enable IPv4 anti spoofing ?
-IPV4_ANTI_SPOOFING=
-
-# Kernel should accept ICMP redirect messages ?
-# The default is 'yes', if the kernel is configured for
-# a regular host; and 'no' for a router configuration.
-IPV4_ACCEPT_ICMP_REDIR=
-
-# Kernel should accept source routed packets ?
-# The default Is 'yes' for routers and 'no' for hosts.
-IPV4_ACCEPT_SOURCE_ROUTE=
-
-# Log packets with source addresses with no known route to kernel log ?
-IPV4_LOG_MARTIANS=
-
-# Do multicast routing ? The kernel needs to be compiled with
-# CONFIG_MROUTE and a multicast routing daemon is required.
-IPV4_MULTICAST=
-
-# Do proxy ARP ?
-IPV4_PROXY_ARP=
-
-# Accept ICMP redirect messages only for gateways, listed in
-# default gateway list ?
-IPV4_ACCEPT_ICMP_REDIR_GATE=
-
-# Send ICMP redirects to other hosts ?
-IPV4_SEND_ICMP_REDIR=
-
-# Ignore all ICMP echo requests ?
-IPV4_IGN_ALL_ICMP=
-
-# Ignore ICMP echo requests to broadcast and multicast addresses ?
-IPV4_IGN_CAST_ICMP=
-
-# Enable MTU discovery patch ? (KERNEL MUST SUPPORT THIS)
-# MTU (maximal transfer unit) is the size of the chunks we send out
-# over the net. "Path MTU Discovery" means that, instead of always
-# sending very small chunks, we start out sending big ones and if we
-# then discover that some host along the way likes its chunks smaller,
-# we adjust to a smaller size.
-IPV4_MTU_DISCOVERY=
-
-# Enable debugging of IP masquerading ?
-IPV4_MASQ_DEBUGGING=
-
-# Bug-to-bug compatibility with some broken printers. On retransmit
-# try to send bigger packets to work around bugs in certain TCP
-# stacks. Can be turned off by setting IPV4_RETRANS_COLLAPSE to ,,yes''.
-IPV4_RETRANS_COLLAPSE=
-
-# Disable select acknowledgments after RFC2018 ?
-# TCP may experience poor performance when multiple packets are lost
-# from one window of data. With the limited information available
-# from cumulative acknowledgments, a TCP sender can only learn about a
-# single lost packet per round trip time. An aggressive sender could
-# choose to retransmit packets early, but such retransmitted segments
-# may have already been successfully received.
-IPV4_NO_SELECT_ACK=
-
-# Disable timestamps as defined in RFC1323 ?
-# Timestamps are designed to provide compatible interworking with
-# TCP's that do not implement the TCP Extensions for High Performance
-IPV4_NO_TIMESTAMPS=
-
-# Enable the strict RFC793 interpretation of the TCP urgent pointer field.
-IPV4_RFC793=
-
-# Enable SYN flood protection ?
-IPV4_SYN_COOKIES=
-
-# Disable window scaling as defined in RFC1323 ?
-# The window scale extension expands the definition of the TCP
-# window to 32 bits and then uses a scale factor to carry this
-# 32-bit value in the 16-bit Window field of the TCP header.
-IPV4_NO_WINDOW_SCALING=
-
-# Enable dynamic socket address rewriting on interface address change.
-# This is useful for dialup interface with changing IP addresses.
-# (default no)
-# IPV4_DYNAMIC_IP_PATCH_VALUE - value from 1 to 9
-IPV4_DYNAMIC_IP_PATCH=
-IPV4_DYNAMIC_IP_PATCH_VALUE=
-
-# Range of ports used by TCP and UDP to choose the local
-# port. Contains two numbers, the first number is the lowest port,
-# the second number the highest local port. Default is "1024 4999".
-# Should be changed to "32768 61000" for high-usage systems.
-IPV4_LOCAL_PORT_RANGE="1024 4999"
-
-######################################################################
-# IPv6 goodies
-
-# Do you want enable IPv6 forwarding ?
-IPV6_FORWARDING=no
-
-# Global route for IPv6 host with IPv6 forwarding
-IPV6_GLOBALROUTE=
-IPV6_GLOBALROUTEDEV=
-
-# Enable tunnel interfaces configuration ?
-IPV6_TUNNELCONFIG=no
-
-# Start Classic router discovery daemon ?
-# You need iputils package installed for this option.
-IPV6_RDISC=no
-
-# rdisc mode: "host" or "router". Default: "host".
-IPV6_RDISC_MODE=host
-
-# Do you want IPv6 address autoconfiguration? Kernel default is yes.
-IPV6_AUTOCONF=
+# Specify interface on which you want to enable tleds software
+# (also you need tleds package installed) -- default set to no
+TLEDS_DEV=no
-# Do you want kernel to add default route for IPv6 interfaces if
-# there is no router on the link? Kernel default is yes.
-# Kernel 2.4.0-test? or later (after ANK accepts my patch - baggins).
-#IPV6_AUTOCONF_ROUTE=
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
networkscriptsdir = @networkscriptsdir@
networkscripts_SCRIPTS = \
+ ifdown-br \
ifdown-ppp \
ifdown-post \
ifdown-sl \
ifup-aliases \
+ ifup-br \
ifup-ipx \
ifup-plip \
ifup-post \
#!/bin/sh
#
-# $Id: ifdown,v 1.26 2000/11/16 15:58:55 baggins Exp $
+# $Id: ifdown,v 1.27 2001/05/15 16:03:44 baggins Exp $
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
+
+# Will be removed in the future
+if is_yes "$NETWORKING" ; then
+ if [ -z "$IPV4_NETWORKING" ] ; then
+ echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
+ echo "Please upgrade your config"
+ echo "Assuming you want IPv4 networking"
+ IPV4_NETWORKING=yes
+ fi
+fi
+
DEV=$1
[ -z "$DEV" ] && {
- echo "usage: ifdown <device name>" >&2
+ nls "usage: %s <device name>" "ifdown" >&2
exit 1
}
-. /etc/sysconfig/network
-. /etc/rc.d/init.d/functions
-. /etc/sysconfig/network-scripts/.functions
-
if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ] ; then
CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV"
else
CONFIG="$DEV"
fi
-if [ `id -u` != 0 ]; then
+if [ "$(id -u)" != "0" ]; then
if [ -x /sbin/usernetctl ]; then
exec /sbin/usernetctl $CONFIG down
fi
source_config
-if [ "$BOOTPROTO" = bootp ]; then
- DYNIP=pump
-fi
-
-if [ "$BOOTPROTO" = "dhcp" ]; then
- DYNIP=dhcpcd
-fi
+# set all major variables
+setup_ip_param
-# IPv4, IPv6 or both ?
-[ -n "$IPV6_ADDR" ] && IPv6=yes || IPv6=no
-[ -n "$IPADDR" -o -n "$DYNIP" ] && IPv4=yes || IPv4=no
+OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}"
-if [ -z "$PREFIX" -a -n "$NETMASK" ]; then
- PREFIX="`calcprefix $NETMASK`"
+# shutdown tleds software
+if [ "$TLEDS_DEV" = "$DEVICE" -a -x /usr/bin/tleds ]; then
+ /usr/bin/tleds -qk "$DEVICE"
fi
-
-if [ -z "$NETMASK" -a -n "$PREFIX" ]; then
- NETMASK="`calcnetmask $PREFIX`"
+
+if [ -x $OTHERSCRIPT ]; then
+ if [ "$HANDLING" = "0" ]; then
+ exec $OTHERSCRIPT $CONFIG $2
+ elif [ "$HANDLING" = "1" ]; then
+ $OTHERSCRIPT $CONFIG $2
+ fi
fi
-FULLDEVNAME="$DEVICE"
-# detect network device type (ie. dummy, eth for dummy0, eth0 ..)
-DEVICETYPE=$(echo $DEVICE | awk ' { gsub(/[0-9]*$/,NUL); print $0 } ')
-# real name of device (ie. is eth0 for eth0,eth0:1,eth0:alias)
-DEVICE=$(echo $DEVICE | awk ' { gsub(/:.*$/,NUL); print $0 } ')
-OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}"
+# Check to make sure the device is actually up
+check_device_down && exit 0
-if [ -x $OTHERSCRIPT ]; then
- if [ "$DEFAULTHANDLING" = "yes" ]; then
- $OTHERSCRIPT $CONFIG $2
- else
- $OTHERSCRIPT $CONFIG $2
- exit $?
+if [ "$BOOTPROTO" = "bootp" -o "$BOOTPROTO" = "pump" ]; then
+ /sbin/pump -r -i ${DEVICE}
+ RESULT=$?
+fi
+
+if [ "$BOOTPROTO" = "dhcp" ]; then
+ if [ -x /sbin/dhcpcd ];then
+ /sbin/dhcpcd -k ${DEVICE}
+ RESULT=$?
+ elif [ -x /sbin/dhclient ];then
+ if [ -f /var/run/dhclient.pid ];then
+ PID=$(cat /var/run/dhclient.pid)
+ if ps ax --no-header|grep -q $PID;then
+ kill $PID
+ RESULT=$?
+ fi
+ fi
+ elif [ -x /sbin/dhcpxd ];then
+ /sbin/dhcpxd -k ${DEVICE}
+ RESULT=$?
+ elif [ -x /sbin/pump ];then
+ pump -r -i ${DEVICE}
+ RESULT=$?
fi
fi
-if echo "$FULLDEVNAME" | grep -q ':' ; then
- ISALIAS=yes
-else
- ISALIAS=no
+ip link set ${DEVICE} down
+ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
+
+if [ "$HANDLING" = "4" ]; then
+ exit 0
fi
-if [ "$ISALIAS" = "yes" ]; then
- if [ "$IPv4" = "yes" ]; then
- ip -family inet addr del ${IPADDR}/${PREFIX} dev ${DEVICE} label ${FULLDEVNAME}
- fi
- for ADDR in ${IPV6_ADDR} ; do
- ip -family inet6 addr del ${ADDR} dev ${DEVICE} label ${FULLDEVNAME}
- done
-else
- if [ "$DYNIP" = "dhcpcd" ]; then
- /sbin/dhcpcd -k $FULLDEVNAME
- fi
- ip link set ${DEVICE} down
- ip addr flush dev ${DEVICE} 2> /dev/null
+if [ "$RESULT" -ne "0" ]; then
+ return $RESULT
fi
exec /etc/sysconfig/network-scripts/ifdown-post $CONFIG
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
--- /dev/null
+#!/bin/sh
+#
+# ifdown-br - bridge configuration script
+# Copyright (C) 2000 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# $Id: ifdown-br,v 1.2 2001/05/15 16:05:08 baggins Exp $
+#
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
+
+CONFIG=$1
+source_config
+
+if [ "foo$2" = "fooboot" ] && is_no "${ONBOOT}"; then
+ exit
+fi
+
+if [ ! -x /sbin/brctl ]; then
+ nls "%s is missing. Can't continue." "/sbin/brctl"
+ exit 1
+fi
+
+# set all major variables
+setup_ip_param
+
+# set device down and forget all addresses
+for device in ${BRIDGE_DEVS} ${DEVICE}; do
+ ip link set ${device} down
+ ip addr flush dev ${device} 2>&1 | grep -v "Nothing to flush"
+ brctl delif ${DEVICE} ${device}
+done
+
+brctl delbr ${DEVICE}
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifdown-post,v 1.11 2000/11/16 15:58:55 baggins Exp $
+# $Id: ifdown-post,v 1.12 2001/05/15 16:03:44 baggins Exp $
#
# This should be called whenever an interface goes down, not just when
# it is brought down explicitly.
source_config
-# full device name as specified by user
-FULLDEVNAME="$DEVICE"
-# detect network device type (ie. dummy, eth for dummy0, eth0 ..)
-DEVICETYPE=$(echo $DEVICE | awk ' { gsub(/[0-9]*$/,NUL); print $0 } ')
-# real name of device (ie. is eth0 for eth0,eth0:1,eth0:alias)
-DEVICE=$(echo $DEVICE | awk ' { gsub(/:.*$/,NUL); print $0 } ')
-
-if echo "$FULLDEVNAME" | grep -q ':' ; then
- ISALIAS=yes
-else
- ISALIAS=no
+# set all major variables
+setup_ip_param
+
+# set REALDEVICE
+get_ppp_device_and_pid
+
+# Delete root queueing discipline
+if [ -n "$QDISC" ]; then
+ tc qdisc del dev "$REALDEVICE" root $QDISC
fi
-# execute run_up() function (if available in device configuration file)
-[ "$ISALIAS" = "no" ] && run_down
+# execute run_down() function (if available in device configuration file)
+run_down
# Notify programs that have requested notification
do_netreport
exit 0
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifdown-ppp,v 1.9 2000/04/21 17:44:22 jajcus Exp $
+# $Id: ifdown-ppp,v 1.10 2001/05/15 16:03:44 baggins Exp $
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
exit 0
fi
+# set all major variables
+setup_ip_param
+
get_ppp_device_and_pid
if [ -z "$PID" ]; then
# pppd might have chat as a child; remember chat's pid to kill after pppd.
# (After, not before, so that pppd doesn't just restart it).
-CHATPID=`ps axl | awk '$4 ~ /^'"$PID"'$/ {print $3}' 2>/dev/null`
+CHATPID=$(ps axl | awk '$4 ~ /^'"$PID"'$/ {print $3}' 2>/dev/null)
kill $PID > /dev/null 2>&1
[ -n "$CHATPID" ] && kill $CHATPID > /dev/null 2>&1
fi
exit 1
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifdown-sl,v 1.10 2000/06/12 08:38:15 waszi Exp $
+# $Id: ifdown-sl,v 1.11 2001/05/15 16:03:44 baggins Exp $
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
CONFIG=$1
source_config
+# set all major variables
+setup_ip_param
+
# signals ifup-sl not to persist
rm -f /var/run/sl-$DEVICE.dev
# we can use dip or direct slip connection via slattach
if is_no "$DIRECT_CONNECT"; then
-PID=`pidof dip-$DEVICE`
+PID=$(pidof dip-$DEVICE)
else
-PID=`pidof slattach`
+PID=$(pidof slattach)
for x in $PID; do
if grep -q "$MODEMPORT" /proc/$x/cmdline; then
- logger -p daemon.info -t ifdown-sl "signal TERM send to \"`ps -o cmd= $x`\" - this should be slattach"
+ logger -p daemon.info -t ifdown-sl "signal TERM send to \"$(ps -o cmd= $x)\" - this should be slattach"
kill -TERM $x
PID=$x
fi
# Grab the PID of connected dial-out daemon.
#
if [ -z "$PID" ]; then
- PID=`pidof -- -dip\ \($IPADDR\)`
+ PID=$(pidof -- -dip\ \($IPADDR\))
fi
if [ -z "$PID" ]; then
exit 1
kill -KILL $PID > /dev/null 2>&1
if [ -d /proc/$PID ]; then
- logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" &
+ logger -p daemon.info -t ifdown-sl "ifdown-sl unable to kill sl-$DEVICE" &
else
/etc/sysconfig/network-scripts/ifdown-post $1
fi
exit 1
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup,v 1.55 2001/05/13 17:10:19 baggins Exp $
+# $Id: ifup,v 1.56 2001/05/15 16:03:44 baggins Exp $
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network-scripts/.functions
+# Will be removed in the future
+if is_yes "$NETWORKING" ; then
+ if [ -z "$IPV4_NETWORKING" ] ; then
+ echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
+ echo "Please upgrade your config"
+ echo "Assuming you want IPv4 networking"
+ IPV4_NETWORKING=yes
+ export IPV4_NETWORKING
+ fi
+fi
+
need_hostname
+# device name must be ifcfg-somename
DEV=$1
[ -z "$DEV" ] && {
- nls "usage: ifup <device name>" >&2
+ nls "usage: %s <device name>" "ifup" >&2
exit 1
}
if [ `id -u` != 0 ]; then
- if [ -u /sbin/usernetctl ]; then
+ if [ -x /sbin/usernetctl ]; then
exec /sbin/usernetctl $DEV up
fi
nls "Users cannot control this device." >&2
IPSETUP=no
-# full network device name
-FULLDEVNAME="$DEVICE"
-# detect network device type (ie. dummy, eth for dummy0, eth0 ..)
-DEVICETYPE=$(echo $DEVICE | awk ' { gsub(/[0-9]*$/,NUL); print $0 } ')
-# real name of device (ie. is eth0 for eth0,eth0:1,eth0:alias)
-DEVICE=$(echo $DEVICE | awk ' { gsub(/:.*$/,NUL); print $0 } ')
-
-if echo "$FULLDEVNAME" | grep -q ':' ; then
- ISALIAS=yes
-else
- ISALIAS=no
-fi
-
-# Old BOOTP variable
-if is_yes "$BOOTP"; then
- BOOTPROTO=bootp
-fi
-
-if [ "$BOOTPROTO" = bootp ]; then
- DYNIP=pump
-fi
-
-if [ "$BOOTPROTO" = "dhcp" ]; then
- DYNIP=dhcpcd
-fi
-
-# IPv4, IPv6 or both ?
-[ -n "$IPV6_ADDR" ] && IPv6=yes || IPv6=no
-[ -n "$IPADDR" -o -n "$DYNIP" ] && IPv4=yes || IPv4=no
-
-# Tunnel device ?
-[ -f /etc/sysconfig/interfaces/tnlcfg-${FULLDEVNAME} ] && TNL=yes || TNL=no
-
-if [ "$TNL" = "yes" ]; then
- TNLOPTS="onlink"
-fi
-
-if [ -z "$PREFIX" -a -z "$NETMASK" ]; then
- PREFIX="32"
-fi
-
-if [ -z "$PREFIX" -a -n "$NETMASK" ]; then
- PREFIX="`calcprefix $NETMASK`"
-fi
-
-if [ -z "$NETMASK" -a -n "$PREFIX" ]; then
- NETMASK="`calcnetmask $PREFIX`"
-fi
-
-is_yes "$MULTICAST" && MULTICAST=on || MULTICAST=off
-[ -n "$SRC_ADDR" ] && SRC_ADDR="src ${SRC_ADDR}" || SRC_ADDR=""
-[ -n "$SCOPE" ] && SCOPE="scope ${SCOPE}" || SCOPE=""
-
-if [ "$ARP" ]; then
- is_yes "$ARP" && ARP=on || ARP=off
-elif [ "$DEVICETYPE" = "eth" ]; then
- ARP=on
-else
- ARP=off
-fi
+# set all major variables
+setup_ip_param
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
if [ -x "$OTHERSCRIPT" ]; then
- if [ "$DEFAULTHANDLING" = "yes" ]; then
+ if [ "$HANDLING" = "0" ]; then
+ exec $OTHERSCRIPT $CONFIG $2
+ elif [ "$HANDLING" = "1" ]; then
$OTHERSCRIPT $CONFIG $2
- else
- exec $OTHERSCRIPT $CONFIG $2
fi
fi
# is this device available? (this catches PCMCIA devices for us)
if ! (/sbin/ip link set multicast ${MULTICAST} dev ${DEVICE} > /dev/null 2>&1); then
- echo "Delaying ${FULLDEVNAME} initialization."
- exit 0
+ nls "Delaying %s initialization" ${DEVICE}
+ exit 1
fi
-if [ "$SLAVE" = "yes" -a "$ISALIAS" = "no" -a "$MASTER" != "" -a -x /sbin/ifenslave ]; then
- RFLAG="" ; [ "${RECIEVE-ONLY}" = "yes" ] && RFLAG="-r"
+if is_yes "$SLAVE" && [ -n "$MASTER" -a -x /sbin/ifenslave ]; then
+ RFLAG="" && is_yes "${RECIEVE-ONLY}" && RFLAG="-r"
ip link set ${DEVICE} down
- echo "Enslaving $DEVICE to $MASTER"
+ nls "Enslaving %s to %s" "$DEVICE" "$MASTER"
ifenslave $RFLAG "$MASTER" "$DEVICE"
exit 0
ip link set ${DEVICE} address ${MACADDR}
fi
-if [ -n "$DYNIP" -a "$ISALIAS" = "no" ]; then
-
- echo -n "`nls 'Determining IP information for %s' $FULLDEVNAME'...'`"
- if [ "$DYNIP" = "pump" ]; then
- if /sbin/pump -i $FULLDEVNAME ; then
- nls " done."
- else
- nls " failed."
- exit 1
- fi
- else
- if /sbin/dhcpcd $FULLDEVNAME $DHCPOPTIONS ; then
- nls " done."
- else
- nls " failed."
- exit 1
- fi
- fi
-
-else
-
- if [ "$IPv4" = "yes" ]; then
- if [ -z "$PREFIX" ]; then
- eval `/bin/ipcalc --prefix ${IPADDR}`
- fi
+ip link set ${DEVICE} multicast ${MULTICAST} arp ${ARP} down
- if [ -z "$BROADCAST" ]; then
- eval `/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}`
- fi
+if is_yes "${IPV6_NETWORKING}" && is_yes "${IPV6_DISABLE_AUTOCONF}"; then
+ run_cmd "Disabling IPv6 autoconfiguration" sysctl -w net.ipv6.conf.${DEVICE}=0
+fi
+
+if [ "$HANDLING" = "2" ]; then
+ exit 0
+fi
- if [ -z "$NETWORK" ]; then
- eval `/bin/ipcalc --network ${IPADDR} ${NETMASK}`
- fi
- fi
+if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" ]; then
- # IPv4 rules
- if [ "$IPv4" = "yes" ]; then
- if [ -n "$REMIP" ]; then
- ip -family inet addr add ${IPADDR} peer ${REMIP} dev ${DEVICE} label ${FULLDEVNAME} ${SCOPE}
- else
- ip -family inet addr add ${IPADDR}/${PREFIX} broadcast ${BROADCAST} dev ${DEVICE} label ${FULLDEVNAME} ${SCOPE}
+ if is_yes "$IPV4_NETWORKING"; then
+ if [ "$BOOTPROTO" = "bootp" -o "$BOOTPROTO" = "pump" ]; then
+ DHCP_CLIENT=/sbin/pump
fi
- # Another IPv4 aliases support
- for ADDR4 in ${IPADDR_ALIASES} ; do
- ip -family inet addr add ${ADDR4} dev ${DEVICE} label ${FULLDEVNAME} broadcast \+
- done
- fi
-
- ip link set ${DEVICE} multicast ${MULTICAST} arp ${ARP} up
-
- # IPv6 rules
- if is_yes "${IPV6_NETWORKING}"; then
- proc_net ipv6/conf/${DEVICE}/autoconf start 0 1 IPV6_AUTOCONF "IPv6 address autoconfiguration on ${DEVICE}"
-
- for ADDR6 in ${IPV6_ADDR} ; do
- ip -family inet6 addr add ${ADDR6} dev ${DEVICE} label ${FULLDEVNAME}
- done
-
- if is_no "${IPV6_FORWARDING}" ; then
- if [ "${GATEWAY6}" != "" ]; then
- if [ "${GATEWAY6DEV}" = "" -o "${GATEWAY6DEV}" = "${FULLDEVNAME}" ]; then
- # set up default gateway
- ip -family inet6 route add default via ${GATEWAY6} dev ${DEVICE}
- fi
+
+ if [ -z "$DHCP_CLIENT" ]; then
+ if [ -x /sbin/dhcpcd ]; then
+ DHCP_CLIENT=/sbin/dhcpcd
+ elif [ -x /sbin/dhclient ]; then
+ DHCP_CLIENT=/sbin/dhclient
+ elif [ -x /sbin/dhcpxd ]; then
+ DHCP_CLIENT=/sbin/dhcpxd
+ elif [ -x /sbin/pump ]; then
+ DHCP_CLIENT=/sbin/pump
+ else
+ nls "Can't find a dhcp client."
+ exit 1
+ fi
fi
- else
- if [ "${IPV6_GLOBALROUTE}" != "" ] ; then
- if [ "${IPV6_GLOBALROUTEDEV}" = "" -o "${IPV6_GLOBALROUTEDEV}" = "${FULLDEVNAME}" ]; then
- ip -family inet6 route add 2000::/3 via ${IPV6_GLOBALROUTE} dev ${DEVICE}
- fi
+
+ DHCP_ARGS=
+ if [ -n "$DHCP_CLIENT" ]; then
+ case $(basename $DHCP_CLIENT) in
+ pump)
+ [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
+ DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
+ ;;
+ dhcpcd)
+ [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
+ DHCP_ARGS="$DHCP_ARGS $DEVICE"
+ ;;
+ dhcpxd)
+ [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-H $DHCP_HOSTNAME"
+ DHCP_ARGS="$DHCP_ARGS $DEVICE"
+ ;;
+ dhclient)
+ # Can't specify a host with dhclient ?
+ DHCP_ARGS="$DEVICE"
+ ;;
+ esac
fi
- fi
- fi
-
- if [ "${GATEWAY}" != "" ]; then
- if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${FULLDEVNAME}" ]; then
- # set up default gateway
- ip -family inet route add default via ${GATEWAY} dev ${DEVICE} ${SRC_ADDR} ${TNLOPTS}
- DEFGW=${GATEWAY}
+ DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS"
+
+ if ! run_cmd "$(nls 'Determining IP information for') $DEVICE ($(basename $DHCP_CLIENT))" $DHCP_CLIENT $DHCP_ARGS ; then
+ exit 1
fi
+
+ # give time for determining IP information
+ check_device_down && sleep 1 && check_device_down && sleep 3
+ check_device_down && ip link set ${DEVICE} up
fi
- if [ "$BOOTPROTO" = bootp -a "$ISALIAS" = no ]; then
- if [ -n "$GATEWAYS" ]; then
- for gw in $GATEWAYS; do
- if [ "$gw" != "${DEFGW}" ]; then
- ip -family inet route add default via $gw dev ${DEVICE} ${SRC_ADDR} ${TNLOPTS}
- fi
- done
- fi
+else
- if [ -n "$DNSSRVS" -a -n "$SEARCH" ]; then
- echo "search $SEARCH" > /etc/resolv.conf
- for dns in $DNSSRVS; do
- echo "nameserver $dns" >> /etc/resolv.conf
- done
+ # IPv4 in use ?
+ if is_yes "$IPV4_NETWORKING" ; then
+ # If broadcast is missing then autocalculate it
+ if ! (echo $IP4ADDROPT | egrep -q "brd|broadcast"); then
+ IP4ADDROPT="brd + ${IP4ADDROPT}"
fi
- if [ -n "$BOOTPHOSTNAME" -a -n "$NEEDHOSTNAME" ]; then
- set_hostname $BOOTPHOSTNAME
+ if [ -n "$REMIP" ]; then
+ ip addr add ${IP4ADDR} peer ${REMIP} dev ${DEVICE} ${IP4ADDROPT}
+ else
+ ip addr add ${IP4ADDR} dev ${DEVICE} ${IP4ADDROPT}
fi
fi
+
+ # Set device up
+ ip link set ${DEVICE} up
+
+ # IPv6 in use ?
+ if is_yes "$IPV6_NETWORKING" ; then
+ ip addr add ${IP6ADDR} dev ${DEVICE} ${IP6ADDROPT}
+ fi
+
+ # IPv4/6 gateways and default routes
+ setup_ip_gw_ro
+fi
+
+if [ "$HANDLING" = "3" ]; then
+ exit 0
fi
if is_yes "$IPX"; then
/etc/sysconfig/network-scripts/ifup-ipx $DEVICE
fi
+if [ "$HANDLING" = "4" ]; then
+ exit 0
+fi
+
exec /etc/sysconfig/network-scripts/ifup-post $CONFIG
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup-aliases,v 1.10 2000/06/12 08:38:15 waszi Exp $
+# $Id: ifup-aliases,v 1.11 2001/05/15 16:03:44 baggins Exp $
#
-# adds aliases of device $1
+# adds all addresses of device $1
. /etc/sysconfig/network
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network-scripts/.functions
-if [ "$1" = "" ]; then
- echo "usage: $0 <net-device>"
- exit 1
-fi
+# device name must be ifcfg-somename
+DEV=$1
+
+[ -z "$DEV" ] && {
+ nls "usage: %s <device name>" "ifup-aliases" >&2
+ exit 1
+}
-# bash 2 is so much fun.
-if [ "$BASH_VERSINFO" ]; then
- shopt -s nullglob
+if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ] ; then
+ CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV"
else
- allow_null_glob_expansion=foo
+ CONFIG="$DEV"
fi
-cd /etc/sysconfig/interfaces/
+source_config
-for alias in ifcfg-$1:* ; do
- [ -f $alias ] && /sbin/ifup $alias
+# set all major variables
+setup_ip_param
+
+# Add all addresses
+for IP_ADDR in $IPADDR_ALIASES; do
+ IP_ADDR_OPT=""
+ IP_ROUTE_OPT=""
+
+ [ -z "$IP_ADDR" ] && continue
+ # Be sure that primary address is added
+ if [ "$IP_ADDR" = "$IP4ADDR" -o "$IP_ADDR" = "$IP6ADDR" ]; then
+ if (ip addr show dev $DEVICE | egrep -q "[[:space:]]${IP_ADDR}[[:space:]]"); then
+ continue
+ fi
+ fi
+ if is_yes "${IPV4_NETWORKING}"; then
+ # If broadcast is missing then autocalculate it
+ if ! (echo $IP_ADDR_OPT | egrep -q "brd|broadcast"); then
+ IP_ADDR_OPT="brd + ${IP_ADDR_OPT}"
+ fi
+ ip -4 addr add ${IP_ADDR} dev ${DEVICE} ${IP_ADDR_OPT}
+ fi
done
-for alias in `find_ldap_aliases` ; do
- /sbin/ifup $alias
+for IP_ADDR in $IPV6_ADDR; do
+ IP_ADDR_OPT=""
+ IP_ROUTE_OPT=""
+
+ [ -z "$IP_ADDR" ] && continue
+ # Be sure that primary address is added
+ if [ "$IP_ADDR" = "$IP4ADDR" -o "$IP_ADDR" = "$IP6ADDR" ]; then
+ if (ip addr show dev $DEVICE | egrep -q "[[:space:]]${IP_ADDR}[[:space:]]"); then
+ continue
+ fi
+ fi
+ # Check for IPv6 address
+ if (echo $IP_ADDR | grep -q ":"); then
+ if is_yes "${IPV6_NETWORKING}"; then
+ ip -6 addr add ${IP_ADDR} dev ${DEVICE} ${IP_ADDR_OPT}
+ fi
+ elif is_yes "${IPV4_NETWORKING}"; then
+ # If broadcast is missing then autocalculate it
+ if ! (echo $IP_ADDR_OPT | egrep -q "brd|broadcast"); then
+ IP_ADDR_OPT="brd + ${IP_ADDR_OPT}"
+ fi
+ ip -4 addr add ${IP_ADDR} dev ${DEVICE} ${IP_ADDR_OPT}
+ fi
done
-if [ "$BASH_VERSINFO" ]; then
- shopt -u nullglob
-else
- unset allow_null_glob_expansion
+for nr in $(awk 'BEGIN { for (j=1; j<256; j++) print j}'); do
+ eval IP_ADDR="\$IPADDR${nr}"
+ eval IP_ADDR_OPT="\$IP_AOPTS${nr}"
+ eval IP_ROUTE_OPT="\$IP_ROPTS${nr}"
+
+ [ -z "$IP_ADDR" ] && continue
+ # Be sure that primary address is added
+ if [ "$IP_ADDR" = "$IP4ADDR" -o "$IP_ADDR" = "$IP6ADDR" ]; then
+ if (ip addr show dev $DEVICE | egrep -q "[[:space:]]${IP_ADDR}[[:space:]]"); then
+ continue
+ fi
+ fi
+ # Check for IPv6 address
+ if (echo $IP_ADDR | grep -q ":"); then
+ if is_yes "${IPV6_NETWORKING}"; then
+ ip -6 addr add ${IP_ADDR} dev ${DEVICE} ${IP_ADDR_OPT}
+ fi
+ elif is_yes "${IPV4_NETWORKING}"; then
+ # If broadcast is missing then autocalculate it
+ if ! (echo $IP_ADDR_OPT | egrep -q "brd|broadcast"); then
+ IP_ADDR_OPT="brd + ${IP_ADDR_OPT}"
+ fi
+ ip -4 addr add ${IP_ADDR} dev ${DEVICE} ${IP_ADDR_OPT}
+ fi
+done
+
+# Setup IPv4-compatible addresses
+if is_yes "$IPV6_NETWORKING" && [ "$BOOTMETHOD6" = "v4compat" ]; then
+ # enable automatic tunnels
+ ip link set sit0 up
+
+ # add v4compat addresses to device
+ for addr in $(ip -4 addr show scope global dev $DEVICE | \
+ awk '/inet/ { print $2 }' | awk -F"/" '{ print $1 }'); do
+ ip -6 addr add ::$addr dev $DEVICE
+ done
fi
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
--- /dev/null
+#!/bin/sh
+#
+# ifup-br - bridge configuration script
+# Copyright (C) 2000 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# $Id: ifup-br,v 1.2 2001/05/15 16:05:08 baggins Exp $
+#
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
+
+CONFIG=$1
+source_config
+
+if [ "foo$2" = "fooboot" ] && is_no "${ONBOOT}"; then
+ exit
+fi
+
+if [ ! -x /sbin/brctl ]; then
+ nls "%s is missing. Can't continue." "/sbin/brctl"
+ exit 1
+fi
+
+# load bridge module
+is_module "bridge" && modprobe -s -k bridge
+
+# set all major variables
+setup_ip_param
+
+# set device down and forget all addresses
+for device in $BRIDGE_DEVS; do
+ ip link set ${device} down
+ ip addr flush dev ${device} 2>&1 | grep -v "Nothing to flush"
+done
+
+brctl addbr ${DEVICE}
+
+# add interfaces to bridge
+for device in $BRIDGE_DEVS; do
+ brctl addif ${DEVICE} ${device}
+ ip link set dev ${DEVICE} multicast ${MULTICAST} arp ${ARP}
+ ip link set ${device} up
+done
+
+
+# standard
+[ -n "$AGEING" ] && brctl setageing "$AGEING"
+[ -n "$GCINT" ] && brctl gcint "$GCINT"
+
+# spanning tree protocol
+if is_yes "$SPANNING_TREE"; then
+ brctl stp ${DEVICE} yes
+ [ -n "$BRIDGEPRIO" ] && brctl bridgeprio ${DEVICE} "$BRIDGEPRIO"
+ [ -n "$FD" ] && brctl fd ${DEVICE} "$FD"
+ [ -n "$HELLO" ] && brctl hello ${DEVICE} "$HELLO"
+ [ -n "$MAXAGE" ] && brctl maxage ${DEVICE} "$MAXAGE"
+ [ -n "$PATHCOST" -a -n "$PATHCOST_PORT" ] && brctl pathcost ${DEVICE} "$PATHCOST_PORT" "$PATHCOST"
+ [ -n "$PORTPRIO" -a -n "$PORTPRIO_PORT" ] && brctl portprio ${DEVICE} "$PORTPRIO_PORT" "$PORTPRIO"
+else
+ brctl stp ${DEVICE} no
+fi
+
+ip link set dev ${DEVICE} multicast ${MULTICAST} arp ${ARP}
+if ! (ip link set dev ${DEVICE} up); then
+ nls "problems with setting bridge %s" "${DEVICE}"
+ exit 1
+fi
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup-ipx,v 1.9 2000/04/07 19:16:11 baggins Exp $
+# $Id: ifup-ipx,v 1.10 2001/05/15 16:03:44 baggins Exp $
#
# configures IPX on $1 if appropriate
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
if [ "$1" = "" ]; then
- echo "usage: $0 <net-device>"
+ nls "usage: %s <device name>" "ifup-ipx" >&2
exit 1
fi
-if [ ! -x /usr/bin/ipx_interface ] ; then
- # cannot configure IPX with non-existant utilities
+if is_no "$IPX"; then
exit 0
fi
-. /etc/sysconfig/network
-
-case $IPX in yes|true) ;; *) exit 0 ;; esac
+if [ ! -x /usr/bin/ipx_interface ] ; then
+ nls "%s is missing. Can't continue." "/usr/bin/ipx_interface"
+ exit 1
+fi
cd /etc/sysconfig/network-scripts
-. /etc/rc.d/init.d/functions
-. /etc/sysconfig/network-scripts/.functions
CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config
-[ -z $IPXFRAMETYPE ] && exit 0
-
-case $IPXPRIMARY in
- yes|true) primary=-p ;;
- *) primary= ;;
-esac
-
-ip link set $DEVICE up
-/usr/bin/ipx_interface add $DEVICE $primary $IPXFRAMETYPE $IPXNETWORK
+# set all major variables
+setup_ip_param
+
+# add ipx for all frame types
+for frametype in '802.2' '802.2TR' '802.3' 'EtherII' 'SNAP'; do
+ framename=$(echo $frametype | awk ' { gsub(/\./,"_"); print $0 } ')
+ case $(eval echo $(echo \$`echo IPXACTIVE_$framename`)) in
+ yes|true)
+ case $(eval echo $(echo \$`echo IPXPRIMARY_$framename`)) in
+ yes|true) primary="-p" ;;
+ *) primary= ;;
+ esac
+
+ ip link set $DEVICE up
+ /usr/bin/ipx_interface add $primary $DEVICE $frametype \
+ $(eval echo $(echo \$`echo IPXNETNUM_$framename`))
+ ;;
+ esac
+done
exit 0
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup-plip,v 1.11 2001/02/23 18:06:48 baggins Exp $
+# $Id: ifup-plip,v 1.12 2001/05/15 16:03:44 baggins Exp $
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
-CONFIG=$1
. /etc/sysconfig/network
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network-scripts/.functions
+CONFIG=$1
source_config
if [ "foo$2" = "fooboot" ] && is_no "${ONBOOT}"; then
exit
fi
-ip link set ${DEVICE} up
-ip -family inet addr add ${IPADDR}/32 peer ${REMIP} dev ${DEVICE}
-ip -family inet route add ${NETWORK}/${PREFIX} dev ${DEVICE}
+# set all major variables
+setup_ip_param
+
+if is_yes "$IPV4_NETWORKING"; then
+ if [ -n "$IP4ADDR" ]; then
+ ip -4 addr add ${IP4ADDR} peer ${REMIP} dev ${DEVICE}
+ fi
+fi
-if [ "${GATEWAY}" != "" ]; then
- if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
- # set up default gateway
- ip -family inet route add default via ${GATEWAY}
+if is_yes "$IPV6_NETWORKING"; then
+ if [ -n "$IP6ADDR" ]; then
+ ip -6 addr add ${IP6ADDR} dev ${DEVICE}
fi
fi
+ip link set dev ${DEVICE} up
+
+. /etc/sysconfig/network
+
+# IPv4/6 gateways and default routes
+setup_ip_gw_ro
+
/etc/sysconfig/network-scripts/ifup-post $1
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup-post,v 1.22 2000/11/16 15:58:55 baggins Exp $
+# $Id: ifup-post,v 1.23 2001/05/15 16:03:44 baggins Exp $
#
run_up() { :; }
CONFIG=$1
source_config
-# full device name as specified by user
-FULLDEVNAME="$DEVICE"
-# detect network device type (ie. dummy, eth for dummy0, eth0 ..)
-DEVICETYPE=$(echo $DEVICE | awk ' { gsub(/[0-9]*$/,NUL); print $0 } ')
-# real name of device (ie. is eth0 for eth0,eth0:1,eth0:alias)
-DEVICE=$(echo $DEVICE | awk ' { gsub(/:.*$/,NUL); print $0 } ')
+# set all major variables
+setup_ip_param
+# set REALDEVICE
get_ppp_device_and_pid
-if echo "$FULLDEVNAME" | grep -q ':' ; then
- ISALIAS=yes
-else
- ISALIAS=no
-fi
-
+if [ -n "$QDISC" ]; then
# Set the queuing discipline
# eg: sfq for better link sharing or teql0 for link equalizer
-if [ -n "$QDISC" ] ; then
tc qdisc add dev "$REALDEVICE" root $QDISC
fi
-/etc/sysconfig/network-scripts/ifup-routes ${CONFIG}
+/etc/sysconfig/network-scripts/ifup-aliases ${DEVICE}
+/etc/sysconfig/network-scripts/ifup-routes ${DEVICE}
-if [ "$ISALIAS" = "no" ] ; then
- /etc/sysconfig/network-scripts/ifup-aliases ${DEVICE}
+# don't set hostname on ppp/slip connections
+if [ -n "$NEEDHOSTNAME" -a "${DEVICETYPE}" != "ppp" -a "${DEVICETYPE}" != "slip" ]; then
+ IPADDR=$(ip -f inet addr show dev ${DEVICE} |
+ awk '/inet/ { print $2 }' |awk -F"/" '{ print $1 }')
+ eval $(/bin/ipcalc --silent --hostname ${IPADDR}) && set_hostname $HOSTNAME
fi
-# don't set hostname on ppp/slip connections
-if [ -n "$NEEDHOSTNAME" -a "${DEVICE}" != lo -a "${DEVICETYPE}" != "ppp" -a "${DEVICETYPE}" != "slip" ]; then
- IPADDR=`ip -f inet addr show dev ${DEVICE} label ${FULLDEVNAME} |
- awk '/inet/ { print $2 }' |awk -F"/" '{ print $1 }'`
- eval `/bin/ipcalc --silent --hostname ${IPADDR}` && set_hostname $HOSTNAME
+# run tleds software
+if [ "$TLEDS_DEV" = "$DEVICE" -a -x /usr/bin/tleds ]; then
+ /usr/bin/tleds -qc "$DEVICE"
fi
# execute run_up() function (if available in device configuration file)
-[ "$ISALIAS" = "no" ] && run_up
+run_up
# Notify programs that have requested notification
do_netreport
exit 0
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup-ppp,v 1.14 2001/03/22 21:50:36 qboosh Exp $
+# $Id: ifup-ppp,v 1.15 2001/05/15 16:03:44 baggins Exp $
#
# ifup-ppp script for pppd-2.3.5 (with persist & demand options) ver 0.2
# Grzegorz Stanislawski <stangrze@open.net.pl>
. /etc/sysconfig/network-scripts/.functions
source_config
+
+# set all major variables
+setup_ip_param
+
[ -z "$HOLDOFF" ] && HOLDOFF=30
if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then
exit
fi
[ -x /usr/sbin/pppd ] || {
- echo "/usr/sbin/pppd does not exist or is not executable"
- echo "ifup-ppp for $DEVICE exiting"
+ nls "/usr/sbin/pppd does not exist or is not executable"
+ nls "ifup-ppp for %s exiting" "$DEVICE"
logger -p daemon.info -t ifup-ppp \
- "/usr/sbin/pppd does not exist or is not executable for $DEVICE"
+ "$(nls '/usr/sbin/pppd does not exist or is not executable for %s' "$DEVICE")"
exit 1
}
+# modprobe ppp in case of kernel with devfs
+# (/dev/ppp is missing and ppp fails without this) --misiek
+if [ -c /dev/.devfsd ]; then
+ modprobe -s -k char-major-108
+fi
+
opts="lock"
if is_yes "${PERSIST}"; then
if [ -z "${MAXFAIL}" ]; then
opts="$opts asyncmap 00000000"
fi
if is_yes "${DEFROUTE}" = yes; then
+ # pppd will no longer delete an existing default route
+ # so we have to help it out a little here.
+ ip route del 0/0 > /dev/null 2>&1
opts="$opts defaultroute"
fi
+if is_yes "${PEERDNS}"; then
+ opts="$opts usepeerdns"
+fi
if [ -n "${MRU}" ] ; then
opts="$opts mru ${MRU}"
fi
if [ -n "${MTU}" ] ; then
opts="$opts mtu ${MTU}"
fi
-if [ -n "${IPADDR}${REMIP}" ] ; then
+if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}${REMIP}" ] ; then
# if either IP address is set, the following will work.
- opts="$opts ${IPADDR}:${REMIP}"
+ opts="$opts ${IP4ADDR}:${REMIP}"
+fi
+if is_yes "$IPV6_NETWORKING" && is_yes "$IPV6_PPP"; then
+ if [ -n "${IP6ADDR}${REMIP6}" ] ; then
+ opts="$opts ipv6 ${IP6ADDR},${REMIP6}"
+ elif is_yes "$IPV6_CP_USEV4"; then
+ opts="$opts ipv6cp-use-ipaddr"
+ elif is_yes "$IPV6_CP_PERSISTENT"; then
+ opts="$opts ipv6cp-use-persistent"
+ fi
+else
+ opts="$opts noipv6"
fi
if [ -n "${PAPNAME}" ] ; then
opts="$opts name ${PAPNAME}"
"pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
if [ -n "${CHATSCRIPT}" ] ; then
export chatdbg chatrpt CHATSCRIPT
- if [ -n "${DATAFORCHAT}" ] ; then
- export $DATAFORCHAT
+ if [ -n "${DATAFORCHAT" ]; then
+ export $DATAFORCHAT
fi
/usr/sbin/pppd $opts $MODEMPORT $LINESPEED \
- connect 'eval /usr/sbin/chat $chatdbg $chatrpt \
- `grep -v ^# ${CHATSCRIPT}`' \
+ connect 'eval /usr/sbin/chat -E $chatdbg $chatrpt \
+ $(grep -v ^# ${CHATSCRIPT})' \
linkname "${DEVICE}" ipparam "${CONFIG}" \
${PPPOPTIONS}
else
${PPPOPTIONS}
fi
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup-routes,v 1.8 2000/04/21 17:47:49 jajcus Exp $
+# $Id: ifup-routes,v 1.9 2001/05/15 16:03:44 baggins Exp $
#
# adds static routes which go through device $DEVICE
-if [ "$1" = "" ]; then
- echo "usage: $0 <net-device>"
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
+
+DEV=$1
+
+if [ -z "$DEV" ]; then
+ nls "usage: %s <device name>" "ifup-routes" >&2
exit 1
fi
exit 0
fi
-cd /etc/sysconfig/network-scripts
-. /etc/rc.d/init.d/functions
-. /etc/sysconfig/network-scripts/.functions
-CONFIG=$1
+if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ] ; then
+ CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV"
+else
+ CONFIG="$DEV"
+fi
+
source_config
+# set all major variables
+setup_ip_param
+
get_ppp_device_and_pid
# note the trailing white space character in the grep gets rid of aliases
grep "^$DEVICE[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
+ if (echo $args | grep -q ":") then
+ if is_no "$IPV6_NETWORKING"; then
+ continue
+ fi
+ else
+ if is_no "$IPV4_NETWORKING"; then
+ continue
+ fi
+ fi
/sbin/ip route add $args dev $REALDEVICE
done
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: ifup-sl,v 1.17 2000/09/19 12:46:45 saq Exp $
+# $Id: ifup-sl,v 1.18 2001/05/15 16:03:44 baggins Exp $
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
# ifup-post can't be done for slip :-( Solution: use PPP
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
+
# become a daemon in case we have to persist.
if [ "$1" != daemon ] ; then
# disconnect stdin, out, err to disassociate from controlling tty
fi
shift
-. /etc/rc.d/init.d/functions
-. /etc/sysconfig/network-scripts/.functions
-
CONFIG=$1
source_config
exit
fi
+# set all major variables
+setup_ip_param
+
if [ -z "$RETRYTIMEOUT" ]; then
RETRYTIMEOUT=30
fi
# Try to load slip module
-if [ "`ls -R /lib/modules/\`uname -r\`/ | grep slip.o`" != "" ]; then
+if is_module "slip"; then
/sbin/modprobe -s -k slip
fi
[ -x /usr/sbin/dip ] || {
nls "/usr/sbin/dip does not exist or is not executable"
- nls "ifup-sl for $DEVICE exiting"
+ nls "ifup-sl for %s exiting" "$DEVICE"
logger -p daemon.info -t ifup-sl \
- "`nls '/usr/sbin/dip does not exist or is not executable for %s' $DEVICE`"
+ "`nls '/usr/sbin/dip does not exist or is not executable for'` $DEVICE"
exit 1
}
DIPSCRIPT=/etc/sysconfig/interfaces/data/dip-$PARENTDEVNAME
}
[ -f $DIPSCRIPT ] || {
- echo "/etc/sysconfig/interfaces/data/dip-$DEVICE `nls 'does not exist'`"
+ echo "/etc/sysconfig/interfaces/data/dip-$DEVICE $(nls 'does not exist')"
echo "ifup-sl for $DEVICE exiting"
logger -p daemon.info -t ifup-sl \
- "/etc/sysconfig/interfaces/data/dip-$DEVICE `nls 'does not exist for %s' $DEVICE`"
+ "/etc/sysconfig/interfaces/data/dip-$DEVICE $(nls 'does not exist for') $DEVICE"
exit 1
}
while : ; do
echo > /var/run/sl-$DEVICE.dev
(logger -p daemon.info -t ifup-sl \
- "`nls 'dip started for %s on %s at %s' $DEVICE $MODEMPORT $LINESPEED`" &)&
+ "$(nls 'dip started for %s on %s at %s' "$DEVICE" "$MODEMPORT" "$LINESPEED")" &)&
doexec /usr/sbin/dip dip-$DEVICE $DIPSCRIPT
if is_no "$PERSIST" || [ ! -f /var/run/sl-$DEVICE.dev ] ; then
exit 0
[ -z "$PROTOCOL" ] && PROTOCOL=slip
[ -x /sbin/slattach ] || {
- nls "/sbin/slattach does not exist or is not executable"
- echo "ifup-sl - $DEVICE `nls exiting`"
+ nls "%s is missing. Can't continue." "/sbin/slattach"
+ echo "ifup-sl - $DEVICE $(nls exiting)"
logger -p daemon.info -t ifup-sl \
- "`nls '/sbin/slattach does not exist or is not executable for %s' $DEVICE`"
+ "$(nls '/sbin/slattach does not exist or is not executable for %s' "$DEVICE")"
exit 1
}
echo > /var/run/sl-$DEVICE.dev
(logger -p daemon.info -t ifup-sl \
- "`nls 'slattach started for %s on %s at %s' $DEVICE $MODEMPORT $LINESPEED`" &)&
+ "$(nls 'slattach started for %s on %s at %s' "$DEVICE" "$MODEMPORT" "$LINESPEED")" &)&
slattach -p $PROTOCOL -s $LINESPEED $MODEMPORT &
usleep 1500
+
+ if is_yes "$IPV4_NETWORKING"; then
+ if [ -n "$IP4ADDR" -a -n "$REMIP" ]; then
+ # Peer is only for IPv4
+ ip -4 addr add $IP4ADDR peer $REMIP dev $DEVICE
+ fi
+ fi
+
+ if is_yes "$IPV6_NETWORKING"; then
+ if [ -n "$IP6ADDR" ]; then
+ ip -6 addr add $IP6ADDR dev $DEVICE
+ fi
+ fi
+
ip link set $DEVICE mtu $MTU up
- ip -family inet addr add $IPADDR peer $REMIP dev $DEVICE
- # Set defaultroute
- if is_yes "$DEFROUTE"; then
- ip -family inet route add default dev $DEVICE
- fi
+ # IPv4/6 gateways and default routes
+ setup_ip_gw_ro
+
+ /etc/sysconfig/network-scripts/ifup-post $1
fi
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: tnldown,v 1.16 2000/07/28 15:03:10 zagrodzki Exp $
+# tnldown - tunnel configuration script
+# Copyright (C) 1999, 2000 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
#
-# Author: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+# 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.
#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# $Id: tnldown,v 1.17 2001/05/15 16:03:44 baggins Exp $
+#
+
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
DEV=$1
[ -z "$DEV" ] && {
- echo "usage: tnlup <device name>" >&2
+ nls "usage: %s <device name>" "tnldown" >&2
exit 1
}
-. /etc/sysconfig/network
-. /etc/rc.d/init.d/functions
-. /etc/sysconfig/network-scripts/.functions
-
-TNLCONFIGS="`ls /etc/sysconfig/interfaces/tnlcfg-*|egrep -v '~$'`"
-TNLCONFIGS="`egrep -L '^#!' $TNLCONFIGS`"
-CONFIG="`egrep -l "^DEVICE=[\"\']*$DEV[\"\']*\$" $TNLCONFIGS`"
+TNLCONFIGS=$(ls /etc/sysconfig/interfaces/tnlcfg-*|egrep -v '~$')
+TNLCONFIGS=$(egrep -L '^#!' $TNLCONFIGS)
+CONFIG=$(egrep -l "^DEVICE=[\"\']*$DEV[\"\']*\$" $TNLCONFIGS)
if [ -z "$CONFIG" ]; then
CONFIG="$DEV"
if false; then
[ -f "/etc/sysconfig/interfaces/$CONFIG" ] || CONFIG=tnlcfg-$CONFIG
[ -f "/etc/sysconfig/interfaces/$CONFIG" ] || {
- echo "usage: tnlup <device name>" >&2
+ echo "usage: tnldown <device name>" >&2
exit 1
}
fi
source_config
-is_no "${IPV6_TUNNELCONFIG}" && [ "${MODE}" = "sit" ] && exit 0
-is_no "${IPX}" && [ "${MODE}" = "ipxip" ] && exit 0
-is_no "${IPX}" && [ "${MODE}" = "ipipx" ] && exit 0
-
-if [ "${MODE}" = "ipip" ] || [ "${MODE}" = "sit" ] || [ "${MODE}" = "gre" ]; then
+case "${MODE}" in
+ sit|four)
+ is_no "${IPV6_NETWORKING}" && exit 0
+ is_no "${IPV6_TUNNELCONFIG}" && exit 0
+ ;;
+ ipip)
+ is_no "${IPV4_NETWORKING}" && exit 0
+ ;;
+ gre)
+ is_no "${IPV4_NETWORKING}" && exit 0
+ ;;
+ ipxip|ipipx)
+ is_no "${IPX}" && exit 0
+ ;;
+esac
- ip tunnel del ${DEVICE}
+RESULT=0
-elif [ "${MODE}" = "ipxip" ] || [ "${MODE}" = "ipipx" ]; then
+case "${MODE}" in
+ ipip|sit|gre)
+ ip link set ${DEVICE} down
+ ip tunnel del ${DEVICE}
+ RESULT=$?
+ ;;
+ four)
+ ip link set ${DEVICE} down
+ fourcfg del ${DEVICE}
+ RESULT=$?
+ ;;
+ ipxip|ipipx)
+ ;;
+esac
-echo "obs³uga ipxip jeszcze nie zrobiona"
+exit $RESULT
-fi
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
#!/bin/sh
#
-# $Id: tnlup,v 1.19 2000/07/28 15:03:10 zagrodzki Exp $
+# tnlup - tunnel configuration script
+# Copyright (C) 1999, 2000 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
#
-# Author: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+# 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.
#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# $Id: tnlup,v 1.20 2001/05/15 16:03:44 baggins Exp $
+#
+
+. /etc/sysconfig/network
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/network-scripts/.functions
DEV=$1
[ -z "$DEV" ] && {
- echo "usage: tnlup <device name>" >&2
+ nls "usage: %s <device name>" "tnlup" >&2
exit 1
}
-. /etc/sysconfig/network
-. /etc/rc.d/init.d/functions
-. /etc/sysconfig/network-scripts/.functions
-
-TNLCONFIGS="`ls /etc/sysconfig/interfaces/tnlcfg-*|egrep -v '~$'`"
-TNLCONFIGS="`egrep -L '^#!' $TNLCONFIGS`"
-CONFIG="`egrep -l "^DEVICE=[\"\']*$DEV[\"\']*\$" $TNLCONFIGS`"
+TNLCONFIGS=$(ls /etc/sysconfig/interfaces/tnlcfg-*|egrep -v '~$')
+TNLCONFIGS=$(egrep -L '^#!' $TNLCONFIGS)
+CONFIG=$(egrep -l "^DEVICE=[\"\']*$DEV[\"\']*\$" $TNLCONFIGS)
if [ -z "$CONFIG" ]; then
CONFIG="$DEV"
source_config
-if [ "foo$2" = "fooboot" ] && is_no "${ONBOOT}"; then
+if [ "foo$2" = "fooboot" -a -n "${ONBOOT}" ] && is_no "${ONBOOT}"; then
exit
fi
-is_no "${IPV6_TUNNELCONFIG}" && [ "${MODE}" = "sit" ] && exit 0
-is_no "${IPX}" && [ "${MODE}" = "ipxip" ] && exit 0
-is_no "${IPX}" && [ "${MODE}" = "ipipx" ] && exit 0
-
-if [ "${MODE}" = "gre" -a "`ls -R /lib/modules/\`uname -r\`/ | grep ip_gre.o`" != "" ]; then
- modprobe -s -k ip_gre
-elif [ "${MODE}" = "ipip" -a "`ls -R /lib/modules/\`uname -r\`/ | grep ipip.o`" != "" ]; then
- modprobe -s -k ipip
-fi
-
+case "${MODE}" in
+ sit|four)
+ is_no "${IPV6_NETWORKING}" && exit 0
+ is_no "${IPV6_TUNNELCONFIG}" && exit 0
+ [ "${MODE}" = "four" ] && is_module "fourtun" && modprobe -s -k fourtun
+ ;;
+ ipip)
+ is_no "${IPV4_NETWORKING}" && exit 0
+ is_module "ipip" && modprobe -s -k ipip
+ ;;
+ gre)
+ is_no "${IPV4_NETWORKING}" && exit 0
+ is_module "ip_gre" && modprobe -s -k ip_gre
+ ;;
+ ipxip|ipipx)
+ is_no "${IPX}" && exit 0
+ ;;
+esac
+
+RESULT=0
[ -z "${LOCALADDR}" ] && LOCALADDR=any
[ -z "${REMOTEADDR}" ] && REMOTEADDR=any
[ -n "${TTL}" ] && TTL="ttl ${TTL}"
[ -n "${TOS}" ] && TOS="tos ${TOS}"
[ -n "${BIND_DEV}" ] && BIND_DEV="dev ${BIND_DEV}"
+[ -n "${PRIORITY}" ] && PRIORITY="priority ${PRIORITY}"
+[ -n "${HOPLIMIT}" ] && HOPLIMIT="hoplimit ${HOPLIMIT}"
+[ -n "${ENCAPLIMIT}" ] && ENCAPLIMIT="encaplimit ${ENCAPLIMIT}"
if is_yes "${SEQ}"; then
SEQ=seq
is_yes "${ICSUM}" && CSUM="${SEQ} ocsum"
fi
-is_yes "${ISEQ}" && ISEQ=iseq
-is_yes "${ISEQ}" && ISEQ=iseq
-is_yes "${ISEQ}" && ISEQ=iseq
is_yes "${ISEQ}" && ISEQ=iseq
-[ "${TTL}" != "0" -a "${TTL}" != "inherit" ] && PMTUDISC=yes
+[ -z "${PMTUDISC}" -a "${TTL}" != "0" -a "${TTL}" != "inherit" ] && PMTUDISC=yes
if is_yes "${PMTUDISC}"; then
PMTUDISC=pmtudisc
OKEY=""
fi
-if [ "${MODE}" = "ipip" -o "${MODE}" = "sit" ]; then
-
- ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV}
-
-elif [ "${MODE}" = "gre" ]; then
-
- ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV} ${CSUM} ${ISEQ} ${KEY} ${IKEY} ${OKEY}
-
-elif [ "${MODE}" = "ipxip" -o "${MODE}" = "ipipx" ]; then
-
-echo "obs³uga ipxip jeszcze nie zrobiona"
-
-fi
+case "${MODE}" in
+ ipip|sit)
+ ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV}
+ RESULT=$?
+ ;;
+ gre)
+ ip tunnel add ${DEVICE} mode ${MODE} local ${LOCALADDR} remote ${REMOTEADDR} ${TTL} ${TOS} ${PMTUDISC} ${BIND_DEV} ${CSUM} ${ISEQ} ${KEY} ${IKEY} ${OKEY}
+ RESULT=$?
+ ;;
+ fourtun)
+ fourcfg add ${DEVICE} saddr ${LOCALADDR} daddr ${REMOTEADDR} ${PRIORITY} ${HOPLIMIT} ${ENCAPLIMIT}
+ RESULT=$?
+ ;;
+ ipxip|ipipx)
+ ;;
+esac
+
+exit $RESULT
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
-# $Id: system,v 1.19 2000/12/27 13:33:19 mkochano Exp $
+# $Id: system,v 1.20 2001/05/15 16:03:42 baggins Exp $
# Do you want colorized starting scripts ?
COLOR_INIT=yes
# Messages with a higher priority than this will be printed
# to the console (default 1)
-CONSOLE_LOGLEVEL=1
+CONSOLE_LOGLEVEL=1
# On errors (when system is starting) run sulogin instead of shell ?
RUN_SULOGIN_ON_ERR=yes
# Start DevFS daemon to preserve compatibility with old "style" device names
RUN_DEVFSD=no
-# Adjust number of inodes and file handles available in the system.
-# If you have a havily loaded system and kernel complains about
-# file/inode limit reached in VFS, increase this 2x. The default
-# value is 4096 (file) and 8192 (inode). The inode number should be
-# always 2-3 times the file number. For most systems this should not
-# be changed
-#VFS_FILE_MAX=4096
-#VFS_INODE_MAX=8192
-
# Set to anything other than 'no' to allow hotkey interactive startup...
PROMPT=yes
-# Setting this to something other than 'no' will turn on magic sysrq keys
-MAGIC_SYSRQ=yes
-
-# Setting this to something other than 'no' will turn on stop-a (Sparc only)
-STOP_A=no
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
# Name of the time zone
# for your system.
TIME_ZONE="Warsaw"
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
--- /dev/null
+### IPV4 NETWORKING
+
+# Disables IPv4 packet forwarding
+net.ipv4.ip_forward = 0
+
+# Enables source route verification
+net.ipv4.conf.all.rp_filter = 1
+
+# Accept ICMP redirect messages (suggested 1 for hosts and 0 for routers)
+# net.ipv4.conf.all.accept_redirects = 1
+
+# Accept source routed packages (suggested 0 for hosts and 1 for routers)
+# net.ipv4.conf.all.accept_source_route = 1
+
+# Log packets with source addresses with no known route to kernel log
+# net.ipv4.conf.all.log_martians = 1
+
+# Do multicast routing ? The kernel needs to be compiled with
+# CONFIG_MROUTE and a multicast routing daemon is required.
+# net.ipv4.conf.all.mc_forwarding = 1
+
+# Do proxy ARP ?
+# net.ipv4.conf.all.proxy_arp = 1
+
+# Accept ICMP redirect messages only for gateways, listed in
+# default gateway list ?
+# net.ipv4.conf.all.secure_redirects = 1
+
+# Send ICMP redirects to other hosts ?
+# net.ipv4.conf.all.send_redirects = 1
+
+# Ignore all ICMP echo requests ?
+# net.ipv4.icmp_echo_ignore_all = 1
+
+# Ignore ICMP echo requests to broadcast and multicast addresses ?
+# net.ipv4.icmp_echo_ignore_broadcasts = 1
+
+# Enable MTU discovery patch ? (KERNEL MUST SUPPORT THIS)
+# MTU (maximal transfer unit) is the size of the chunks we send out
+# over the net. "Path MTU Discovery" means that, instead of always
+# sending very small chunks, we start out sending big ones and if we
+# then discover that some host along the way likes its chunks smaller,
+# we adjust to a smaller size.
+# net.ipv4.ip_no_pmtu_disc = 1
+
+# Enable debugging of IP masquerading ?
+# net.ipv4.ip_masq_debug = 1
+
+# Bug-to-bug compatibility with some broken printers. On retransmit
+# try to send bigger packets to work around bugs in certain TCP
+# stacks. Can be turned off by setting IPV4_RETRANS_COLLAPSE to ,,yes''.
+# net.ipv4.tcp_retrans_collapse = 1
+
+# Disable select acknowledgments after RFC2018 ?
+# TCP may experience poor performance when multiple packets are lost
+# from one window of data. With the limited information available
+# from cumulative acknowledgments, a TCP sender can only learn about a
+# single lost packet per round trip time. An aggressive sender could
+# choose to retransmit packets early, but such retransmitted segments
+# may have already been successfully received.
+# net.ipv4.tcp_sack = 0
+
+# Disable timestamps as defined in RFC1323 ?
+# Timestamps are designed to provide compatible interworking with
+# TCP's that do not implement the TCP Extensions for High Performance
+# net.ipv4.tcp_timestamps = 0
+
+# Enable the strict RFC793 interpretation of the TCP urgent pointer field.
+# net.ipv4.tcp_stdurg = 1
+
+# Enable tcp_syncookies
+net.ipv4.tcp_syncookies = 1
+
+# Disable window scaling as defined in RFC1323 ?
+# The window scale extension expands the definition of the TCP
+# window to 32 bits and then uses a scale factor to carry this
+# 32-bit value in the 16-bit Window field of the TCP header.
+# net.ipv4.tcp_window_scaling = 0
+
+# Enable dynamic socket address rewriting on interface address change.
+# This is useful for dialup interface with changing IP addresses.
+# sys.net.ipv4.ip_dynaddr = 7
+
+# Range of ports used by TCP and UDP to choose the local
+# port. Contains two numbers, the first number is the lowest port,
+# the second number the highest local port. Default is "1024 4999".
+# Should be changed to "32768 61000" for high-usage systems.
+net.ipv4.ip_local_port_range = 1024 4999
+
+# Disables automatic defragmentation (needed for masquerading, LVS)
+# Non existant on Linux 2.4
+# net.ipv4.ip_always_defrag = 0
+
+### IPV6 NETWORKING
+
+# Disables IPv6 packet forwarding
+net.ipv6.conf.all.forwarding = 0
+
+# Do you want IPv6 address autoconfiguration? Kernel default is yes.
+# net.ipv6.conf.all.autoconf = 0
+
+# Do you want kernel to add default route for IPv6 interfaces if
+# there is no router on the link? Kernel default is yes.
+# Kernel 2.4.0-test? or later (after ANK accepts my patch - baggins).
+# net.ipv6.conf.all.autoconf_route = 0
+
+### OTHER SETTINGS
+
+# Adjust number of inodes and file handles available in the system.
+# If you have a havily loaded system and kernel complains about
+# file/inode limit reached in VFS, increase this 2x. The default
+# value is 4096 (file) and 8192 (inode). The inode number should be
+# always 2-3 times the file number. For most systems this should not
+# be changed
+# fs.file-max = 8192
+# fs.inode-max = 16384
+
+# Enable the magic-sysrq key
+kernel.sysrq = 1