#!/bin/bash #Framework, welches ein komplettes Linux System aus den Sourcen erstellt #dieses Framework wird im CVS Repository #:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt # #Lage dieser Datei im Archiv: $Source: $ # #(c) 2003 Harald Kueller, Germany #This program is free software; you can redistribute it and/or #modify ist 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. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #See the GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not write to the Free Software Foundation, #Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # #Script: #BasisScript Viitor_Setup #Sammlung von Funktionen zum Format von Volumes/Partitions # #Letzte Änderung von: $Author: $ #Datum der letzten Änderung: $Date: $ #Version der Datei: $Revision: $ # #$Log: $ # FindMountablePart() { PART="" DIALOGCFG="" NumEntrys=0 for i in `\ls /dev/{h,s}d? 2>/dev/null`; do DEVNAME=`basename $i` if [ "`cat /sys/block/$DEVNAME/device/type 2>/dev/null`" == "0" ] || \ [ "`cat /sys/block/$DEVNAME/device/media 2>/dev/null`" == "disk" ]; then if [ "`cat /sys/block/$DEVNAME/removable 2>/dev/null`" == "0" ]; then for j in `fdisk -l /dev/${DEVNAME}| \ grep "^\/dev"|\ sed -e "s/\*//"|\ awk '{ if ($5 == "83") print $1}'`; do PART=$PART" $j" done fi fi done for i in `vgdisplay|grep "VG Name"|awk '{print $3}'`; do for j in `lvdisplay $i|grep "LV Name"|awk '{print $3}'`; do PART=$PART" $j" done done for i in `cat /proc/mdstat 2>/dev/null| \ grep active | \ awk '{print $1}'| \ sed -e "s/md//"`; do PART=$PART" /dev/md/$i" done NumEntrys=0 for i in $PART; do if ! grep $i /etc/fstab >/dev/null 2>&1; then if ! grep $i /proc/mounts >/dev/null 2>&1; then (( NumEntrys = $NumEntrys + 1 )) DIALOGCFG=$DIALOGCFG" $i NoConfig off" fi fi done DIALOGCFG=$DIALOGCFG" Exit MountMenue off" (( NumEntrys = $NumEntrys + 1 )) while [ ! "$PARTITION" == "Exit" ]; do PARTITION=`$DIALOGPRG --backtitle "Viitor Setup" \ --title "ViitorLinux VolumeManager Setup" \ --stdout --radiolist \ "Select Volume to mount" 0 65 $NumEntrys \ $DIALOGCFG` if [ ! $? == "0" ]; then break; fi if [ $PARTITION != "Exit" ]; then MOUNTPOINT=`$DIALOGPRG --stdout --title "Please choose a Mounpoint for $PARTITION" --fselect / 0 0` if [ $? == "0" ]; then echo "$PARTITION $MOUNTPOINT" >>/tmp/mountlist.$$ else continue fi if $DIALOGPRG --title "mount" --clear --yesno \ "Should i Mount Partition \n$PARTITION on \n$MOUNTPOINT now?" 10 50; then if [ $INSTALLROOT ]; then MOUNTPOINT=$INSTALLROOT/$MOUNTPOINT if [ ! -d $MOUNTPOINT ]; then mkdir -p $MOUNTPOINT fi fi mount $PARTITION $MOUNTPOINT fi unset DIALOGCFG for i in $PART; do if ! grep $i /etc/fstab >/dev/null 2>&1; then if ! grep $i /proc/mounts >/dev/null 2>&1; then if grep $i /tmp/mountlist.$$ >/dev/null 2>&1; then MNTPOINT=`grep $i /tmp/mountlist.$$|awk '{print $2}'` DIALOGCFG=$DIALOGCFG" $i $MNTPOINT off" else DIALOGCFG=$DIALOGCFG" $i NoConfig off" fi fi fi done DIALOGCFG=$DIALOGCFG" Exit MountMenue off" fi done MOUNTPOINTS=`cat /tmp/mountlist.$$` rm /tmp/mountlist.$$ NumEntrys=0 echo $MOUNTPOINTS } FindFormatablePart() { PART="" REALPART="" NumEntrys=0 for i in `\ls /dev/{h,s}d? 2>/dev/null`; do DEVNAME=`basename $i` if [ "`cat /sys/block/$DEVNAME/device/type 2>/dev/null`" == "0" ] || \ [ "`cat /sys/block/$DEVNAME/device/media 2>/dev/null`" == "disk" ]; then if [ "`cat /sys/block/$DEVNAME/removable 2>/dev/null`" == "0" ]; then for j in `fdisk -l /dev/${DEVNAME}| \ grep "^\/dev"|\ sed -e "s/\*//"|\ awk '{ if ($5 == "83") print $1}'`; do PART=$PART" $j" done fi fi done for i in `vgdisplay|grep "VG Name"|awk '{print $3}'`; do for j in `lvdisplay $i|grep "LV Name"|awk '{print $3}'`; do PART=$PART" $j" done done for i in $PART; do VOLNAME=`basename $i` DIRNAME=`dirname $i` VGNAME=`basename $DIRNAME` SIZE=`fdisk -s $i` (( SIZE = $SIZE / 1024 )) SIZE=$SIZE"M" if [ -e /dev/mapper/$VGNAME-$VOLNAME ]; then if ! mount|grep /dev/mapper/$VGNAME-$VOLNAME >/dev/null 2>&1; then REALPART=$REALPART" $i $SIZE off" (( NumEntrys = $NumEntrys + 1 )) fi elif ! mount|grep $i >/dev/null 2>&1; then REALPART=$REALPART" $i $SIZE off" (( NumEntrys = $NumEntrys + 1 )) fi done for i in `cat /proc/mdstat 2>/dev/null| \ grep active| \ awk '{print $1}'|\ sed -e "s/md//"`; do if ! pvdisplay /dev/md/$i >/dev/null 2>&1; then REALPART=$REALPART" $i $SIZE off" (( NumEntrys = $NumEntrys + 1 )) fi done (( NumEntrys = $NumEntrys + 1 )) $DIALOGPRG --stdout \ --backtitle "ViitorLinux Setup" \ --title "Filesystem Creator" \ --checklist "Select Volumes/Partitions to Format" \ 0 70 $NumEntrys \ $REALPART |sed -e "s%//% /%g" } SelectFilesystemForPart() { if [ -f /tmp/format$$.tmp ]; then rm /tmp/format$$.tmp fi for i in $*; do FSYSTEM=`$DIALOGPRG --stdout \ --backtitle "ViitorLinux Setup" \ --title "Filesystem Creator" \ --radiolist "Select Filesystem for use with $i" \ 0 50 3 \ "xfs" "jornaling Filesystem from SGI" on \ "reiserfs" "jornaling DB Filesystem" off \ "ext3fs" "Extendet ext2fs with journaling" off \ "swapfs" "Use Partition as Swap Device" off` if [ ! $? = "0" ]; then return 1 fi echo "$i $FSYSTEM" >>/tmp/format$$.tmp done }