aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/make-boot-splash
blob: d46a33841843cac0c628789bef5d7c00f5071ac1 (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
#!/bin/sh
# -*- Mode: shell-script -*-
# Copyright (C) 2002 by Chmouel Boudjnah <chmouel@mandrakesoft.com>
# Redistribution of this file is permitted under the terms of the GNU 
# Public License (GPL)
# $Id$

: ${splash_dir=/usr/share/bootsplash}
: ${splash_cfg=/etc/bootsplash}

[[ -f /etc/sysconfig/bootsplash ]] && source /etc/sysconfig/bootsplash
[[ -z $THEME ]] && THEME=Mandrake

initrd_file=$1

[[ -z $initrd_file ]] && {
    echo "You need to specify a initrd file as argument"
    exit 1;
}

vgamode=$2

if [[ -z $vgamode || $vgamode == auto ]];then
    vgamode=$( $splash_dir/scripts/detect-resolution )
fi

if [[ $vgamode == 640* ]];then
    resolution=640x480
elif [[ $vgamode == 800* ]];then
    resolution=800x600
elif [[ $vgamode == 1024* ]];then
    resolution=1024x768
elif [[ $vgamode == 1280* ]];then
    resolution=1280x1024
elif [[ $vgamode == 1600* ]];then
    resolution=1600x1200
fi

if [[ -f $splash_dir/themes/$THEME/images/bootsplash-$resolution.jpg && -f $splash_cfg/themes/$THEME/cfg/bootsplash-$resolution.cfg ]];then
    image=$splash_dir/themes/$THEME/images/bootsplash-$resolution.jpg
    config=$splash_cfg/themes/$THEME/cfg/bootsplash-$resolution.cfg
fi

if [[ -f $splash_dir/themes/$THEME/lilo/message ]];then
    cp -f $splash_dir/themes/$THEME/lilo/message /boot/message-graphic
fi

if [[ -n $image ]];then
    if [[ -z $config ]];then
	echo "Can't find a config files for resolution $resolution";
	exit 1;
    fi
else #no image
    echo "Can't find images for resolution $resolution";
    exit 1
fi

# From SuSe mk_initrd script
function out_byte()
{
 	let x=$1
	echo -en "`printf \\\\%o $x`"
}

function write_int()
{
	let tmp1=$[$1 & 255]
	let tmp2=$[$1>>8]
	let tmp2=$[$tmp2&255]
	let tmp3=$[$1>>16]
	let tmp3=$[$tmp3&255]
	let tmp4=$[$1>>24]
	let tmp4=$[$tmp4&255]
	out_byte $tmp1
	out_byte $tmp2
	out_byte $tmp3
	out_byte $tmp4
}
function write_short()
{
	let tmp1=$[$1>>8]
	let tmp2=$[$1&0xff]
	out_byte $tmp2
	out_byte $tmp1
}

function write_header()
{
  	# write signature
	echo -n "BOOTSPL1"
	# write text x coordinate
	write_short $1
	# write text y coordinate
	write_short $2
	# write text width
	write_short $3
	# write text height
	write_short $4
	# write file length
	write_int $5
}

source $config
size=`wc -c<$image`
write_header $tx $ty $tw $th $size >> $initrd_file
cat $image >> $initrd_file

$splash_dir/scripts/switch-themes -u