[Pkg-sysvinit-commits] r1070 - in sysvinit/trunk/debian/initscripts/lib: . init

pere at alioth.debian.org pere at alioth.debian.org
Tue Nov 27 11:17:06 UTC 2007


Author: pere
Date: 2007-11-27 11:17:06 +0000 (Tue, 27 Nov 2007)
New Revision: 1070

Added:
   sysvinit/trunk/debian/initscripts/lib/init/splash-functions-base
   sysvinit/trunk/debian/initscripts/lib/init/splash-functions-usplash
Removed:
   sysvinit/trunk/debian/initscripts/lib/lib/
Log:
Move splash functions to the correct location.

Copied: sysvinit/trunk/debian/initscripts/lib/init/splash-functions-base (from rev 1069, sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-base)
===================================================================
--- sysvinit/trunk/debian/initscripts/lib/init/splash-functions-base	                        (rev 0)
+++ sysvinit/trunk/debian/initscripts/lib/init/splash-functions-base	2007-11-27 11:17:06 UTC (rev 1070)
@@ -0,0 +1,99 @@
+# This script contains hooks to allow init scripts to control
+# a splash program during boot and shutdown.
+#
+# To override these, provide a /lib/init/splash-functions scripts
+# with new functions (it is sourced at the end of this file)
+#
+# Note that scripts have a number of constraints:
+#  1) Should avoid using any binaries not found in the initramfs so that 
+#     the same hooks can be used there.
+#  2) This also means that bashisms can't be used.
+#  3) Scripts must work when running under "set -e".
+#  4) "local" should be used to avoid overwriting global variables.
+
+
+# Detects whether a splash is running
+splash_running() { return 1; }
+
+# Tells the splash to quit
+splash_stop () { return 0; }
+
+# Tells the splash to start if not already running
+splash_start () { return 1; }
+
+# Tells the splash the current boot/shutdown progress
+# $1 contains the progress as a percentage value between -100 and 100
+# Positive values indicate boot progress
+# Negative values indicate shutdown progress
+splash_progress ()
+{
+	local progress tmp
+	progress="$1"
+
+	splash_running || return 0
+
+	# Sanity check step 1 - must match ^-[0-9]*$
+	tmp="$progress"
+
+	# Strip trailing numbers
+	while [ "${tmp%[0-9]}" != "$tmp" ]; do
+		tmp="${tmp%[0-9]}"
+	done
+
+	# Now "-" or no characters should remain
+	if [ -n "$tmp" ] && [ "$tmp" != "-" ]; then
+		return 1
+	fi
+
+	#  Sanity check step 2 - check for values >= -100 and <= 100
+	if [ "$progress" != "${progress#-}" ]; then
+		# Negative value
+		if [ "$progress" -lt -100 ]; then
+			return 1
+		fi
+	else
+		# Positive value
+		if [ "$progress" -gt 100 ]; then
+			return 1
+		fi
+	fi
+
+	# Sanity checks passed
+	custom_splash_progress "$progress" || return 1
+	return 0
+}
+
+# Customizations should replace this function instead of splash_progress above
+custom_splash_progress () { return 0; }
+
+
+# Tells the splash that a task which may take an unknown amount of
+# time has started (such as a fsck). This is useful to make sure the
+# splash doesn't time out and to give visual feedback to the user.
+splash_start_indefinate () { return 0; }
+
+# Tells the splash that an indefinate task is done
+splash_stop_indefinate () { return 0; }
+
+# Gets user input from a splash
+# $1 contains the text for the user prompt
+# $2 describes the type of input:
+#     regular  = regular input, e.g. a user name
+#     password = input which should not be echoed to screen, e.g. a password
+#     enter    = A "press enter to continue" type of prompt
+#
+# Returns 1 if no user input is possible
+# Should be called with an alternative non-splash input fallback:
+#   INPUT="$(splash_user_input "Enter password:" password)" || \
+#   INPUT="$(manual_method)"
+splash_user_input () { return 1; }
+
+# Load usplash support while we wait for the usplash package to pick
+# up the new API. [pere 2007-11-18]
+if [ -x /sbin/usplash ] && [ -e /lib/init/splash-functions-usplash ] ; then
+	. /lib/init/splash-functions
+fi
+
+# Allow these functions to be overridden with custom scripts.  This is
+# the official API hook.
+if [ -e /lib/init/splash-functions ] ; then . /lib/init/splash-functions ; fi

Copied: sysvinit/trunk/debian/initscripts/lib/init/splash-functions-usplash (from rev 1069, sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-usplash)
===================================================================
--- sysvinit/trunk/debian/initscripts/lib/init/splash-functions-usplash	                        (rev 0)
+++ sysvinit/trunk/debian/initscripts/lib/init/splash-functions-usplash	2007-11-27 11:17:06 UTC (rev 1070)
@@ -0,0 +1,93 @@
+# Usplash hooks for /lib/init/splash-functions-base
+
+# Internal function, do not use in external scripts
+usplash_pidfound()
+{
+	pidof usplash > /dev/null 2>&1 || return 1
+	return 0
+}
+
+splash_running()
+{
+	if [ -x /sbin/usplash ] && usplash_pidfound; then
+		return 0
+	fi
+	return 1
+}
+
+splash_stop ()
+{
+	local i
+
+	splash_running || return 0
+
+	# Wait until it is gone or forcibly kill it
+	i=0
+	while usplash_pidfound; do
+		i=$(($i + 1))
+		if [ $i -gt 10 ]; then
+			kill -9 $(pidof usplash)
+			break
+		fi
+		sleep 1
+	done
+	return 0
+}
+
+splash_start ()
+{
+	if splash_running; then
+		return 0
+	elif [ ! -x /sbin/usplash ] || [ ! -x /sbin/usplash_down ]; then
+		return 1
+	else
+		/sbin/usplash_down || return 1
+		return 0
+	fi
+}
+
+private_splash_progress ()
+{
+	splash_running || return 0
+	/sbin/usplash_write "PROGRESS $1" || return 1
+	return 0
+}
+
+splash_start_indefinate ()
+{
+	splash_running || return 0
+	/sbin/usplash_write "TIMEOUT 0" || return 1
+	/sbin/usplash_write "PULSATE" || return 1
+	return 0
+}
+
+splash_stop_indefinate ()
+{
+	splash_running || return 0
+	/sbin/usplash_write "CLEAR" || return 1
+	/sbin/usplash_write "TIMEOUT 15" || return 1
+	return 0
+}
+
+splash_user_input ()
+{
+	splash_running || return 1
+	[ -p /dev/.initramfs/usplash_outfifo ] || return 1
+
+	case "$2" in
+		regular)
+			/sbin/usplash_write "INPUT $1" || return 1
+			;;
+		password)
+			/sbin/usplash_write "INPUTQUIET $1" || return 1
+			;;
+		enter)
+			/sbin/usplash_write "INPUTENTER $1" || return 1
+			;;
+		*)
+			return 1
+			;;
+	esac
+	cat /dev/.initramfs/usplash_outfifo 2> /dev/null || return 1
+	return 0
+}




More information about the Pkg-sysvinit-commits mailing list