[Frugalware-darcs] fwrunit-scripts: fwrunit-scripts: added gettext support, fixed up udev script

AlexExtreme alex at alex-smith.me.uk
Thu Oct 12 20:09:58 CEST 2006


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=fwrunit-scripts;a=darcs_commitdiff;h=20061012181000-46e39-11b940d3899b89d02df60893ed320f874a3322fc.gz;

[fwrunit-scripts: added gettext support, fixed up udev script
AlexExtreme <alex at alex-smith.me.uk>**20061012181000] {
adddir ./lib/init/messages
hunk ./lib/init/functions 40
+# Gettext needs the path to the messages directory set
+TEXTDOMAIN=functions
+TEXTDOMAINDIR=/lib/init/messages
+
hunk ./lib/init/functions 69
-	echo -e "${BLUE}${MSG_PREFIX}${WHITE}${1}${NORMAL}"
+	if [ "$1" = "-n" ]; then
+		echo_opts=" -n"
+		shift
+	fi
+	
+	echo -e${echo_opts} "${BLUE}${MSG_PREFIX}${WHITE}${1}${NORMAL}"
hunk ./lib/init/functions 127
+
+# Usage info
+msg_help() {
+	msg $"Please use $0 $1"
+}
hunk ./lib/init/startup.d/00udev 6
+# Copyright (C) 2004 Greg Kroah-Hartman <greg at kroah.com>
hunk ./lib/init/startup.d/00udev 10
-# Copyright (C) 2004 Greg Kroah-Hartman <greg at kroah.com>
-# Released under the GPL v2 only.
-#
-# Thanks go out to the Gentoo developers for proving 
-# that this is possible to do.
-
hunk ./lib/init/startup.d/00udev 11
-
-mount / -o rw,remount
-
-msg "Mounting /sys..."
-mount none -t sysfs /sys || exit 1
-ok $?
-
hunk ./lib/init/startup.d/00udev 12
-
-prog=udev
-sysfs_dir=/sys
-bin=/sbin/udev
-udevd=/sbin/udevd
-udev_root="/dev"
-
-run_udev () {
-	# handle block devices and their partitions
-	for i in ${sysfs_dir}/block/*; do
-		# add each drive
-		export DEVPATH=${i#${sysfs_dir}}
-		#echo "$DEVPATH"
-		$bin block
-
-		# add each partition, on each device
-		for j in $i/*; do
-			if [ -f $j/dev ]; then
-				export DEVPATH=${j#${sysfs_dir}}
-				#echo "$DEVPATH"
-				$bin block
-			fi
-		done
-	done
-	# all other device classes
-	for i in ${sysfs_dir}/class/*; do
-		for j in $i/*; do
-			if [ -f $j/dev ]; then
-				export DEVPATH=${j#${sysfs_dir}}
-				CLASS=`echo ${i#${sysfs_dir}} | \
-					cut --delimiter='/' --fields=3-`
-				#echo "$DEVPATH"
-				$bin $CLASS
-			fi
-		done
-	done
-	return 0
-}
+TEXTDOMAIN=udev
hunk ./lib/init/startup.d/00udev 15
-	# there are a few things that sysfs does not export for us.
-	# these things go here (and remember to remove them in 
-	# remove_extra_nodes()
-	#
+	# There are a few things that sysfs does not export for us.
+	
hunk ./lib/init/startup.d/00udev 18
-	ln -snf /proc/self/fd $udev_root/fd
-	ln -snf /proc/self/fd/0 $udev_root/stdin
-	ln -snf /proc/self/fd/1 $udev_root/stdout
-	ln -snf /proc/self/fd/2 $udev_root/stderr
-	ln -snf /proc/kcore $udev_root/core
+	ln -snf /proc/self/fd /dev/fd
+	ln -snf /proc/self/fd/0 /dev/stdin
+	ln -snf /proc/self/fd/1 /dev/stdout
+	ln -snf /proc/self/fd/2 /dev/stderr
+	ln -snf /proc/kcore /dev/core
hunk ./lib/init/startup.d/00udev 24
-	mkdir $udev_root/pts
-	mkdir $udev_root/shm
+	mkdir /dev/pts
+	mkdir /dev/shm
hunk ./lib/init/startup.d/00udev 28
-# don't use udev if sysfs is not mounted.
-if [ ! -d $sysfs_dir/block ]; then
-	exit 1
-fi
-
-#echo "mounting... ramfs at $udev_root"
-mount -n -t ramfs none $udev_root
-
-# propogate /udev from /sys
-export ACTION=add
-expor1t UDEV_NO_SLEEP=1
-#echo "Creating initial udev device nodes:"
-
-msg "Creating initial device nodes..."
-
-# You can use the shell scripts above by calling run_udev or execute udevstart
-# which does the same thing, but much faster by not using shell.
-# Only comment out one of the following lines.
-#run_udev
-/sbin/udevstart || exit 1
-ok $?
-
-#echo "making extra nodes"
-msg "Creating extra device nodes..."
-make_extra_nodes
-ok 0
-
-#echo "udev startup is finished!"
-
-if ls /lib/udev/devices/* 2>/dev/null >/dev/null;then
-	cp -a /lib/udev/devices/* /dev
-fi
-
-# check if udevd is already running
-if ! [ `pidof -o %PPID /sbin/udevd` ]; then
-	/sbin/udevd --daemon
-fi
+case "${1}" in
+	start)
+		# We need a writable /
+		mount / -o rw,remount
+		if [ $? -ne 0 ]; then
+			error $"Could not remount / as read-write"
+			exit 1
+		fi
+		
+		# Mount /sys
+		msg $"Mounting /sys..."
+		mount none -t sysfs /sys
+		ok $?
+		
+		# If sysfs is not mounted, die
+		if [ ! -d /sys/block ]; then
+			error $"System cannot boot without sysfs mounted!"
+			exit 1
+		fi
+		
+		# Create the ramfs for Udev
+		msg $"Mounting ramfs on /dev..."
+		mount -n -t ramfs none /dev
+		retval=$?
+		ok $retval
+		if [ $retval -ne 0 ]; then
+			error $"Udev cannot run without ramfs!"
+			exit 1
+		fi
hunk ./lib/init/startup.d/00udev 58
-# Make udevsend the hotplug multiplexer
-if [ -f "/sys/class/tty/console/uevent" ]; then
-	# trigger the sorted events
-	echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
-else
-	echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
-fi 
-mount / -o ro,remount
+		# Propogate /dev from /sys
+		export ACTION=add
+		export UDEV_NO_SLEEP=1
+		
+		msg $"Creating initial device nodes..."
+		
+		/sbin/udevstart
+		retval=$?
+		ok $retval
+		if [ $retval -ne 0 ]; then
+			error $"Failed to run udevstart!"
+			exit 1
+		fi
+		
+		msg "Creating extra device nodes..."
+		make_extra_nodes
+		ok 0
hunk ./lib/init/startup.d/00udev 76
-# end of rc.udev
+		if ls /lib/udev/devices/* 2>/dev/null >/dev/null;then
+			cp -a /lib/udev/devices/* /dev
+		fi
+		
+		# Check if udevd is already running
+		if ! [ `pidof -o %PPID /sbin/udevd` ]; then
+			msg $"Starting udevd..."
+			/sbin/udevd --daemon
+			ok $?
+		fi
+		
+		# Make udevsend the hotplug multiplexer
+		if [ -f "/sys/class/tty/console/uevent" ]; then
+			# Trigger the sorted events
+			echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
+		else
+			echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
+		fi
+		
+		mount / -o ro,remount
+		if [ $? -ne 0 ]; then
+			error $"Could not remount / as read-only"
+			exit 1
+		fi
+		
+		;;
+	*)
+		msg_help "start"
+		exit 1
+		;;
+esac
}


More information about the Frugalware-darcs mailing list