[arch-dev-public] Impending initscripts changes

James Rayner iphitus at gmail.com
Thu Dec 20 07:28:50 EST 2007


On Thu, Dec 20, 2007 at 01:45:04AM -0600, Aaron Griffin wrote:
> Hey all,
> I've been throwing together a handful of initscripts changes to fix
> numerous bugs and things of that nature.
> 
> Relevant git repo:
> http://code.phraktured.net/?p=initscripts.git;a=summary
> 
> The splash branch contains the patch to make it look less like it's
> splash related (the wording makes it seem better, IMO)
> This is yet to be merged on my working branch (due to change there)
> but I'll do that tomorrow-ish.
> 
> So, the working branch is the fun one to look at.
> 
> -----------------------------------
> 
> http://bugs.archlinux.org/task/1186 (force background color to black -
> thanks Simo)
> http://bugs.archlinux.org/task/8843 (tput calls fail if /usr isn't
> mounted - thanks Roman)
> http://bugs.archlinux.org/task/6989 (added /etc/rc.d/functions.d/ directory)
> 
> I'd like to finish this up, but want some input:
> http://bugs.archlinux.org/task/4550 (break out hwclock functionality
> from rc.sysinit)
> 
> Thomas merged this earlier:
> http://bugs.archlinux.org/task/8579 (allow loading of multiple keymaps
> - thanks Roman)
> 
> I don't think this one is a good idea:
> http://bugs.archlinux.org/task/6776
> 
> -----------------------------------
> 
> Anything else pending for initscripts? Any other requests? Can I get
> some possible input on the above items? 

Patch for netcfg2: 
http://share.iphitus.org/201207/0001-updating-initscripts-for-netcfg2.patch

Optional tidy up for rc.conf:
http://share.iphitus.org/201207/0002-tidy-up-rc.conf.patch

Also attached.
-------------- next part --------------
>From 06712af5ee07185a49a088f4d06b230cd27f1d76 Mon Sep 17 00:00:00 2001
From: James Rayner <james at archlinux.org>
Date: Thu, 20 Dec 2007 23:21:17 +1100
Subject: [PATCH] updating initscripts for netcfg2

---
 install.sh       |    3 -
 netcfg           |  301 ------------------------------------------------------
 network          |   30 ------
 profile-template |   36 -------
 rc.conf          |   14 ++--
 5 files changed, 7 insertions(+), 377 deletions(-)
 delete mode 100755 netcfg
 delete mode 100644 profile-template

diff --git a/install.sh b/install.sh
index 6d5b2dc..e98a832 100755
--- a/install.sh
+++ b/install.sh
@@ -17,7 +17,4 @@ done
 gcc $CFLAGS -o minilogd minilogd.c || exit 1
 install -D -m755 minilogd ${DESTDIR}/sbin/minilogd || exit 1
 
-install -D -m755 netcfg ${DESTDIR}/usr/bin/netcfg || exit 1
-install -D -m644 profile-template ${DESTDIR}/etc/network-profiles/template || exit 1
-
 install -D -m755 makedevs ${DESTDIR}/sbin/makedevs || exit 1
diff --git a/netcfg b/netcfg
deleted file mode 100755
index b755e52..0000000
--- a/netcfg
+++ /dev/null
@@ -1,301 +0,0 @@
-#!/bin/bash
-
-. /etc/rc.conf
-. /etc/rc.d/functions
-[ -f /etc/conf.d/dhcpcd ] && . /etc/conf.d/dhcpcd
-
-NETCFG_VER=0.1
-PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
-
-PROFILE_DIR="/etc/network-profiles"
-STATE_DIR="/var/run/net"
-
-version()
-{
-	echo "netcfg v$NETCFG_VER"
-}
-
-usage()
-{
-	version
-	echo
-	echo "usage: netcfg [options] <profile_name>"
-	echo "       netcfg --stop <interface>"
-	echo "       netcfg --menu [--timeout <secs>]"
-	echo "       netcfg --stopall"
-	echo
-	echo "options:"
-	echo "  -c    Don't reconfigure an interface if it's already up"
-	echo
-	echo "Network profiles are stored in $PROFILE_DIR"
-	echo
-}
-
-stop_profile()
-{
-	if [ "$1" = "" ]; then
-		echo "error: missing interface name (eg, eth0)"
-		exit 1
-	fi
-	INTERFACE=$1
-	[ -f $STATE_DIR/$INTERFACE ] || return
-
-	unset GATEWAY IFOPTS
-	. $STATE_DIR/$INTERFACE
-
-	stat_busy "Shutting down interface: $INTERFACE"
-
-	# bring down the default route (gateway)
-	[ "$GATEWAY" ] && route del default gw $GATEWAY
-
-	# shutdown wpa_supplicant if it's running
-	[ "$USEWPA" = "yes" -o "$USEWPA" = "YES" ] && wpa_cli terminate >/dev/null 2>&1
-
-	# bring down dhcpcd if we're using it
-	if [ "$IFOPTS" = "dhcp" -o "$IFOPTS" = "DHCP" ]; then
-		# if the dhcp client received an unlimited lease then it just exits,
-		# so check for .pid file before trying to kill it.
-		if [ -f /var/run/dhcpcd-${INTERFACE}.pid ]; then
-			kill $(cat /var/run/dhcpcd-${INTERFACE}.pid)
-		fi
-	fi
-
-	# bring down the interface itself
-	ifconfig $INTERFACE down
-
-	rm -f $STATE_DIR/$INTERFACE
-
-	stat_done
-}
-
-stop_all()
-{
-	[ -d $STATE_DIR ] || return
-	for prof in $(ls $STATE_DIR); do
-		unset INTERFACE
-		. $STATE_DIR/$prof
-		stop_profile $INTERFACE
-	done
-}
-
-start_profile()
-{
-	if [ "$1" = "" ]; then
-		echo "error: missing profile name"
-		exit 1
-	fi
-	if [ ! -f $PROFILE_DIR/$1 ]; then
-		echo "error: $PROFILE_DIR/$1 is missing" >&2
-		exit 1
-	fi
-	
-	# Read the profile
-	. $PROFILE_DIR/$1
-
-	[ "$CHECK" = "1" -a  -f $STATE_DIR/$INTERFACE ] && return
-
-	# Shut down any profiles tied to this interface
-	stop_profile $INTERFACE
-
-	stat_busy "Starting network profile: $1"
-
-	# Re-read the profile (stop_profile might have overwritten our settings)
-	unset DESCRIPTION INTERFACE IFOPTS
-	unset IWOPTS WIFI_INTERFACE WIFI_WAIT USEWPA WPAOPTS
-	unset GATEWAY HOSTNAME DOMAIN DNS1 DNS2
-	. $PROFILE_DIR/$1
-
-	# Configure wireless settings, if necessary
-	[ "$WIFI_INTERFACE" ] || WIFI_INTERFACE=$INTERFACE
-	
-	if [ "$IWOPTS" ]; then
-		iwconfig $WIFI_INTERFACE $IWOPTS
-		[ $? -ne 0 ] && stat_fail && return
-		[ "$WIFI_WAIT" ] && sleep $WIFI_WAIT
-	fi
-
-	# Start wpa_supplicant, if necessary
-	if [ "$USEWPA" = "yes" -o "$USEWPA" = "YES" ]; then
-		ifconfig $WIFI_INTERFACE up
-	  
-		WPA_CONF="/etc/wpa_supplicant.conf"	
-		if [ "$AUTOWPA" = "yes" -o "$AUTOWPA" = "YES" ]; then
-			WPA_CONF=$(mktemp /tmp/wpa.XXXXXXXX)
-			# file will contain PSK, limit reading
-			chmod 600 $WPA_CONF
-			echo "ctrl_interface=/var/run/wpa_supplicant" > $WPA_CONF
-			wpa_passphrase $ESSID "$PASSKEY" >> $WPA_CONF	
-  		[ $? -ne 0 ] && cat $WPA_CONF && stat_fail && return
-		fi
-			
-		[ "$WPAOPTS" ] || WPAOPTS="-Dwext"
-		wpa_supplicant -wB -i ${WIFI_INTERFACE} -c ${WPA_CONF} $WPAOPTS 
-		
-	  # I don't know how we could determine if wpa_supplicant is ready	
-		sleep 2
-		let i=0
-		while ! wpa_cli status | grep "wpa_state=COMPLETED" >/dev/null 2>&1; do
-			if [ $i -gt 10 ]; then
-				wpa_cli terminate >/dev/null 2>&1
-				ifconfig $WIFI_INTERFACE down
-				stat_fail && return
-			fi
-			sleep 2
-			let i++
-		done
-	fi
-
-	if [ "$IFOPTS" = "dhcp" -o "$IFOPTS" = "DHCP" ]; then
-		# remove the .pid file if it exists
-		rm -f /var/run/dhcpcd-${INTERFACE}.{pid,cache} >/dev/null 2>&1
-		dhcpcd $DHCPCD_ARGS $INTERFACE
-		[ $? -ne 0 ] && stat_fail && return
-	else
-		# bring up the interface
-		ifconfig $INTERFACE $IFOPTS up
-		[ $? -ne 0 ] && stat_fail && return
-
-		# bring up the default route (gateway)
-		if [ "$GATEWAY" ]; then
-			route add default gw $GATEWAY
-			[ $? -ne 0 ] && stat_fail && return
-		fi
-	fi
-
-	# set the hostname
-	if [ "$HOSTNAME" ]; then
-		hostname $HOSTNAME
-		[ $? -ne 0 ] && stat_fail && return
-	fi
-
-	# Generate a new resolv.conf
-	if [ "$DNS1" ]; then
-		: >/etc/resolv.conf
-		[ $? -ne 0 ] && stat_fail && return
-		[ "$DOMAIN" ] && echo "domain $DOMAIN"   >>/etc/resolv.conf
-		[ "$DNS1" ]   && echo "nameserver $DNS1" >>/etc/resolv.conf
-		[ "$DNS2" ]   && echo "nameserver $DNS2" >>/etc/resolv.conf
-	fi
-
-	# Save the info in /var/run so we can shut it down later
-	mkdir -p $STATE_DIR
-	cp $PROFILE_DIR/$1 $STATE_DIR/$INTERFACE
-	stat_done
-}
-
-menu()
-{
-	if [ "$(ls $PROFILE_DIR 2>/dev/null | grep -v ^template$)" = "" -o ! -d $PROFILE_DIR ]; then
-		echo "No profiles found.  Add profiles in $PROFILE_DIR"
-		return
-	fi
-	# scan all profiles
-	unset profiles
-	DEFAULT=
-	i=0
-	for prof in $(ls $PROFILE_DIR); do
-		# ignore the template
-		[ "$prof" = "template" ] && continue
-		NAME=$prof
-
-		# if there's a profile called "main", use that as default
-		[ "$NAME" = "main" ] && DEFAULT=$NAME
-		unset DESCRIPTION
-		. $PROFILE_DIR/$NAME
-		if [ "$DESCRIPTION" ]; then
-			profiles[$i]=$NAME
-			i=$((i+1))
-			profiles[$i]=$DESCRIPTION
-			i=$((i+1))
-		fi
-	done
-
-	if [ ${#profiles} -eq 0 ]; then
-		echo "No profiles were found in $PROFILE_DIR"
-		return
-	fi
-
-	# if no default yet, use the first entry
-	[ "$DEFAULT" = "" ] && DEFAULT=${profiles[0]}
-
-	ANSWER=$(mktemp) || exit 1
-
-	if [ "$TIMEOUT" != "" ]; then
-		dialog \
-			--output-fd 1 \
-			--timeout $TIMEOUT \
-			--default-item $DEFAULT \
-			--menu "Select the network profile you wish to use\n\n            (timeout in $TIMEOUT seconds)" \
-			13 50 6 \
-			"${profiles[@]}" >$ANSWER
-		ret=$?
-	else
-		dialog \
-			--output-fd 1 \
-			--default-item $DEFAULT \
-			--menu "Select the network profile you wish to use" \
-			13 50 6 \
-			"${profiles[@]}" >$ANSWER
-		ret=$?
-	fi
-
-	case $ret in
-		1) ;;                                # cancel - do nothing
-		255) start_profile $DEFAULT ;;       # timeout - use default
-		0)   start_profile $(cat $ANSWER) ;;  # user selection
-		# abnormal
-		*) echo "abnormal ret code from dialog: $ret" ;;
-	esac
-
-	rm $ANSWER
-}
-
-#
-#  Begin
-#
-
-if [ "$(id -u)" != "0" ]; then
-	echo "This script should be run as root."
-	exit 1
-fi
-
-# Parse command line
-MODE="profile"
-CHECK=0
-PROFILE=
-IFACE=
-TIMEOUT=
-while [ $# -ne 0 ]; do
-	case $1 in
-		--version) MODE="ver"     ;;
-		--help)    MODE="usage"   ;;
-		--menu)    MODE="menu"    ;;
-		--stopall) MODE="stopall" ;;
-		--stop)    MODE="stop"
-		           shift
-		           IFACE=$1       ;;
-		--timeout) shift
-		           TIMEOUT=$1     ;;
-		--*)       MODE="usage"   ;;
-		-c)        CHECK=1        ;;
-		-*)        MODE="usage"   ;;
-		*)         PROFILE=$1     ;;
-	esac
-	shift
-done
-
-if [ "$MODE" = "profile" -a "$PROFILE" = "" ]; then
-	MODE="usage"
-fi
-
-# Figure out what we're doing...
-[ "$MODE" = "ver" ]     && version
-[ "$MODE" = "usage" ]   && usage
-[ "$MODE" = "profile" ] && start_profile $PROFILE
-[ "$MODE" = "stop" ]    && stop_profile $IFACE
-[ "$MODE" = "stopall" ] && stop_all
-[ "$MODE" = "menu" ]    && menu
-
-exit 0
-
-# vim: set ts=2 noet:
diff --git a/network b/network
index ba4bb7d..4dea506 100755
--- a/network
+++ b/network
@@ -3,8 +3,6 @@
 . /etc/rc.conf
 . /etc/rc.d/functions
 
-# wireless settings
-[ -f /etc/conf.d/wireless ] && . /etc/conf.d/wireless
 # ethernet bonding settings
 [ -f /etc/conf.d/bonding ] && . /etc/conf.d/bonding
 # bridge settings
@@ -33,11 +31,6 @@ ifup()
 	fi
 	# don't bring up an interface that's already up
 	[ "$(/sbin/ifconfig ${1} 2>/dev/null | grep UP)" ] && return 0
-	eval iwcfg="\$wlan_${1}"
-	if [ "$iwcfg" != "" ]; then
-		sh -c "/usr/sbin/iwconfig $iwcfg"
-		/bin/sleep 2
-	fi
 	eval ifcfg="\$${1}"
 	if [ "$ifcfg" = "dhcp" ]; then
 		# remove the .pid file if it exists
@@ -163,26 +156,6 @@ case "$1" in
 			exit
 		fi
 
-		# See if we're using network profiles
-		if [ "$NET" ]; then
-			# This env var is passed from the kernel boot line
-			if [ "$NET" = "menu" ]; then
-				/usr/bin/netcfg --menu --timeout 5
-			else
-				/usr/bin/netcfg $NET
-			fi
-		elif [ "$NET_PROFILES" ]; then
-			if [ "$NET_PROFILES" = "menu" ]; then
-				/usr/bin/netcfg --menu --timeout 5
-			else
-				for prof in ${NET_PROFILES[@]}; do
-					if [ "$prof" = "${prof#!}" ]; then
-						/usr/bin/netcfg -c $prof
-					fi
-				done
-			fi
-		fi
-
 		stat_busy "Starting Network"
 		error=0
 		# bring up bridge interfaces
@@ -214,9 +187,6 @@ case "$1" in
 		#	exit
 		#fi
 
-		# shutdown any profiles started by netcfg (or from NET_PROFILES in rc.conf)
-		/usr/bin/netcfg --stopall
-
 		stat_busy "Stopping Network"
 		rm_daemon network
 		error=0
diff --git a/profile-template b/profile-template
deleted file mode 100644
index 868a389..0000000
--- a/profile-template
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Network Profile
-#
-
-DESCRIPTION="Default Network Profile"
-
-# Network Settings
-INTERFACE=eth0
-HOSTNAME=myhost
-
-# Interface Settings (use IFOPTS="dhcp" for DHCP)
-IFOPTS="192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
-GATEWAY=192.168.0.1
-
-# DNS Settings (optional)
-DOMAIN=localdomain
-DNS1=192.168.0.1
-DNS2=
-
-# Wireless Settings (optional)
-#ESSID=default
-#KEY=
-#IWOPTS="mode managed essid $ESSID channel 6 key restricted $KEY"
-
-#WIFI_INTERFACE=wlan0   # use this if you have a special wireless interface
-                        # that is linked to the real $INTERFACE
-
-#WIFI_WAIT=5            # seconds to wait for the wireless card to
-                        # associate before bringing the interface up
-#USEWPA="yes"           # start wpa_supplicant with the profile
-#WPAOPTS=""             # use "" for normal operation or specify additional
-                        # options (eg, "-D ipw")
-                        # see /etc/wpa_supplicant.conf for configuration
-#AUTOWPA="yes"          # automatically configure WPA
-#PASSKEY=""             # wpa passkey/phrase. for use with AUTOWPA
-
diff --git a/rc.conf b/rc.conf
index 43a597e..ed84064 100644
--- a/rc.conf
+++ b/rc.conf
@@ -68,15 +68,15 @@ INTERFACES=(eth0)
 #
 gateway="default gw 192.168.0.1"
 ROUTES=(!gateway)
+
+# To use network profiles, please install the 'netcfg' package
 #
-# Enable these network profiles at boot-up.  These are only useful
-# if you happen to need multiple network configurations (ie, laptop users)
-#   - set to 'menu' to present a menu during boot-up (dialog package required)
-#   - prefix an entry with a ! to disable it
-#
-# Network profiles are found in /etc/network-profiles
+# To to connect to networks on boot, define each in /etc/network.d
+# and then list in NETWORKS=()
+#   - Set to NETWORKS=(menu) to present a menu during boot-up
+#   - Prefix an entry with ! to disable it
 #
-#NET_PROFILES=(main)
+NETWORKS=()
 
 #
 # -----------------------------------------------------------------------
-- 
1.5.3.7

-------------- next part --------------
>From 71c34b3a827deb9ca8cac1a272a2a1cbb2bdc54d Mon Sep 17 00:00:00 2001
From: James Rayner <james at archlinux.org>
Date: Thu, 20 Dec 2007 23:23:19 +1100
Subject: [PATCH] tidy up rc.conf

---
 rc.conf |   35 +++++++++++++++++------------------
 1 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/rc.conf b/rc.conf
index ed84064..aff95e5 100644
--- a/rc.conf
+++ b/rc.conf
@@ -2,7 +2,6 @@
 # /etc/rc.conf - Main Configuration for Arch Linux
 #
 
-#
 # -----------------------------------------------------------------------
 # LOCALIZATION
 # -----------------------------------------------------------------------
@@ -23,30 +22,31 @@ CONSOLEFONT=
 CONSOLEMAP=
 USECOLOR="yes"
 
-#
+
 # -----------------------------------------------------------------------
 # HARDWARE
 # -----------------------------------------------------------------------
 #
-# Scan hardware and load required modules at bootup
+# MOD_AUTOLOAD: Scan hardware and load required modules at bootup
+# MOD_BLACKLIST: Prevent udev from loading these modules
+# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
+#
 MOD_AUTOLOAD="yes"
-# Module Blacklist - modules in this list will never be loaded by udev
 MOD_BLACKLIST=()
-#
-# Modules to load at boot-up (in this order)
-#   - prefix a module with a ! to blacklist it
-#
 MODULES=()
-# Scan for LVM volume groups at startup, required if you use LVM
+
+# USELVM: Scan for LVM volume groups at startup, required if you use LVM
 USELVM="no"
 
-#
+
 # -----------------------------------------------------------------------
 # NETWORKING
 # -----------------------------------------------------------------------
 #
-HOSTNAME="myhost"
+# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
 #
+HOSTNAME="myhost"
+
 # Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available
 # interfaces.
 #
@@ -54,14 +54,13 @@ HOSTNAME="myhost"
 # Declare each interface then list in INTERFACES
 #   - prefix an entry in INTERFACES with a ! to disable it
 #   - no hyphens in your interface names - Bash doesn't like it
-#
-# Note: to use DHCP, set your interface to be "dhcp" (eth0="dhcp")
-#
-# Don't use this for wireless interfaces, see network profiles below
+# 
+# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
+# Wireless: See network profiles below
 #
 eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
 INTERFACES=(eth0)
-#
+
 # Routes to start at boot-up (in this order)
 # Declare each route then list in ROUTES
 #   - prefix an entry in ROUTES with a ! to disable it
@@ -71,14 +70,14 @@ ROUTES=(!gateway)
 
 # To use network profiles, please install the 'netcfg' package
 #
-# To to connect to networks on boot, define each in /etc/network.d
+# To connect to networks on boot, define each in /etc/network.d
 # and then list in NETWORKS=()
 #   - Set to NETWORKS=(menu) to present a menu during boot-up
 #   - Prefix an entry with ! to disable it
 #
 NETWORKS=()
 
-#
+
 # -----------------------------------------------------------------------
 # DAEMONS
 # -----------------------------------------------------------------------
-- 
1.5.3.7



More information about the arch-dev-public mailing list