# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
# 
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# Please add additional copyright information _after_ the line containing
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
# 
# ROCK Linux: rock-src/package/sparc/silo/stone_mod_silo.sh
# ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. A copy of the GNU General Public
# License can be found at Documentation/COPYING.
# 
# Many people helped and are helping developing ROCK Linux. Please
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
# file for details.
# 
# --- ROCK-COPYRIGHT-NOTE-END ---
#
# [MAIN] 70 silo SILO Boot Loader Setup

create_silo_conf() {
	rootdev="`grep '^/dev/.* / ' /etc/fstab | tr ' ' '\t' | cut -f1`"
	cat << EOT > /etc/silo.conf
timeout=40
default=rock

image[sun4c,sun4d,sun4m]=/boot/vmlinux32.gz
	label=rock
	root=$rootdev
	read-only

image[sun4u]=/boot/vmlinux64.gz
	label=rock
	root=$rootdev
	read-only

EOT
	gui_message "This is the new /etc/silo.conf file:

$( cat /etc/silo.conf )"

}

install_silo() {
	if [ -n "`ls -l /dev/discs/disc0 | grep scsi`" ] ; then
		# Ultra 30 and many more...
		DEV="sda";
	else
		# IDE - by default this is slave, but let's check...
		if [ -n "`ls -l /dev/discs/disc0 | grep bus0`" ] ; then
			DEV="hda";
		else
			DEV="hdc";
		fi
	fi

	echo "Creating symlinks for /dev/$DEV - silo doesn't do devfs yet."
	ln -s /dev/discs/disc0/disc /dev/$DEV
	for i in /dev/discs/disc0/part* ; do
		PARTNO=`echo $i | sed -e 's,/dev/discs/disc0/part,,'`
		echo "Creating symlink $i -> /dev/$DEV$PARTNO"
		ln -s $i /dev/$DEV$PARTNO
	done

	if silo ; then 
		echo "SILO installed succesfully" ;
	else
		echo "SILO install failed!" ;
	fi
}

main() {
    while
        gui_menu silo 'SILO Boot Loader Setup' \
                '(Re-)Create default /etc/silo.conf' 'create_silo_conf' \
                '(Re-)Install SILO in the Bootblock of /dev/discs/disc0/disc' \
			'gui_cmd "Installing SILO in Bootblock..." "install_silo"' \
                "Edit /etc/silo.conf" \
                        "gui_edit 'SILO Config File' /etc/silo.conf"
    do : ; done
}

