1
# This script contains hooks to allow init scripts to control
2
# a splash program during boot and shutdown.
4
# To override these, provide a /lib/init/splash-functions scripts
5
# with new functions (it is sourced at the end of this file)
7
# Note that scripts have a number of constraints:
8
# 1) Should avoid using any binaries not found in the initramfs so that
9
# the same hooks can be used there.
10
# 2) This also means that bashisms can't be used.
11
# 3) Scripts must work when running under "set -e".
12
# 4) "local" should be used to avoid overwriting global variables.
15
# Detects whether a splash is running
16
splash_running() { return 1; }
18
# Tells the splash to quit
19
splash_stop() { return 0; }
21
# Tells the splash to start if not already running
22
splash_start() { return 1; }
24
# Tells the splash the current boot/shutdown progress
25
# $1 contains the progress as a percentage value between -100 and 100
26
# Positive values indicate boot progress
27
# Negative values indicate shutdown progress
33
splash_running || return 0
35
# Sanity check step 1 - must match ^-[0-9]*$
38
# Strip trailing numbers
39
while [ "${tmp%[0-9]}" != "$tmp" ]; do
43
# Now "-" or no characters should remain
44
if [ -n "$tmp" ] && [ "$tmp" != "-" ]; then
48
# Sanity check step 2 - check for values >= -100 and <= 100
49
if [ "$progress" != "${progress#-}" ]; then
51
if [ "$progress" -lt -100 ]; then
56
if [ "$progress" -gt 100 ]; then
61
# Sanity checks passed
62
custom_splash_progress "$progress" || return 1
66
# Customizations should replace this function instead of splash_progress above
67
custom_splash_progress() { return 0; }
70
# Tells the splash that a task which may take an unknown amount of
71
# time has started (such as a fsck). This is useful to make sure the
72
# splash doesn't time out and to give visual feedback to the user.
73
splash_start_indefinite() { return 0; }
75
# Tells the splash that an indefinite task is done
76
splash_stop_indefinite() { return 0; }
78
# Gets user input from a splash
79
# $1 contains the text for the user prompt
80
# $2 describes the type of input:
81
# regular = regular input, e.g. a user name
82
# password = input which should not be echoed to screen, e.g. a password
83
# enter = A "press enter to continue" type of prompt
85
# Returns 1 if no user input is possible
86
# Should be called with an alternative non-splash input fallback:
87
# INPUT="$(splash_user_input "Enter password:" password)" || \
88
# INPUT="$(manual_method)"
89
splash_user_input() { return 1; }
91
# Allow these functions to be overridden with custom scripts. This is
92
# the official API hook.
93
if [ -e /lib/init/splash-functions ] ; then . /lib/init/splash-functions ; fi