diff options
Diffstat (limited to 'abs/core-testing/LinHES-config/install_functions.sh')
-rwxr-xr-x | abs/core-testing/LinHES-config/install_functions.sh | 388 |
1 files changed, 0 insertions, 388 deletions
diff --git a/abs/core-testing/LinHES-config/install_functions.sh b/abs/core-testing/LinHES-config/install_functions.sh index 9f38384..6775337 100755 --- a/abs/core-testing/LinHES-config/install_functions.sh +++ b/abs/core-testing/LinHES-config/install_functions.sh @@ -201,8 +201,6 @@ function init_network { MYTHDEFAULT="eth0" fi - - echo $CMDLINE | grep -q ip if [ $? -eq 0 ] then @@ -260,390 +258,4 @@ function init_remote { #----------------------- -#set -x - -partition_it () { -ROOT=$1 -DATA=$2 -SWAP=$3 - -if [ ! "$SWAP" == "NO" ] - then - SWAPLINE=",$SWAP,S" - MKSWAPCMD="mkswap /dev/${disk}2" - else - SWAPLINE=",0,0" - MKSWAPCMD="" - fi - -if [ "$DATA" == "ALL" ] -then - DATALINE=",,," - EXTRALINE="" -else - DATALINE=",$DATA,," - EXTRALINE=",0,," -fi -sfdisk /dev/$disk -uM << EOF -,$1,,* -$SWAPLINE -$DATALINE -$EXTRALINE -; -EOF - -$MKSWAPCMD -#sfdisk -l /dev/$disk -} - - -function fscmd () { - -case $1 in - reiserfs) FSCMDC="mkreiserfs -q -l ROOT" - ;; - - xfs) FSCMDC="mkfs -t $1 -f" - ;; - ext3) FSCMDC="mkfs.ext3" - ;; - jfs) FSCMDC="mkfs.jfs -q " - ;; - ext4) FSCMDC="mkfs.ext4" - ;; - *) FSCMDC="echo $1" - ;; -esac -} - -format_it () { - fscmd $1 - $FSCMDC /dev/${disk}1| tr -s [:cntrl:] \\n - fscmd $2 - $FSCMDC /dev/${disk}3| tr -s [:cntrl:] \\n -} - -mount_it () { - if [ ! -d \/$mountpoint ] - then - mkdir \/$mountpoint - fi - mount /dev/${disk}1 \/$mountpoint - mkdir \/$mountpoint/myth - mount /dev/${disk}3 \/$mountpoint/myth -} - -unmount_it () { - umount /dev/${disk}1 - umount /dev/${disk}3 - umount \/$mountpoint/myth - umount \/$mountpoint -} - - -copy_it () { - - if [ "$1" == "ALL" ] - then - echo "Transferring system" - unsquashfs -f -d /$mountpoint /.livesys/medium/system.sqf - else - echo "Upgrading system" - unsquashfs -e $1 -f -d /$mountpoint /.livesys/medium/system.sqf - fi - - for i in sys proc dev tmp - do - mkdir /$mountpoint/$i - - done - chmod 777 /$mountpoint/tmp - mknod /$mountpoint/dev/null c 1 3 - mknod /$mountpoint/dev/null c 1 5 - mknod /$mountpoint/dev/console c 5 1 - chmod +s /$mountpoint/usr/bin/Xorg - chmod +s /$mountpoint/usr/bin/crontab - chmod +s /$mountpoint/usr/bin/sudo - chmod +s /$mountpoint/bin/mount - -} - - -device_node () { - cd /dev - mknod hda b 3 0 - mknod hda1 b 3 1 - mknod hda2 b 3 2 - mknod hda3 b 3 3 - mknod hda4 b 3 4 - mknod hda5 b 3 5 - mknod hda6 b 3 6 - mknod hda7 b 3 7 - mknod hda8 b 3 8 - mknod sda b 8 0 - mknod sda1 b 8 1 - mknod sda2 b 8 2 - mknod sda3 b 8 3 - mknod sda4 b 8 4 - mknod sda5 b 8 5 - mknod sda6 b 8 6 - mknod sda7 b 8 7 - mknod sda8 b 8 8 - mknod sdb b 8 16 - mknod sdb1 b 8 17 - mknod sdb2 b 8 18 - mknod sdb3 b 8 19 - mknod sdb4 b 8 20 - mknod sdb5 b 8 21 - mknod sdb6 b 8 22 - mknod sdb7 b 8 23 - mknod sdb8 b 8 24 - cd - - } - - - - -function create_fstab() -{ -echo "creating fstab" -cat > /$mountpoint/etc/fstab << EOF -# <file system> <dir> <type> <options> <dump> <pass> -none /dev/pts devpts defaults 0 0 -none /dev/shm tmpfs defaults 0 0 -/dev/cdrom /media/cdrom auto ro,user,noauto,unhide 0 0 -/dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0 -UUID=ROOTUID / auto defaults 0 1 -UUID=DATAUID /myth auto defaults 0 1 -UUID=SWAPUID swap swap defaults 0 0 -EOF - - -} - - -function find_uuid() { - uuid=`blkid -s UUID /dev/$1 |cut -d= -f2|cut -d\" -f2` - echo $uuid for $1 - FOUNDUUID=$uuid - -} - - -get_grub_map() { - [ -e /tmp/dev.map ] && rm /tmp/dev.map - /sbin/grub --no-floppy --device-map /tmp/dev.map <<EOF -quit -EOF -} - -mapdev() { - partition_flag=0 - device_found=0 - devs=$(cat /tmp/dev.map | grep -v fd | sed 's/ *\t/ /' | sed ':a;$!N;$!ba;s/\n/ /g') - linuxdevice=$(echo $1 | cut -b1-8) - if [ "$(echo $1 | egrep '[0-9]$')" ]; then - # /dev/hdXY - pnum=$(echo $1 | cut -b9-) - pnum=$(($pnum-1)) - partition_flag=1 - fi - for dev in $devs - do - if [ "(" = $(echo $dev | cut -b1) ]; then - grubdevice="$dev" - else - if [ "$dev" = "$linuxdevice" ]; then - device_found=1 - break - fi - fi - done - if [ "$device_found" = "1" ]; then - if [ "$partition_flag" = "0" ]; then - echo "$grubdevice" - else - grubdevice_stringlen=${#grubdevice} - grubdevice_stringlen=$(($grubdevice_stringlen - 1)) - grubdevice=$(echo $grubdevice | cut -b1-$grubdevice_stringlen) - echo "$grubdevice,$pnum)" - fi - else - echo "Grub DEVICE NOT FOUND" - fi -} - - -dogrub() { - get_grub_map - sync - ROOTDEV=/dev/$1 - echo "ROOTDEV: $ROOTDEV" - - bootdev=$(mapdev $ROOTDEV) - echo "bootdev: $bootdev" - cp -a /$mountpoint/usr/lib/grub/i386-pc/* /$mountpoint/boot/grub/ - sync - # freeze xfs filesystems to enable grub installation on xfs filesystems - if [ -x /usr/sbin/xfs_freeze ]; then - #/usr/sbin/xfs_freeze -f /$mountpoint > /dev/null 2>&1 - echo "freezing xfs fs" - /usr/sbin/xfs_freeze -f /$mountpoint - if [ $? -eq 0 ] - then - sleep 40 - echo "unfreezing xfs" - /usr/sbin/xfs_freeze -u /$mountpoint - fi - fi - #$DESTDIR/sbin/grub-install --recheck --root-directory=$DESTDIR $bootdev >/tmp/grub.log 2>&1 - echo grub-install --recheck --root-directory=/$mountpoint $bootdev - grub-install --recheck --root-directory=/$mountpoint $bootdev - # unfreeze xfs filesystems - - - if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then - echo "Error installing GRUB. " - return 1 - fi - echo "GRUB was successfully installed." -} - -function removevg () { - LIST=`pvscan |grep $1|tr -s " " |cut -d" " -f 5` - for vg in $LIST - do - echo "Removing vg $vg" - vgremove -f -v $vg - done - - - - -} - - -case $1 in - partition_it ) - #drive ROOT DATA(ALL) SWAP(NO) - for i in `mount | grep $disk | awk ' { print $1 } '` - do - umount $i - done - swap=`cat /etc/fstab |grep $disk|grep swap|awk ' { print $1 } '` - swapoff $swap - removevg $disk - partition_it $3 $4 $5 - exit 0 - - ;; - format_it ) - device_node - - format_it $3 $4 - exit 0 - ;; - mount_it ) - mount_it - ;; - copy_it ) - copy_it $3 - - ;; - - - fstab_fix_it) - echo $@ >> /tmp/fstab.input - if [ ! -f /$mountpoint/etc/fstab ] - then - create_fstab - fi - #was 5 - if [ "$3" == "UPGRADE" ] - then - if [ ! -f /tmp/etc/KnoppMyth-version ] - then - if [ -f /tmp/etc/fstab ] - then - cp -f /tmp/etc/fstab /$mountpoint/etc/fstab - else - create_fstab - fi - else - create_fstab - fi - fi - - #search for UUID - FOUNDUUID="" - find_uuid ${2}1 - ROOTUUID=$FOUNDUUID - echo "--" - echo $ROOTUUID - echo "--" - FOUNDUUID="" - find_uuid ${2}2 - SWAPUUID=$FOUNDUUID - - FOUNDUUID="" - if [ "$4" == "" ] - then - #upgrade - find_uuid ${2}3 - elif [ "$5" == "FULL_INSTALL" ] - then - #install - find_uuid ${2}3 - else - #upgrade with non statndard myth - find_uuid $4 - fi - - DATAUUID=$FOUNDUUID - - - - sed -i -e "s/.*\/\ .*$/UUID=$ROOTUUID \/ auto defaults,noatime 0 1/g" /$mountpoint/etc/fstab - sed -i -e "s/.*\/myth\ .*$/UUID=$DATAUUID \/myth auto defaults,noatime 0 1/g" /$mountpoint/etc/fstab - sed -i -e "s/.*swap\ .*$/UUID=$SWAPUUID swap swap defaults 0/g" /$mountpoint/etc/fstab - -#if Knoppmyth upgrade then loop through old fstab picking out vg - if [ -f /tmp/etc/KnoppMyth-version ] - then - if [ -f /tmp/etc/fstab ] - then - grep -q /dev/vg /tmp/etc/fstab - if [ $? -eq 0 ] - then - grep /dev/vg /tmp/etc/fstab >> /$mountpoint/etc/fstab - grep /dev/vg /tmp/etc/fstab | awk -v mount=$mountpoint ' { print "/" mount $2 }' |xargs mkdir - grep /dev/vg /tmp/etc/fstab | awk -v mount=$mountpoint ' { print "/" mount $2 }' |xargs chown -R mythtv:users - fi - fi - fi - ;; - - grub_it ) - - #grub-install --recheck --no-floppy --root-directory=/$mountpoint "(hd0)" - #fixing grub/menu.1st - dogrub ${disk} - FOUNDUUID="" - find_uuid ${disk}1 - ROOTUUID=$FOUNDUUID - sed -i -e "s/root=.\S*/root=\/dev\/disk\/by-uuid\/$ROOTUUID/g" /$mountpoint/boot/grub/menu.lst - mkinitcpio -g /$mountpoint/boot/kernel26.img - ;; - umount_it) - umount \/$mountpoint/myth - umount \/$mountpoint - ;; - update_db_it ) - update_db_settings "$2" "$3" - ;; - - -esac - - |