#!/bin/sh # -*- Mode: shell-script -*- # Copyright (C) 2002 by Chmouel Boudjnah # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) # $Id$ bootsplashdir=/usr/share/bootsplash sysconfig=/etc/sysconfig/bootsplash bootdir=/boot function list_available_themes () { local basename= for i in $bootsplashdir/themes/*;do basename=${i##*/} echo $basename done } function get_current_theme () { local opt= theme= while read opt ;do [[ $opt != THEME=* ]] && continue theme=${opt##*=} done < $sysconfig #[[ -z $theme ]] && theme="Mandrake" echo $theme } function read_link () { perl -e '{print readlink shift, "\n"}' $1 } function lilo_switch_themes () { local theme=$1 local message_from_theme=$bootsplashdir/themes/$theme/lilo/message local message_from_current=$bootdir/lilo/message #checking if [[ ! -f $message_from_theme ]];then return; fi #Make sure to point on lilo-graphic if [[ -L $bootdir/message ]];then point_to=$(read_link $bootdir/message) if [[ $point_to != message-graphic ]];then rm -f $bootdir/message ln -s message-graphic $bootdir/message fi fi if ! cmp -s $message_from_theme $message_from_current;then cp -f $message_from_theme $bootdir/message-graphic fi } function check_it () { local theme=$1 local ok= c= for c in $(list_available_themes);do [[ $c == $theme ]] && ok=yes done if [[ -z $ok ]];then echo -e "Themes $theme doen't exist\n"; bash $0 -l exit; fi } function update () { local theme=$1; lilo_switch_themes $theme } function switch_theme () { local toswitch=$1 local current_theme=$(get_current_theme) local ok= c= #Seeding if [[ $current_theme != $toswitch ]];then ok= tmpfile=$(mktemp /tmp/.bootsplash.XXXXXXX) cp -f $sysconfig $tmpfile && rm -f $sysconfig while read line;do if [[ $line == SPLASH=* ]];then echo "SPLASH=auto" >> $sysconfig ok=yes continue; fi if [[ $line == THEME=* ]];then echo "THEME=$toswitch" >> $sysconfig ok=yes continue; fi echo $line >> $sysconfig done < $tmpfile if [[ -z $ok ]];then echo "THEME=$toswitch" >> $sysconfig fi rm -f $tmpfile if [[ -d /etc/bootsplash/themes/$toswitch ]]; then rm -f /etc/bootsplash/themes/current ln -s $toswitch /etc/bootsplash/themes/current fi fi lilo_switch_themes $toswitch } function update_boot () { pushd /boot &> /dev/null if [[ -x /usr/share/loader/make-initrd ]]; then /usr/share/loader/make-initrd -n &> /dev/null if [[ -x /usr/sbin/detectloader ]]; then LOADER=$(/usr/sbin/detectloader -q) if [[ $LOADER = "LILO" ]] && [[ -x /sbin/lilo ]];then /sbin/lilo >/dev/null 2>/dev/null fi if [[ $LOADER = "YABOOT" ]] && [[ -x /sbin/ybin ]];then /sbin/ybin >/dev/null 2>/dev/null fi fi fi popd &> /dev/null } function usage () { basename=`basename $0` cat <