Initscripts: keeping it simple

35 views
Skip to first unread message

Daniel Robbins

unread,
Jul 8, 2009, 5:31:54 PM7/8/09
to funto...@googlegroups.com
As I've posted on my blog, I'm looking to move to a simpler setup for
networking initscripts:

http://blog.funtoo.org/2009/06/initscripts-keeping-it-simple.html

The specific changes I'm looking at making (all together) are:

1) Upgrade to OpenRC 0.5.0+
2) Adding OpenResolv to Funtoo Core
3) Moving to minimal initscripts
4) Moving to dhcpcd 5.x

If you are using dhcp, all you need to do for network config is to add
/etc/init.d/dhcpcd
to your default runlevel (I think -- I'll be testing this, please test
dhcpd-5 too :)

Here is a sample net.eth0 (static config) I am using for testing,
which follows the
minimal approach:

#!/sbin/runscript
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
provide net
after net.lo
}

IP=207.66.127.104
NM=255.255.255.0
GW=207.66.127.254
INT=eth0

start() {
ebegin "Configuring network interface $INT"
ifconfig $INT $IP netmask $NM up && \
route add default gw $GW $INT && \
resolvconf -a $INT << "EOF"
domain funtoo.org
nameserver 129.121.254.1
nameserver 129.121.254.2
EOF
eend $?
}

stop() {
ebegin "Shutting down network interface $INT"
resolvconf -d $INT && \
route del default gw $GW $INT && \
ifconfig $INT down
eend $?
}

As you can see, resolv.conf info is stored in the initscript, and this
works great with openresolv. What this means is that you don't write
directly to /etc/resolv.conf anymore.

Here is a sample net.lo:

#!/sbin/runscript
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
provide net
}

start() {
ifconfig lo 127.0.0.1 netmask 255.0.0.0 up
route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
}

stop() {
route del -net 127.0.0.0 netmask 255.0.0.0 dev lo
ifconfig lo down
}

Looking for feedback...

-Daniel

drobbins

unread,
Jul 8, 2009, 5:46:25 PM7/8/09
to Funtoo
Just to clarify - I want to move to minimal *network* initscripts....

Daniel Cordero

unread,
Jul 8, 2009, 6:23:01 PM7/8/09
to Daniel Robbins, funto...@googlegroups.com
On Wed, Jul 08, 2009 15:31:30 -0600, Daniel Robbins wrote:
> Looking for feedback...

My dhcpcd.conf has:
nohook resolv.conf
and I leave my /etc/resolv.conf alone (my router incorrectly handles dns
servers).

For me, I don't really care what address my ethernet gets. Letting DHCP
take care of it whenever it is plugged in would be nice (it shouts at me
for not configuring it).
I would like to know (i.e. make it print) the IP address that I get.

For wireless, which I use more, I read that gentoo initscripts try to be
a bit too clever and freak it out. So, I wrote a script that sets it all
up.

#!/bin/sh
test "$1" -o -f /var/run/dhcpcd-ra0.pid && dhcpcd -x ra0

ifconfig ra0 up
iwconfig ra0 essid $(< ~/Desktop/essid) key $(< ~/Desktop/key) enc open
dhcpcd -s 192.168.2.2 -m 2 ra0

(Due to a bug in the hardware, I do not need to worry about turning
off the adapter)

I used to be near some WPA spots, in which I beefed up my script to:

#!/bin/sh
test "$1" -o -f /var/run/dhcpcd-ra0.pid && dhcpcd -x ra0

ifconfig ra0 up
wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf -ira0 -Dwext -B \
|| killall -HUP wpa_supplicant
# wpa_supplicant has to be configured at each access point
dhcpcd -m 2 ra0

As you can see, I have quite a few variables. In a more generic script,
these variables should go into /etc/conf.d/net (or somewhere
otherwise suitable), because a small change to the initscript will
mean a user (umm... i mean system admin) will need to learn about the
horror of merging in dispatch-conf.

RuanLaB

unread,
Jul 11, 2009, 5:16:10 PM7/11/09
to Funtoo
Running openrc 0.5.0, gcc 4.4.0 python 2.6.2-r* since end of May with
great success and speed improvements on 2.6.30 and above kernels.
This caused me to get the cold shoulder for not conforming to the
narrow minded dictatorship's of some gentoo distro's.

Would like to get eglibc into funtoo / gentoo if possible to get linux
back to basics / compact fast basis to customize on.

Adding openresolv and other basic usable networking is the way to go ,
too many Linux distro's adding bloatware that only works in Gnome or
KDE and ends up being a major pain to text login and getting it to
connect to wifi WPA or similar dew to lack of useful packages. Some
even lack midnight commander or binutils.

There is a lot of Linux users out there that wants to break away from
the torture tools that linux dictatorships has become and most of them
with a bit of guidance will jump into helping out provided they have
a way to help. Will have to start building up a new base of skilled
linux users before the linux users become extinct.

If there is a way I would like to setup a automated server that can
pull in new source code and build or create a usable up to date gentoo
funtoo tree or similar as gentoo tree is falling behind tremendously.

Very nice to see Daniel/Funtoo still in contact with daily use linux /
daily linux needs and thinking clearly unlike some linux developers
specializing in hiding in closets and building some far-out linux
program that only 100 users might use.

Keep up the good work.

You build it they will come. You are spot on with your ideas and
direction.

Regards
Ruan

***********

Daniel Cordero

unread,
Jul 15, 2009, 9:33:37 AM7/15/09
to RuanLaB, Funtoo
On Sat, Jul 11, 2009 14:15:46 -0700, RuanLaB wrote:
> Would like to get eglibc into funtoo / gentoo if possible to get linux
> back to basics / compact fast basis to customize on.
>

AFAIK, eglibc is a "glibc distribution", with doesn't make it any easier
or faster than ordinary glibc. Last time I checked, the major difference
is the maintainers and their patch-acceptance policy.

"Back to basics" would involve ANSI C's standard library (and POSIX
extensions optionally available) only, and a cat(1) that can read directories
and not "invisible" characters.

Daniel Robbins

unread,
Jul 15, 2009, 12:39:07 PM7/15/09
to funto...@googlegroups.com, Daniel Cordero, RuanLaB
On Wed, Jul 15, 2009 at 7:33 AM, Daniel Cordero<theap...@gmail.com> wrote:
> "Back to basics" would involve ANSI C's standard library (and POSIX
> extensions optionally available) only, and a cat(1) that can read directories
> and not "invisible" characters.

"Back to basics" can be interpreted in many different ways. For my
purposes, "back to basics" is the concept of putting the user in
direct control of their OS, and eliminating intermediate layers of
complexity when they don't add significant value, as these layers end
up becoming liabilities rather than assets over time (you need to
maintain them, they have their own bugs and limitations, etc.) If
significant amounts of code can be eliminated while functionality is
maintained or even improved, this is an indication that there is
bloat. Of course there are other factors to consider when deciding
whether or not to remove code - for Linux users, asking them to see
the commands that set up their network (and have direct control over
them) has other benefits besides just eliminating some unnecessary
code.

-Daniel

Reply all
Reply to author
Forward
0 new messages