664 lines
23 KiB
Bash
Executable File
664 lines
23 KiB
Bash
Executable File
# openmamba installation script
|
|
# Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
|
#
|
|
# For the devfs2gdev() function:
|
|
# Copyright (c) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
|
|
#
|
|
# Released under the terms of the GNU GPLv3 License
|
|
|
|
VERSION=1.1
|
|
TEXTDOMAIN=installer
|
|
TEXTDOMAINDIR=/opt/kde3/share/locale/
|
|
INSTALL_DATE=`date +%Y%m%d-%H%M`
|
|
INPUT_FILE=~/.installer.conf
|
|
MAMBAWELCOME_SCRIPT=/usr/share/openmamba/mambawelcome/mambawelcome.sh
|
|
LOG_FILE=/var/log/install-$INSTALL_DATE.log
|
|
MOUNTPOINT=/mnt/install
|
|
KERNEL_RELEASE=`uname -r`
|
|
|
|
function abort() {
|
|
[ "$DCOPID" ] && {
|
|
dcop $DCOPID KommanderIf setText progressText $"Installation aborted; press Next to see the error log."
|
|
dcop $DCOPID KommanderIf setText finallabel $"Installation aborted :-("
|
|
dcop $DCOPID KommanderIf setEnabled next true
|
|
}
|
|
exit 1
|
|
}
|
|
|
|
function finished() {
|
|
[ "$DCOPID" ] && {
|
|
dcop $DCOPID KommanderIf setText progressText $"Installation completed; press Next to continue."
|
|
dcop $DCOPID KommanderIf setText progressBar 100
|
|
dcop $DCOPID KommanderIf setText installTopLabel $"Installation completed."
|
|
dcop $DCOPID KommanderIf setText installInfoLabel ""
|
|
dcop $DCOPID KommanderIf setEnabled next true
|
|
dcop $DCOPID KommanderIf setEnabled ProgressGroupBox true
|
|
}
|
|
exit 1
|
|
}
|
|
|
|
function dcop_write() {
|
|
[ "$DCOPID" ] && {
|
|
dcop $DCOPID KommanderIf setText progressText "$1"
|
|
dcop $DCOPID KommanderIf setText progressBar $2
|
|
}
|
|
}
|
|
|
|
function dcop_write_details() {
|
|
[ "$DCOPID" ] && {
|
|
dcop $DCOPID KommanderIf setText progressText2 "$1"
|
|
}
|
|
}
|
|
|
|
function apt_parser() {
|
|
while read line; do
|
|
[ "$DCOPID" ] && {
|
|
echo $line
|
|
dcop $DCOPID KommanderIf setText progressText2 "$line"
|
|
}
|
|
done
|
|
}
|
|
|
|
cp_parser_count=0
|
|
date_start=`date +%s`
|
|
|
|
function cp_parser() {
|
|
while read line; do
|
|
let cp_parser_count+=1
|
|
if [ $cp_parser_count -ge 100 ]; then
|
|
CP_LINE=`echo ${line/*$MOUNTPOINT/}`
|
|
MOUNT_SPACE=`df -m $MOUNTPOINT | tail -1 | awk '{ print $3; }'`
|
|
PERCENT=`expr $MOUNT_SPACE \* 100 / $TOTAL_SPACE`
|
|
let TIME_ELAPSED=\(`date +%s`-$date_start\)/60
|
|
if [ "$DCOPID" ]; then
|
|
dcop_write $"Copying files (/$d)..." `expr $PERCENT / 2 + $prog`
|
|
dcop_write_details $"\
|
|
Copying: '$CP_LINE
|
|
${MOUNT_SPACE} Mbytes copied
|
|
Installation time: $TIME_ELAPSED minutes"
|
|
else
|
|
echo -e -n "\rCopying files (${MOUNT_SPACE}M ${TIME_ELAPSED}m ${PERCENT}%) "
|
|
echo -e -n "\rCopying files (${MOUNT_SPACE}M ${TIME_ELAPSED}m ${PERCENT}%) ${CP_LINE:0:40}..."
|
|
fi
|
|
cp_parser_count=0
|
|
fi
|
|
done
|
|
}
|
|
|
|
function get_udisks_key() {
|
|
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
|
|
}
|
|
|
|
[ "$1" = "-y" ] || {
|
|
echo $"Warning: this script will perform an automatic installation erasing all the"
|
|
echo $" contents of device $INSTALL_DEVICE; use $0 -y to actually start the"
|
|
echo $" operation."
|
|
exit 0
|
|
}
|
|
|
|
DCOPID=$2
|
|
|
|
echo $"\
|
|
openmamba installation script - version $VERSION
|
|
Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
|
"
|
|
|
|
dcop_write $"Starting installation..." 5
|
|
|
|
[ -r $INPUT_FILE ] || {
|
|
echo $"Error: cannot read input file $INPUT_FILE; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
. $INPUT_FILE
|
|
|
|
FORMAT_APPEND=
|
|
[ "$INSTALL_HOSTNAME" ] || INSTALL_HOSTNAME="openmamba"
|
|
|
|
case "$INSTALL_FSTYPE" in
|
|
ext2|ext3|ext4) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE"
|
|
[ "$INSTALL_HOSTNAME" ] && \
|
|
FORMAT_APPEND="$FORMAT_APPEND -L $INSTALL_HOSTNAME"
|
|
;;
|
|
reiserfs|reiser4) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE"
|
|
FORMAT_APPEND="$FORMAT_APPEND -ff"
|
|
[ "$INSTALL_HOSTNAME" ] && \
|
|
FORMAT_APPEND="$FORMAT_APPEND -l $INSTALL_HOSTNAME"
|
|
;;
|
|
*) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE"
|
|
[ -e "$FORMAT_CMD" ] || {
|
|
echo $"Error: $INSTALL_FSTYPE is not a supported filesystem type; aborting." >&2
|
|
abort
|
|
}
|
|
;;
|
|
"") echo $"Error: filesystem type non specified; aborting." >&2
|
|
abort
|
|
;;
|
|
esac
|
|
|
|
if [ "$INSTALL_HOME_DEVICE" ]; then
|
|
case "$INSTALL_HOME_FSTYPE" in
|
|
ext2|ext3|ext4) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE"
|
|
FORMAT_HOME_APPEND="$FORMAT_APPEND -L home"
|
|
;;
|
|
reiserfs|reiser4) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE"
|
|
FORMAT_HOME_APPEND="$FORMAT_APPEND -ff -l home"
|
|
;;
|
|
*) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE"
|
|
[ -e "$FORMAT_HOME_CMD" ] || {
|
|
echo $"Error: $INSTALL_HOME_FSTYPE is not a supported filesystem type; aborting." >&2
|
|
abort
|
|
}
|
|
;;
|
|
"") echo $"Error: filesystem type non specified; aborting." >&2
|
|
abort
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
[ $INSTALL_DEVICE ] || {
|
|
echo $"Error: installation device is not defined in $INPUT_FILE; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
#INSTALL_DISK_DEVICE=${INSTALL_DEVICE:0:8}
|
|
|
|
[ -e $INSTALL_DEVICE ] || {
|
|
echo $"Error: missing install device $INSTALL_DEVICE; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
echo $"openmamba installation started"
|
|
|
|
tempfile=`tempfile 2>/dev/null`
|
|
mapfile=`tempfile 2>/dev/null`
|
|
|
|
# generate current volumes sorted list with driver information
|
|
devices=`udisks --enumerate-device-files | grep -v /dev/disk`
|
|
for s in $storages; do
|
|
native_path=`get_udisks_key $device native-path`
|
|
[ -e $native_path/partition ] && continue
|
|
is_system_internal=`get_udisks_key $device "system internal"`
|
|
#linux_driver=`find_driver_for_udi $s`
|
|
[ "${device:5:2}" = "sd" -o "${device:5:2}" = "hd" ] && \
|
|
echo "${device:0:8}" >> $tempfile
|
|
if [ "$INSTALL_BOOTLOADER_DEVICE" = "$device" ]; then
|
|
INSTALL_BOOTLOADER_DEVICE_INTERNAL=$is_system_internal
|
|
fi
|
|
done
|
|
# sort
|
|
cat $tempfile|sort > $mapfile
|
|
rm -f $tempfile
|
|
|
|
echo $"Available disks information"
|
|
echo "==========================="
|
|
cat $mapfile
|
|
echo
|
|
|
|
LETTERS=(a b c d e f g h i j k l m n o p q r s t u v w x y z)
|
|
|
|
GRUB_DRIVE_NUMBER=0
|
|
while read line; do
|
|
set -- $line
|
|
[ "$1" = "${INSTALL_DEVICE:0:8}" ] && REMAPPED_INSTALL_DEVICE="${INSTALL_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_DEVICE:8:2}"
|
|
[ "$1" = "${INSTALL_HOME_DEVICE:0:8}" ] && REMAPPED_INSTALL_HOME_DEVICE="${INSTALL_HOME_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_HOME_DEVICE:8:2}"
|
|
[ "$2" = "$INSTALL_DRIVER" ] && {
|
|
DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $1)
|
|
DEV_NAME_DEST=(${DEV_NAME_DEST[*]} ${1:0:7}${LETTERS[CURR_DRIVE_LETTER]})
|
|
GRUB_NAME_DEST=(${GRUB_NAME_DEST[*]} hd${GRUB_DRIVE_NUMBER})
|
|
let CURR_DRIVE_LETTER+=1
|
|
let GRUB_DRIVE_NUMBER+=1
|
|
PREV_DEV_NAME=$1
|
|
}
|
|
done < $mapfile
|
|
[ "$REMAPPED_INSTALL_DEVICE" ] || REMAPPED_INSTALL_DEVICE=$INSTALL_DEVICE
|
|
[ "$REMAPPED_INSTALL_HOME_DEVICE" ] || REMAPPED_INSTALL_HOME_DEVICE=$INSTALL_HOME_DEVICE
|
|
echo $"Install device $INSTALL_DEVICE will be known as $REMAPPED_INSTALL_DEVICE in the installed system"
|
|
|
|
# other drivers follow the root disk device driver
|
|
while read line; do
|
|
set -- $line
|
|
# differentiate letter count for e.g. hd* and sd* disks
|
|
[ "${1:5:2}" != "${PREV_DEV_NAME:5:2}" ] && CURR_DRIVE_LETTER=0
|
|
PREV_DEV_NAME=$1
|
|
[ "$2" = "$INSTALL_DRIVER" ] && continue
|
|
DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $1)
|
|
DEV_NAME_DEST=(${DEV_NAME_DEST[*]} ${1:0:7}${LETTERS[CURR_DRIVE_LETTER]})
|
|
GRUB_NAME_DEST=(${GRUB_NAME_DEST[*]} hd${GRUB_DRIVE_NUMBER})
|
|
let CURR_DRIVE_LETTER+=1
|
|
let GRUB_DRIVE_NUMBER+=1
|
|
done < $mapfile
|
|
|
|
echo $"The following live versus installed system mappings have been calculated:"
|
|
for i in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
|
|
echo "${DEV_NAME_ORIG[i-1]} -> ${DEV_NAME_DEST[i-1]} (${GRUB_NAME_DEST[i-1]})"
|
|
done
|
|
echo
|
|
|
|
if [ "$INSTALL_HOME_DEVICE" ]; then
|
|
mount | grep "$INSTALL_HOME_DEVICE " && {
|
|
echo $"Info: device $INSTALL_HOME_DEVICE already mounted; unmounting."
|
|
umount $INSTALL_HOME_DEVICE || {
|
|
echo $"Error: could not unmount $INSTALL_HOME_DEVICE; aborting." >&2
|
|
abort
|
|
}
|
|
}
|
|
fi
|
|
|
|
mount | grep "$INSTALL_DEVICE " && {
|
|
echo $"Info: device $INSTALL_DEVICE already mounted; unmounting."
|
|
[ -e $MOUNTPOINT/dev ] && umount $MOUNTPOINT/dev
|
|
[ -e $MOUNTPOINT/proc ] && umount $MOUNTPOINT/proc
|
|
mount | grep " $MOUNTPOINT/home " && umount $MOUNTPOINT/home
|
|
umount $INSTALL_DEVICE || {
|
|
echo $"Error: could not unmount $INSTALL_DEVICE; aborting." >&2
|
|
abort
|
|
}
|
|
}
|
|
|
|
mount | grep "on $MOUNTPOINT/dev" && {
|
|
echo $"Info: device already mounted on $MOUNTPOINT/dev; unmounting." >&2
|
|
umount $MOUNTPOINT/dev || {
|
|
echo $"Error: could not unmount $MOUNTPOINT/dev; aborting." >&2
|
|
abort
|
|
}
|
|
}
|
|
|
|
mount | grep "on $MOUNTPOINT" && {
|
|
echo $"Info: device already mounted on $MOUNTPOINT; unmounting." >&2
|
|
umount $MOUNTPOINT || {
|
|
echo $"Error: could not unmount $MOUNTPOINT; aborting." >&2
|
|
abort
|
|
}
|
|
} || {
|
|
mkdir -p $MOUNTPOINT || {
|
|
echo $"Error: could not create mount point $MOUNTPOINT; aborting." >&2
|
|
abort
|
|
}
|
|
}
|
|
|
|
[ -x $FORMAT_CMD ] || {
|
|
echo $"Error: missing initialization tool $FORMAT_CMD; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
dcop_write $"Formatting device $INSTALL_DEVICE..." 10
|
|
echo $"Formatting device $INSTALL_DEVICE"
|
|
|
|
$FORMAT_CMD $INSTALL_DEVICE $FORMAT_APPEND
|
|
|
|
[ $? -ne 0 ] && {
|
|
echo $"Error: could not format device $INSTALL_DEVICE; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
dcop_write $"Mounting $INSTALL_FSTYPE filesystem..." 10
|
|
echo $"Mounting $INSTALL_FSTYPE filesystem"
|
|
mount $INSTALL_DEVICE $MOUNTPOINT || {
|
|
echo $"Error: could not mount filesystem; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
if [ "$INSTALL_HOME_DEVICE" ]; then
|
|
if [ "$INSTALL_HOME_FORMAT" == "1" ]; then
|
|
dcop_write $"Formatting device $INSTALL_HOME_DEVICE..." 10
|
|
echo $"Formatting device $INSTALL_HOME_DEVICE"
|
|
$FORMAT_HOME_CMD $INSTALL_HOME_DEVICE $FORMAT_HOME_APPEND
|
|
[ $? -ne 0 ] && {
|
|
echo $"Error: could not format device $INSTALL_DEVICE; aborting." >&2
|
|
abort
|
|
}
|
|
fi
|
|
|
|
dcop_write $"Mounting home filesystem..." 10
|
|
echo $"Mounting home filesystem"
|
|
mkdir -p $MOUNTPOINT/home
|
|
mount $INSTALL_HOME_DEVICE $MOUNTPOINT/home || {
|
|
echo $"Error: could not mount home filesystem; aborting." >&2
|
|
abort
|
|
}
|
|
fi
|
|
|
|
echo -n $"Copying files..."
|
|
dcop_write $"Copying files..." 15
|
|
prog=15
|
|
|
|
for d in etc bin boot lib opt sbin srv usr var root; do
|
|
[ ! "$INSTALL_CLONE_MODE" == "1" -a -e /squashfs/$d ] && canonical_dir=/squashfs/$d || canonical_dir=`readlink -f /$d`
|
|
DIR_SPACE=`du -sxm $canonical_dir | awk '{ print $1; }'`
|
|
TOTAL_SPACE=`expr $TOTAL_SPACE + $DIR_SPACE`
|
|
done
|
|
|
|
for d in etc bin boot lib opt sbin srv usr var root; do
|
|
[ ! "$INSTALL_CLONE_MODE" == "1" -a -e /squashfs/$d ] && canonical_dir=/squashfs/$d || canonical_dir=`readlink -f /$d`
|
|
cp -av $canonical_dir $MOUNTPOINT/ | cp_parser || {
|
|
echo $"Error: cannot copy $canonical_dir to $MOUNTPOINT; aborting." >&2
|
|
abort
|
|
}
|
|
done
|
|
|
|
MOUNT_SPACE=`df -m $MOUNTPOINT | tail -1 | awk '{ print $3; }'`
|
|
let TIME_ELAPSED=\(`date +%s`-$date_start\)/60
|
|
dcop_write_details $"\
|
|
|
|
${MOUNT_SPACE} Mbytes copied
|
|
Installation time: $TIME_ELAPSED minutes"
|
|
|
|
CONFIGURED_FILES="/etc/sysconfig/keyboard /etc/sysconfig/i18n /etc/vconsole.conf /etc/locale.conf \
|
|
/etc/X11/xorg.conf /etc/X11/xorg.conf.d/10-keyboard.conf /etc/X11/xorg.conf.d/20-touchpad.conf"
|
|
for f in $CONFIGURED_FILES; do
|
|
cp $f ${MOUNTPOINT}/${f}
|
|
done
|
|
echo
|
|
|
|
mkdir -p $MOUNTPOINT/{dev,home,initrd,media,mnt,proc,run,sys,tmp}
|
|
chmod 1777 $MOUNTPOINT/tmp
|
|
chmod 0750 $MOUNTPOINT/root
|
|
|
|
# create base devices
|
|
[ -x /lib/udev/devices/MAKEDEV ] || {
|
|
echo $"Error: cannot run MAKEDEV; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
UDEV_ROOT=$MOUNTPOINT/dev /lib/udev/devices/MAKEDEV
|
|
|
|
dcop_write $"Binding system dirs to new mountpoint..." 73
|
|
echo $"Binding /dev to new mountpoint"
|
|
mount -o bind /dev $MOUNTPOINT/dev || {
|
|
echo $"Error: could not bind /dev to new mountpoint; aborting." >&2
|
|
abort
|
|
}
|
|
mount -o bind /proc $MOUNTPOINT/proc || {
|
|
echo $"Error: could not bind /proc to new mountpoint; aborting." >&2
|
|
abort
|
|
}
|
|
|
|
# set root partition in fstab
|
|
# must be done before mkinitrd
|
|
#currroot=`readlink /dev/root`
|
|
eval `blkid $INSTALL_DEVICE -o udev`
|
|
[ "$ID_FS_UUID" ] && INSTALL_DEVICE_UUID=$ID_FS_UUID || unset INSTALL_DEVICE_UUID
|
|
grep -v ^/dev $MOUNTPOINT/etc/fstab | grep -v ^UUID= > $MOUNTPOINT/etc/fstab.new
|
|
if [ "$INSTALL_DEVICE_UUID" ]; then
|
|
echo "UUID=$INSTALL_DEVICE_UUID / $INSTALL_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new
|
|
else
|
|
echo "$REMAPPED_INSTALL_DEVICE / $INSTALL_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new
|
|
fi
|
|
|
|
if [ "$INSTALL_HOME_DEVICE" ]; then
|
|
eval `blkid $INSTALL_HOME_DEVICE -o udev`
|
|
[ "$ID_FS_UUID" ] && INSTALL_HOME_DEVICE_UUID=$ID_FS_UUID || unset INSTALL_HOME_DEVICE_UUID
|
|
[ "$INSTALL_HOME_FORMAT" == "1" ] || INSTALL_HOME_FSTYPE="auto"
|
|
if [ "$INSTALL_HOME_DEVICE_UUID" ]; then
|
|
echo "UUID=$INSTALL_HOME_DEVICE_UUID /home $INSTALL_HOME_FSTYPE defaults 2 2" >> $MOUNTPOINT/etc/fstab.new
|
|
else
|
|
echo "$REMAPPED_INSTALL_HOME_DEVICE /home $INSTALL_HOME_FSTYPE defaults 2 2" >> $MOUNTPOINT/etc/fstab.new
|
|
fi
|
|
fi
|
|
mv $MOUNTPOINT/etc/fstab.new $MOUNTPOINT/etc/fstab
|
|
|
|
if [ "$INSTALL_DRIVER" ]; then
|
|
/sbin/lsmod | grep "^$INSTALL_DRIVER " && {
|
|
echo "alias scsi_hostadapter $INSTALL_DRIVER" >> $MOUNTPOINT/etc/modprobe.d/initramfs.conf
|
|
MKINITRAMFS_ADD="--with=$INSTALL_DRIVER"
|
|
} || MKINITRAMFS_ADD=""
|
|
fi
|
|
|
|
# remove not-running installed kernel
|
|
RUNNING_KERNEL=`uname -r | sed "s|[0-9.]*||"`
|
|
for i in `ls $MOUNTPOINT/boot/vmlinuz-*`; do
|
|
INSTALLED_KERNEL=`echo ${i} | sed "s|.*/vmlinuz-[0-9.]*||"`
|
|
[ "$INSTALLED_KERNEL" = "$RUNNING_KERNEL" ] && continue
|
|
dcop_write $"Removing ""$INSTALLED_KERNEL kernel..." 74
|
|
echo $"Removing ""$INSTALLED_KERNEL kernel..."
|
|
chroot $MOUNTPOINT smart remove -y kernel-$INSTALLED_KERNEL
|
|
done
|
|
|
|
dcop_write $"Creating initramfs..." 75
|
|
echo $"Creating initramfs"
|
|
chroot $MOUNTPOINT \
|
|
mkinitrd /boot/initramfs-$KERNEL_RELEASE.img \
|
|
$KERNEL_RELEASE -f $MKINITRAMFS_ADD || \
|
|
{
|
|
echo $"Error: initramfs creation failed; aborting." >&2
|
|
abort
|
|
}
|
|
# --fstab=/etc/fstab ||
|
|
|
|
if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
|
|
dcop_write $"Installing bootloader on $INSTALL_BOOTLOADER_DEVICE..." 85
|
|
INSTALL_BOOTLOADER_DEVICE_BYID=$INSTALL_BOOTLOADER_DEVICE
|
|
for f in `ls /dev/disk/by-id/*`; do
|
|
if [ "$INSTALL_BOOTLOADER_DEVICE" = "`readlink -f $f`" ]; then
|
|
INSTALL_BOOTLOADER_DEVICE_BYID=$f
|
|
break
|
|
fi
|
|
done
|
|
echo "GRUB_INSTALL_DEVICE=$INSTALL_BOOTLOADER_DEVICE_BYID" >> $MOUNTPOINT/etc/sysconfig/grub
|
|
if [ "$INSTALL_BOOTLOADER_DEVICE_INTERNAL" != "1" ]; then
|
|
echo $"Installing grub bootloader on removable device $INSTALL_BOOTLOADER_DEVICE"
|
|
echo "(hd0) $INSTALL_BOOTLOADER_DEVICE" > $MOUNTPOINT/boot/grub/device.map
|
|
grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force
|
|
else
|
|
echo $"Installing grub bootloader on $INSTALL_BOOTLOADER_DEVICE"
|
|
> $MOUNTPOINT/boot/grub/device.map
|
|
for i in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
|
|
echo "(${GRUB_NAME_DEST[i-1]}) ${DEV_NAME_ORIG[i-1]}" >> $MOUNTPOINT/boot/grub/device.map
|
|
done
|
|
grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force
|
|
fi
|
|
|
|
# DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV)
|
|
# DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV)
|
|
|
|
# # create a couple of conversion vectors to convert/dev/sd* devices names
|
|
# # into how they will appear on the installed system
|
|
# unset CURR_DRIVER LOAD_DRIVER_LIST
|
|
# CURR_SD_LETTER=0
|
|
# while read line; do
|
|
# GRUB_DEV=`echo ${line/*[[:space:]]/}`
|
|
# if [ "${GRUB_DEV:0:7}" = "/dev/sd" ]; then
|
|
# NEW_GRUB_DEV=/dev/sd${LETTERS[CURR_SD_LETTER]}
|
|
# let CURR_SD_LETTER+=1
|
|
# else
|
|
# NEW_GRUB_DEV=$GRUB_DEV
|
|
# fi
|
|
# DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV)
|
|
# DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV)
|
|
# done < /boot/grub/device.map
|
|
|
|
if [ "${INSTALL_BOOTLOADER_DEVICE:8:2}" = "" ]; then
|
|
# MBR install: set /boot partition as bootable as required by grub2
|
|
# CHECK: this does not work when install device is an extended partition, but in this case
|
|
# a 1-4 boot partition is already set by another system
|
|
if [ ${INSTALL_DEVICE:8:2} -le 4 ]; then
|
|
parted ${INSTALL_DEVICE:0:8} \
|
|
set ${INSTALL_DEVICE:8:2} boot on || \
|
|
echo $"Warning: there was an error setting /boot partition as bootable." >&2
|
|
fi
|
|
elif [ "$INSTALL_BOOTLOADER_DEVICE_SETBOOTABLE" = "1" ]; then
|
|
parted ${INSTALL_BOOTLOADER_DEVICE:0:8} \
|
|
set ${INSTALL_BOOTLOADER_DEVICE:8:2} boot on || \
|
|
echo $"Warning: there was an error setting bootloader partition as bootable." >&2
|
|
fi
|
|
|
|
[ "$INSTALL_BOOTLOADER_CHAINLOAD" ] && {
|
|
# configure boot chainloader for e.g. windows
|
|
GRUB_OTHER_TITLES=()
|
|
GRUB_OTHER_DEVICES=()
|
|
for i in ${INSTALL_BOOTLOADER_CHAINLOAD[*]}; do
|
|
# FIXME: missing conversion from device to grub (hdx,y) form
|
|
unset ID_FS_UUID
|
|
eval `blkid $i -o udev`
|
|
if [ "$ID_FS_UUID" ]; then
|
|
if [ "$ID_FS_TYPE" = "ntfs" ]; then
|
|
[ "$ID_FS_LABEL" ] &&
|
|
ID_FS_LABEL="Windows ($ID_FS_LABEL)" || ID_FS_LABEL="Windows"
|
|
elif [ "${ID_FS_TYPE:0:3}" = "fat" ]; then
|
|
[ "$ID_FS_LABEL" ] &&
|
|
ID_FS_LABEL="Win/DOS ($ID_FS_LABEL)" || ID_FS_LABEL="Windows/DOS"
|
|
else
|
|
[ "$ID_FS_LABEL" ] &&
|
|
ID_FS_LABEL="Other OS ($ID_FS_LABEL)" || ID_FS_LABEL="Other OS"
|
|
fi
|
|
[ "$ID_FS_LABEL" ] || ID_FS_LABEL="W"
|
|
GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} /dev/disk/by-uuid/$ID_FS_UUID)
|
|
GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"$ID_FS_LABEL\"")
|
|
else
|
|
GRUB_OTHER_DEV=$i
|
|
for o in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
|
|
[ "${DEV_NAME_ORIG[o-1]}" = "${i:5:3}" ] && {
|
|
GRUB_OTHER_DEV=${DEV_NAME_DEST[o-1]}${i:8:2}
|
|
break
|
|
}
|
|
done
|
|
# echo $"Renaming device "${DEV_NAME_ORIG[o-1]}$" to "${DEV_NAME_DEST[o-1]}
|
|
# sed -i "s|/dev/${DEV_NAME_ORIG[o-1]:5:3}|/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
|
|
# $MOUNTPOINT/boot/grub/devices.map \
|
|
# $MOUNTPOINT/etc/sysconfig/grub
|
|
# CURR_ROOT_LETTER=0
|
|
# sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
|
|
# $MOUNTPOINT/boot/grub/grub.cfg
|
|
# done
|
|
GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} $GRUB_OTHER_DEV)
|
|
GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"Windows on $GRUB_OTHER_DEV\"")
|
|
fi
|
|
done
|
|
cat >> $MOUNTPOINT/etc/sysconfig/grub << _EOF
|
|
GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]})
|
|
GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]})
|
|
_EOF
|
|
}
|
|
|
|
# mount all disks and dbus for Grub other linuxes detection to work (30_other_linux)
|
|
mount -o bind /mnt $MOUNTPOINT/mnt
|
|
mount -o bind /var/run/dbus $MOUNTPOINT/var/run/dbus
|
|
for d in /mnt/*; do
|
|
[ -d $d ] && mount -o bind,ro $d ${MOUNTPOINT}${d}
|
|
done
|
|
chroot $MOUNTPOINT grub-mkconfig -o /boot/grub/grub.cfg
|
|
for d in /mnt/*; do
|
|
[ -d $d ] && umount ${MOUNTPOINT}${d}
|
|
done
|
|
umount $MOUNTPOINT/var/run/dbus
|
|
umount $MOUNTPOINT/mnt
|
|
|
|
# for o in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
|
|
# [ ${DEV_NAME_ORIG[o-1]} != ${DEV_NAME_DEST[o-1]} ] & continue
|
|
# echo $"Renaming device "${DEV_NAME_ORIG[o-1]}$" to "${DEV_NAME_DEST[o-1]}
|
|
# sed -i "s|/dev/${DEV_NAME_ORIG[o-1]:5:3}|/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
|
|
# $MOUNTPOINT/boot/grub/devices.map \
|
|
# $MOUNTPOINT/etc/sysconfig/grub
|
|
# CURR_ROOT_LETTER=0
|
|
# sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
|
|
# $MOUNTPOINT/boot/grub/grub.cfg
|
|
# done
|
|
|
|
[ "${INSTALL_DEVICE}" != "${REMAPPED_INSTALL_DEVICE}" ] && \
|
|
sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${REMAPPED_INSTALL_DEVICE:5:5}|" \
|
|
$MOUNTPOINT/boot/grub/grub.cfg
|
|
else
|
|
echo $"Info: skipping bootloader installation"
|
|
fi
|
|
|
|
## MBR backup
|
|
#echo "Installing MBR record on $INSTALL_BOOTLOADER_DEVICE"
|
|
#dd if=$INSTALL_BOOTLOADER_DEVICE of=$MOUNTPOINT/boot/mbr-backup bs=1 count=512
|
|
#install-mbr $INSTALL_BOOTLOADER_DEVICE
|
|
|
|
dcop_write $"Configuring system startup files..." 85
|
|
echo $"Configuring system startup files"
|
|
|
|
# configure inittab
|
|
sed -i "s,^\([1-3]\):.*,\1:2345:respawn:/sbin/agetty tty\1 9600," \
|
|
$MOUNTPOINT/etc/inittab
|
|
|
|
# enable multithreaded init
|
|
sed -i "s|multithread=.*|multithread=1|" $MOUNTPOINT/etc/sysconfig/rc
|
|
chroot $MOUNTPOINT depinit
|
|
|
|
if [ -d /cdrom/openmamba/base ]; then
|
|
|
|
# openmamba install_packages script section
|
|
dcop_write $"Installing packages..." 90
|
|
echo $"Installing packages"
|
|
|
|
PKGGROUPS_DB=$MOUNTPOINT/usr/share/openmamba/pkggroups.db
|
|
. $PKGGROUPS_DB
|
|
|
|
# trap "umount $MOUNTPOINT/var/lib/apt/cdrom 2>/dev/null" 0 1 2 5 15
|
|
|
|
mount -o bind /cdrom $MOUNTPOINT/var/lib/apt/cdrom
|
|
chroot $MOUNTPOINT apt-cdrom add -m -d /var/lib/apt/cdrom
|
|
|
|
# disable the service command
|
|
mv $MOUNTPOINT/sbin/service $MOUNTPOINT/sbin/service.preinst
|
|
ln -sf /bin/true $MOUNTPOINT/sbin/service
|
|
|
|
echo $"Launching chrooted apt-get..."
|
|
chroot $MOUNTPOINT apt-get -y install $ALL_PKGS \
|
|
-o Acquire::CDROM::mount=/var/lib/apt/cdrom \
|
|
-o Acquire::CDROM::Copy=false \
|
|
-o Acquire::CDROM::Copy-All=false | apt_parser
|
|
|
|
# re-enable the service command
|
|
rm -f $MOUNTPOINT/sbin/service
|
|
mv $MOUNTPOINT/sbin/service.preinst $MOUNTPOINT/sbin/service
|
|
|
|
umount $MOUNTPOINT/var/lib/apt/cdrom 2>/dev/null
|
|
|
|
# installation completed, remove cdrom volume from apt sources list
|
|
sed -i "s|^\(rpm cdrom:.*\)|#\1|" $MOUNTPOINT/etc/apt/sources.list
|
|
fi
|
|
|
|
dcop_write $"Removing/cleaning unnecessary files and packages..." 95
|
|
echo $"Removing/cleaning unnecessary files and packages"
|
|
# remove unnecessary files and packages for fixed disk install
|
|
rpm -r $MOUNTPOINT -e livecd-tools
|
|
[ "$INSTALL_STABLE_UPDATES" = "1" ] && rpm -r $MOUNTPOINT -e openmamba-devel 2>/dev/null
|
|
|
|
sed -i /eject_cd.sh/d $MOUNTPOINT/etc/rc0.d/K99halt
|
|
sed -i /eject_cd.sh/d $MOUNTPOINT/etc/rc6.d/K99reboot
|
|
|
|
# fix paths in root home directory and perform some cleanup
|
|
for d in $MOUNTPOINT/root/.kde $MOUNTPOINT/root/.kde4 $MOUNTPOINT/root/.qt; do
|
|
[ -e $d ] && find $d -type f -exec sed -i "s|/squashfs||" {} \;
|
|
done
|
|
rm -f $MOUNTPOINT/root/.DCOPserver* $MOUNTPOINT/root/.ICEauthority
|
|
|
|
[ "$INSTALL_USER" -a -e $MOUNTPOINT/$MAMBAWELCOME_SCRIPT ] && {
|
|
dcop_write $"Configuring users and host..." 87
|
|
echo $"Configuring users and host"
|
|
chroot $MOUNTPOINT sh $MAMBAWELCOME_SCRIPT -y
|
|
}
|
|
|
|
# FIXME: test gconftool-2 --shutdown
|
|
[ "`pidof gconfd-2`" ] && killall -9 gconfd-2
|
|
|
|
umount $MOUNTPOINT/dev
|
|
umount $MOUNTPOINT/proc
|
|
[ "$INSTALL_HOME_DEVICE" ] && umount $MOUNTPOINT/home
|
|
|
|
# NOTE: move INPUT_FILE instead of copying to prevent mambawelcome from starting from
|
|
# bootusb after an installation
|
|
cp $INPUT_FILE $MOUNTPOINT/root/
|
|
mv $INPUT_FILE ~/.installer.conf.$INSTALL_DATE
|
|
|
|
REDIRECTED_FILE=`readlink /proc/$$/fd/1`
|
|
[ -f $REDIRECTED_FILE ] && {
|
|
cp -a $REDIRECTED_FILE ${MOUNTPOINT}${LOG_FILE}
|
|
[ -f ${MOUNTPOINT}${REDIRECTED_FILE} ] && rm -f ${MOUNTPOINT}${REDIRECTED_FILE}
|
|
}
|
|
|
|
## now remove sensible information from input file
|
|
#sed -i "/^INSTALL_ROOT_PASSWORD=.*/d" $INPUT_FILE
|
|
#sed -i "/^INSTALL_USER_PASSWORD=.*/d" $INPUT_FILE
|
|
|
|
umount $MOUNTPOINT
|
|
finished
|
|
|
|
echo $"Installation done. You can now reboot to start the freshly installed system."
|
|
|
|
exit 0
|