aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/make-boot-splash
blob: 9bf64a01d487f8be85f10f5d80453af6bb65fbcc (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
#!/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=Mandriva

[ $# = 2 ] || { echo "usage: $0 <initrd> <resolution>"; exit 1; }

initrd_file=$1
vgamode=$2

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
else 
    echo "unknown resolution \"$vgamode\""
    [ "$vgamode" = "auto" ] && echo 'resolution "auto" is not handled anymore'
    exit 1
fi

if [[ -f $splash_cfg/themes/$THEME/config/bootsplash-$resolution.cfg ]];then
    config=$splash_cfg/themes/$THEME/config/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 [[ -z $config ]];then
    echo "Can't find a config file for resolution $resolution";
    exit 1;
fi

# warly: we cannot use file command which is in /usr/bin/
# initrd_type=`zcat /boot/initrd-2.6.14-2mdk.ramfs.img | file -`

if `/bin/zcat $initrd_file 2> /dev/null | /bin/cpio -t &> /dev/null`; then
    tmp_dir=`mktemp -d`
    pushd $tmp_dir &> /dev/null
    /bin/zcat $initrd_file 2>/dev/null | /bin/cpio -id 2>/dev/null
    if [[ -x /sbin/splash ]]; then
        /sbin/splash -s -f $config > $tmp_dir/bootsplash
    else 
	if [[ -f $tmp_dir/bootsplash ]]; then
            rm -f $tmp_dir/bootsplash
        fi
    fi
    /bin/find . -print | /bin/cpio -o 2> /dev/null | gzip -c > $initrd_file
    popd &> /dev/null
    rm -rf $tmp_dir 
else 
    $splash_dir/scripts/remove-boot-splash $initrd_file

    if [[ -x /sbin/splash ]]; then
        /sbin/splash -s -f $config >> $initrd_file
    fi
fi
    
if [ -z "$DURING_INSTALL" ]; then
    $splash_dir/scripts/switch-themes -u
fi