#!/bin/bash
# --- 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/base/installer/stone_mod_install.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 ---
#
# [INSTALL] 10 installer ROCK Linux Operation System Installer V2

MAIN_MENU="'Start Installation!' 'main_start_installation' "
# The main menu, displayed when 'stone install' is called
POSTINSTALL_BEFORE_CHROOT=""
# Commands to execute before doing the postinstall chroot
# Format is:
# function_1 function_2 function_3 ... function_n

main_start_installation() {
	stone packages

	grep ' /mnt/target[/ ]' /proc/mounts | \
		sed 's,/mnt/target/\?,/,' > /mnt/target/etc/mtab

	for x in ${POSTINSTALL_BEFORE_CHROOT} ; do
		$x
	done

	mount --rbind /dev /mnt/target/dev
	mount -v -t proc proc /mnt/target/proc
	mount -v -t sysfs sysfs /mnt/target/sys
	chroot /mnt/target sh -c ". /etc/profile ; stone setup"
	umount -v /mnt/target/{dev,proc,sys}

	if gui_yesno "Do you want to un-mount the filesystems and reboot now?"
	then
		cd /
		sync
		shutdown -r now
	else
		echo
		echo "You might want to umount all filesystems now and reboot"
		echo "the system now using the commands:"
		echo
		echo "	umount -adrv"
		echo "	reboot -f"
		echo
		echo "Or by executing 'shutdown -r now' which will run the above commands."
		echo
	fi
}

main() {
# Stuff we need to set up
# filesystems
#	raids
#	encryption
#	lvm
# keyboard layout
# package selection
# after-install stuff will be done by '# stone setup'

	for subscript in ${SETUPD}/mod_install_*.sh ; do
		subscript="${subscript#${SETUPD}/}"
		if [ "${subscript%_*}" == "mod_install" ] ; then
			. ${SETUPD}/${subscript}
		fi
	done
	
	local run=1
	while [ "${run}" == "1" ] ; do
		eval gui_menu MAIN_MENU "'ROCK Linux Installer'" ${MAIN_MENU}
		if [ "${?}" == "1" ] ; then	# Cancel was pressed
			run=0
		fi
	done
}

