Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to "switch system profile" in Redhat 7.3

2 views
Skip to first unread message

M Markevitch

unread,
May 11, 2002, 2:43:11 AM5/11/02
to
With linuxconf, it used to be possible to set up
different "system profiles" with different network init
parameters, and choose them at boot time (helpful if one
uses a laptop at home with DHCP and at work with static IP).

Now linuxconf is not included in 7.3 (I tried installing
it, but could not even make it start), did wise folks at
Redhat think of an alternative?

Thanks
M M

Jonathan Horne

unread,
May 11, 2002, 10:44:26 AM5/11/02
to
i too have often wondered if there was an alternative to linuxconf,
ever since 7.1 when it was no longer included by default.

on the flip side, i have sucessfully installed the linuxconf included
on the rh7.2 cd, and so far it seems to work fine.

jonathan

M Markevitch

unread,
May 12, 2002, 2:30:17 AM5/12/02
to
OK, I've solved my problem with different network
setups for a laptop without resorting to lunuxconf
(presumably, this is how linuxconf does it
anyway). In case anybody is interested, it's easy:

1. Create dirs
/etc/sysconfig/networking/profiles/[home,office]

2. Using redhat-config-network or whatever, configure
eth0 for office and home, moving the resulting 4
files (/etc/hosts, /etc/resolv.conf,
/etc/sysconfig/network,
/etc/sysconfig/network-scripts/ifcfg-eth0 [can be any
ifcfg-*]) to the above profile dirs. (Note that even
though resolv.conf is not needed for DHCP, the script
below wants it, so keep it even if you are using
DHCP.)

3. Using webmin or whatever, create boot options
'linux home' and 'linux office' that differ by a
kernel option PROFILE=home or office (it must be the
last option in the list). The option is harmless.

4. Edit /etc/rc.d/init.d/network as below (I also
renamed it to network-chkprof and changed the service
name to network-chkprof in the file header), and
start this 'network-chkprof' at boot instead of
'network' (set it up in webmin). It will read the
profile name at boot, and the profile can be reset
manually later (see comments).

Enjoy,
Maxim Markevitch

The following needs to be added in
/etc/rc.d/init.d/network right after the initial
comments:

############################################################
# M M 11.5.02: added to the standard 'network' script:
#
# Check env. var. PROFILE, then a boot option PROFILE (stored in file
# /proc/cmdline, e.g., PROFILE=home; should be the last option). If found,
# check the corresponding subdir. in /etc/sysconfig/networking/profiles/.
# If it has all the needed files, copy them to the relevant default dirs.
# Otherwise, do not do anything and let 'network' run using the existing
# setup files.
#
# If one wants to reset profile from the command line, the script should be
# called directly, e.g.,
# setenv PROFILE home ; /etc/rc.d/init.d/network-chkprof restart
# (calling 'service network-chkprof' doesn't pass env. vars to the script).

rootdir='/etc/sysconfig/networking/profiles'
profile=''

## first check if have env. var. PROFILE:
if [[ $PROFILE != '' ]] ; then
profile=$PROFILE
else
## check if have PROFILE boot option (should be the last passed to kernel):
jnk=`cat /proc/cmdline`;
if [[ $jnk == *PROFILE=* ]] ; then
## have this option, extract it:
profile=${jnk/*PROFILE=/''}
fi
fi

if [[ $profile != '' ]] ; then
profdir="${rootdir}/${profile}"

if [[ ( -a ${profdir}/resolv.conf ) && \
( -a ${profdir}/hosts ) && \
( -a ${profdir}/network ) && \
( -n `ls ${profdir}/ifcfg-* 2> /dev/null` ) ]] ; then

echo "Using network setup '${profile}'"

cp ${profdir}/resolv.conf ${profdir}/hosts /etc
cp ${profdir}/network /etc/sysconfig
cp ${profdir}/ifcfg-* /etc/sysconfig/network-scripts
fi
fi
# below starts the original 'network' script.
############################################################

Dr.J

unread,
May 13, 2002, 9:43:59 AM5/13/02
to
I did something different.

situation: laptop with built-in NIC (eth0), docking station has a NIC
(eth1) at work. eth1 is used at work, which eth0 is in use at home.

solution: when boot, both eth0 and eth1 are not activated. a script is
called by rc.local to detect if it is docked (by looking for eth1 from
/proc/interupts. if it is present, it is docked (at work). otherwise,
it is at home), that react accordingly.

Dr.J

mmar...@yahoo.com (M Markevitch) wrote in message news:<69aaebf1.02051...@posting.google.com>...

0 new messages