aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/splash.sh
blob: a8a6f0f5b163f5ff401866b53da7a05333c92e2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#
# splash.sh - script to paint progress bar during
# system startup/shutdown. This script is solely run
# by the init scripts (shell function rc_splash)
#
# (w) 2002-2003 Stefan Reinauer, <stepan@suse.de>
# 2003 Florent Villard, <warly@mandrakesoft.com>
# It's licensed under GPL, of course.
#
# this script expects the following environment variables:
#  nbservices = number of start/stop scripts to be executed for runlevel change
#  progress = number of currently executed start/stop script
#  runlevel = runlevel to be reached.

_procsplash="`cat /proc/splash 2>/dev/null`"
TEXTDOMAIN=bootsplash
TEXTDOMAINDIR=/etc/locale 
LOCPATH=/etc/locale

# execute splash binary utility because we are a wrapper:
if [ "$1" == "-s" -o "$1" == "-u" -o "$1" == "-n" -o "$1" == "-f" ]; then
    exec /sbin/splash $*
else
   ( exec /sbin/splash "$*" )
fi

gprintf() {
    if [ -x /bin/gettext -a -n "$1" ]; then
	if [ -n "$GP_LANG" ]; then
	    TEXT=`LC_MESSAGES=$GP_LANG gettext -e --domain=$TEXTDOMAIN "$1"`
	else
	    TEXT=`gettext -e --domain=$TEXTDOMAIN "$1"`
	fi
    else
	TEXT=$1
    fi
    [ "${1#*\\n}" ] || TEXT="$TEXT\n"
}

# assertions
test -r /proc/splash || exit 0
test -z "`echo $_procsplash|grep on`" && exit 0

if [[ -z $res ]]; then 
    res=`fbresolution`
    if [[ -f /etc/sysconfig/bootsplash ]]; then
        . /etc/sysconfig/bootsplash
	theme=$THEME
	if [[ -f /etc/bootsplash/themes/$theme/config/bootsplash-$res.cfg ]]; then
	    function box() { true; }
            . /etc/bootsplash/themes/$theme/config/bootsplash-$res.cfg
        fi
    fi
fi

_shutdown="no"
_silent="no"
grep -q silent /proc/cmdline && _silent="yes"
test "$runlevel" == "6" -o "$runlevel" == "0" && _shutdown="yes"

if [ "$1" == "stop" -a $_shutdown == "no" ]; then
    if [[ $LOGO_CONSOLE == No ]] || [[ $LOGO_CONSOLE == no ]] || [[ $LOGO_CONSOLE == NO ]]; then                                                        
	if [[ -e /proc/splash ]];then
	    echo 0 > /proc/splash
	    exit 0
	fi 
    else 
	if [[ $LOGO_CONSOLE == vt ]]; then
	    for i in 0 1 2 3 4 5
	    do
		if [[ -f /etc/bootsplash/themes/$theme/config/vt$i-$res.cfg ]]; then
		    splash -s -u $i /etc/bootsplash/themes/$theme/config/vt$i-$res.cfg
		fi
	    done
	fi
    fi
fi

test -z "$progress" -a -z "$nbservices" && exit 0
grep -vq "splash=silent" /proc/cmdline && exit 0 

if [ "$previous" == "3" -o "$previous" == "5" ] ; then
  if [ "$runlevel"  = "3" -o "$runlevel" == "5" ] ; then
    exit 0
  fi
fi

# acquire data
# 
num=$(( $nbservices + 2 ))

# Initialize and print text string..
if [ "$progress" == 1 -o "$1" == "start" ]; then
    if test "$_shutdown" == "yes"; then 
        gprintf "Shutting down the system..."
        [[ -f /etc/bootsplash/themes/$theme/config/bootsplash-$res.cfg ]] && /sbin/splash -s -u 0 /etc/bootsplash/themes/$theme/config/bootsplash-$res.cfg
        echo "silent" >/proc/splash
        chvt 1
    else 
        gprintf "Booting the system..."
    fi
    _boot=$TEXT
    if [ "$text_x" != "" -a "$text_y" != "" \
        -a "$text_color" != "" -a "$text_size" != "" -a "$_silent" == "yes" ]; then
        gprintf "Press F2 for verbose mode."
        fbtruetype.static -x $text_x -y $text_y -t $text_color -s $text_size \
  			"$_boot $TEXT"
    fi
fi

# Paint progressbar..
test -z "$progress_enable" && exit 0
echo "show $(( 65534 * ( $progress + 1 ) / $num ))" > /proc/splash