#!/bin/sh
log "Starting F09-start..."
log "====================="

#=============================================
# 9) call preFirstCall hook scripts
#---------------------------------------------
callHooks preFirstCall

#=============================================
# 9.1) check for driver update mode
#---------------------------------------------
# If /update/y2update/y2update.gz exists (copied there by linuxrc)
# uncompress the y2update.gz file, and mount it to /y2update.
#
# Else make a symlink from /y2update to /update/y2update.
# YaST2 will look for config files and components there.
#
mkdir -p /media/floppy

UPDATE_MOUNTED=false
if [ "$YaST2update" = 1 ] ; then
	if [ -r /update/y2update/y2update.gz ] ; then
		gunzip -c /update/y2update/y2update.gz > /dev/ram5
		mkdir -p /y2update
		if mount -o noatime /dev/ram5 /y2update ; then
			log "\tPacked extension disk... OK"
			UPDATE_MOUNTED=true
		else
			log "\tPacked extension disk... Failed"
		fi
	else
		if [ -d /update/y2update ] ; then
			log "\tUnpacked extension disk..."
			ln -sf /update/y2update /y2update
			UPDATE_MOUNTED=true
		fi
	fi
	[ -r /y2update/logconf.ycp ] && cp /y2update/logconf.ycp /root
fi

#=============================================
# 9.2) goto run stage, start YaST2 (initial)
#---------------------------------------------
rm -f /var/X11R6/bin/X
rm -f /tmp/YaST2_ssh_installation_finished
log "\tDelegate program call to YaST2.call installation initial"
/usr/lib/YaST2/startup/YaST2.call installation initial
yast2exitcode=$?

#=============================================
# 9.3) save log file to installed system
#---------------------------------------------
log "\tCopy first level log file to installed system"
mkdir -p /mnt/var/log/YaST2
cp /var/log/YaST2/y2start.log /mnt/var/log/YaST2

#=============================================
# 9.4) call postFirstCall hook scripts
#---------------------------------------------
callHooks postFirstCall
