#!/bin/bash

VERSION=1.0
export VERSION

. bk_functions

# Read in bootkit configuration, create if necessary

# Does config file exist? (.bootkit.config)
if [ ! -f ./.bootkit.config ]
then
	# No - then create it with defaults
	DISKETTEDEV=/dev/fd0
	KERNELPATH=/vmlinuz
	MOUNTPOINT=./mnt
	LIBCLINK=/lib/libc.so.4
	RAMDISK=ON
	COPYLIBC=ON
	ADDBKUSER=ON

	bkSaveOptions

fi

. ./.bootkit.config

export DISKETTEDEV
export KERNELPATH
export MOUNTPOINT
export LIBCLINK
export RAMDISK
export COPYLIBC
export ADDBKUSER

# Main processing loop (main menu)

while [ 0 ]; do

	dialog --backtitle "Linux Bootkit $VERSION - (C)opyright 1995, B. Scott Burkett" \
	       --title "Main Menu"\
	       --menu "\nWelcome to the Linux Bootkit! This package will allow you to create\n\
and manage emergency boot disks, floppy-based root filesystems, and\n\
floppy-based utility diskettes.\n\
\nIf you have trouble using the arrow keys, you can use '+', '-',\n\
TAB instead. Which option would you like?\n" 20 74 6 \
"CONFIG" "Configure the Linux bootkit" \
"BOOTABLE" "Create an emergency boot diskette" \
"ROOTSYS" "Create a floppy-based root filesystem" \
"UTILITY" "Create a floppy-based utility diskette" \
"HELP!" "Help Index" \
"QUIT" "Quit the Linux Bootkit" 2>/tmp/mainselect

if [ $? = 1 -o $? = 255 ]; then 
	reset
	exit
fi

MAINSELECT="`cat /tmp/mainselect`"
rm /tmp/mainselect

# Process Selected Option

if [ "$MAINSELECT" = "CONFIG" ]; then
	./bk_config
	. ./.bootkit.config
fi

if [ "$MAINSELECT" = "BOOTABLE" ]; then
	./bk_mkboot
fi

if [ "$MAINSELECT" = "ROOTSYS" ]; then
	./bk_mkroot
fi

if [ "$MAINSELECT" = "UTILITY" ]; then
	./bk_mkutil
fi

if [ "$MAINSELECT" = "HELP!" ]; then
	./bk_help
fi

if [ "$MAINSELECT" = "QUIT" ]; then
	reset
	break
fi

done
