SF.net SVN: morphix: [2620] trunk/scripts-base

[email protected] Thu, 27 Mar 2008 09:46:27 -0700
Newsgroups gmane.linux.morphix.cvs
Message-ID <[email protected]>
Revision: 2620
          http://morphix.svn.sourceforge.net/morphix/?rev=2620&view=rev
Author:   alextreme
Date:     2008-03-27 09:46:19 -0700 (Thu, 27 Mar 2008)

Log Message:
-----------
 * cleaning up large parts of the base module's init scripts,
   rewriting parts for usage of udev.
 * base modules using these scripts will require python,
   add python-minimal to your isomaker template!
 * This is a work-in-progress. If you depend on a working base iso,
   save your last build and don't expect those of the next few days to work.

Modified Paths:
--------------
    trunk/scripts-base/debian/changelog
    trunk/scripts-base/etc/init.d/knoppix-autoconfig
    trunk/scripts-base/etc/init.d/load-minimodules.sh
    trunk/scripts-base/etc/init.d/morphix-start
    trunk/scripts-base/miniroot/debian/changelog
    trunk/scripts-base/miniroot/linuxrc-scripts/linuxrc
    trunk/scripts-base/usr/sbin/rebuildfstab
    trunk/scripts-base/usr/sbin/scanpartitions

Added Paths:
-----------
    trunk/scripts-base/usr/sbin/linux_devices.py
    trunk/scripts-base/usr/sbin/rebuildfstab-morphix

Modified: trunk/scripts-base/debian/changelog
===================================================================
--- trunk/scripts-base/debian/changelog	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/debian/changelog	2008-03-27 16:46:19 UTC (rev 2620)
@@ -1,3 +1,15 @@
+morphix-base-scripts (0.5-65) unstable; urgency=low
+
+  * Large cleanup of pre-udev stuff, restructuring loading of main/minimods
+
+ -- Alex de Landgraaf <[email protected]>  Thu, 27 Mar 2008 17:40:25 +0100
+
+morphix-base-scripts (0.5-64) unstable; urgency=low
+
+  * Fixing unionfs-mount commands
+
+ -- alextreme <[email protected]>  Wed, 05 Dec 2007 14:30:29 +0100
+
 morphix-base-scripts (0.5-63) unstable; urgency=low
 
   * Fix 1589476 XOrg patch for Modules, and locations.

Modified: trunk/scripts-base/etc/init.d/knoppix-autoconfig
===================================================================
--- trunk/scripts-base/etc/init.d/knoppix-autoconfig	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/etc/init.d/knoppix-autoconfig	2008-03-27 16:46:19 UTC (rev 2620)
@@ -14,8 +14,7 @@
 
 # Ignore these signals: INT, TERM, SEGV
 trap "" 2 3 11
-## FIXME this is really strange (kernel-2.6.13). At this point proc is not available, but when exit the linuxrc proc is still savailable??
-## There is also a strange message : Failed to mount /selinux/  
+
 [ -f /proc/version ] || mount -t proc proc /proc 2>/dev/null
 
 
@@ -52,10 +51,8 @@
 [ -d /sys/devices ] || mount -t sysfs /sys /sys 2>/dev/null
 eend $?
 
-#mount udev after sysfs
 if [ -x /etc/init.d/udev ];then
-  #You can add more loop device 1->N in /etc/udev/links.sh
-  ebegin "Configuring system to udev"
+  ebegin "Configuring system to use udev"
   /etc/init.d/udev start &>/dev/null
   eend $?
 fi
@@ -459,7 +456,7 @@
 [ -n "$NOSCSI" ] && HWSETUP_NOSCSI="-s"
 if checkbootparam "nohwsetup"; then
     einfo "Loading hardware profile from ${MAGENTA}/etc/modules${BLUE}.${NORMAL}"
-    /etc/init.d/module-init-tools start >/dev/null 2>/dev/null 	#replace modutils by his 2.6 version
+    /etc/init.d/module-init-tools start >/dev/null 2>/dev/null
 else
     ebegin "Autoconfiguring devices (hardware setup)"
     if [ -z "$DEBUG" ]; then
@@ -499,8 +496,6 @@
 
 if [ -x /etc/init.d/alsa-autoconfig ]; then
     DRIVERS="$SOUND_DRIVER" /etc/init.d/alsa-autoconfig
-#elif [ -x /usr/sbin/morphix-alsasound ]; then
-#    DRIVERS="$SOUND_DRIVER" /usr/sbin/morphix-alsasound
 fi
 
 # This should be in morphix-alsasound script
@@ -520,45 +515,6 @@
     done
 fi
 
-# Check for blind option or brltty
-#
-# NOTE: This won't work in Morphix
-#
-BLIND=""
-checkbootparam "blind" && BLIND="yes"
-BRLTTY="$(getbootparam brltty 2>/dev/null)"
-
-if [ -n "$BLIND" -o -n "$BRLTTY" ]; then
-    if [ -x /sbin/brltty ]; then
-# Blind option detected, start brltty now.
-	CMD=brltty
-	BRLTYPE=""
-	BRLDEV=""
-	BRLTEXT=""
-	if [ -n "$BRLTTY" ]; then
-# Extra options
-	    BRLTYPE="${BRLTTY%%,*}"
-	    R="${BRLTTY#*,}"
-	    if [ -n "$R" -a "$R" != "$BRLTTY" ]; then
-		BRLTTY="$R"
-		BRLDEV="${BRLTTY%%,*}"
-		R="${BRLTTY#*,}"
-		if [ -n "$R" -a "$R" != "$BRLTTY" ]; then
-		    BRLTTY="$R"
-		    BRLTEXT="${BRLTTY%%,*}"
-		    R="${BRLTTY#*,}"
-		fi
-	    fi
-	fi
-	[ -n "$BRLTYPE" ] && CMD="$CMD -b $BRLTYPE"
-	[ -n "$BRLDEV" ] && CMD="$CMD -d $BRLDEV"
-	[ -n "$BRLTEXT" ] && CMD="$CMD -t $BRLTEXT"
-	echo " ${BLUE}Starting braille-display manager: ${GREEN}${CMD}${BLUE}.${NORMAL}"
-	( exec $CMD & )
-	sleep 2
-    fi
-fi
-
 if test -n "$SPLASH"; then
     echo "show 20000">/proc/splash 2>/dev/null
 fi
@@ -607,7 +563,6 @@
 
 # Read in changes
 [ -f /etc/sysconfig/morphix ] && . /etc/sysconfig/morphix
-#[ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix
 
 if [ -n "$INTERACTIVE" ]
     then
@@ -624,14 +579,6 @@
     echo "show 24000">/proc/splash 2>/dev/null
 fi
 
-# Add new devices to /etc/fstab
-# maybe it's better to use CD drive information from /proc/sys/dev/cdrom/info ?
-for i in /dev/cdrom*; do
-    if [ -L $i ]; then
-	addmount "$i" "ro"
-    fi
-done
-
 NOSWAP=""
 DMA=""
 checkbootparam "noswap" && NOSWAP="yes"
@@ -673,12 +620,8 @@
 
 # Start creating /etc/fstab with HD partitions and USB SCSI devices now
 ebegin "Scanning for Harddisk partitions and creating ${YELLOW}/etc/fstab${BLUE}... "
-rebuildfstab -r -u $USERNAME >/dev/null 2>&1
+rebuildfstab-morphix $USERNAME >/dev/null 2>&1
 val=$?
-if [ -e /var/run/rebuildfstab.pid ]; then
-# Another instance of rebuildfstab, probably from hotplug, is still running, so just wait.
-    sleep 8
-fi
 eend $val
 
 if [ -n "$partitions" ]; then
@@ -696,27 +639,6 @@
 		continue
 		;;
 	esac
-# Create mountdir if not already present
-# FIXME already done by rebuildfstab  
-#	d="/mnt/${p##*/}" ; [ -d "$d" ] || mkdir -p "$d"
-	case "$f" in vfat|msdos)
-		if [ -z "$NOSWAP" ] && mount -o uid=$USERNAME,gid=users,ro -t $f $p $d 2>/dev/null; then
-		    if [ -f $d/morphix.swp ]; then
-			mount -o remount,rw $d
-			if swapon $d/morphix.swp 2>/dev/null; then
-			    einfo "${BLUE}Using Morphix swapfile ${MAGENTA}$d/morphix.swp${BLUE}.${NORMAL}"
-			    mount -o remount,ro $d 2>/dev/null
-			    fnew="$d/morphix.swp swap swap defaults 0 0"
-			    stringinfile "$fnew" "/etc/fstab" || echo "$fnew" >> /etc/fstab
-			else
-			    umount $d
-			fi
-		    else
-			umount $d
-		    fi
-		fi
-		;;
-	esac
     done </etc/fstab
 fi
 
@@ -792,6 +714,7 @@
     fi
     [ -n "$FOUND_CONFIG" ] || echo " ${BLUE}Not present.${NORMAL}"
 fi
+
 if test -n "$SPLASH"; then
     echo "show 36000">/proc/splash
 

Modified: trunk/scripts-base/etc/init.d/load-minimodules.sh
===================================================================
--- trunk/scripts-base/etc/init.d/load-minimodules.sh	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/etc/init.d/load-minimodules.sh	2008-03-27 16:46:19 UTC (rev 2620)
@@ -4,43 +4,16 @@
 #
 # Feel free to change this file to adapt it to your main-module
 # 
-# copyleft 2003-2005, Alex de Landgraaf <alex at delandgraaf dot com>
+# Copyleft 2003-2005, Alex de Landgraaf <alex at delandgraaf dot com>
 # GPL, (www.gnu.org for details)
 #
 # $Id$
-#
-# All linking/binding, copying /etc and /var etc is done
-# in /etc/init.d/morphix-start on Morphix Base
-# Could also be done here, but would be unneeded complexity
-# (and modules should be loaded in a uniform matter)
-# 
-# MiniModules are loaded here, still a bit dirty for now,
-# as we need a kernelmodule for each minimodule that we want to load
-# Reread boot command line; echo last parameter's argument or return false.
 
 . /etc/morphix.d/color.sh
 . /etc/morphix.d/functions.sh
 
 CMDLINE="$(cat /proc/cmdline)"
 
-trymount(){
-# Apparently, mount-aes DOES autodetect AES loopback files.
-    [ -b "$1" ] && { mount -t auto -o ro "$1" "$2" 2>/dev/null; RC="$?"; }
-# We need to mount crypto-loop files with initial rw support
-    [ -f "$1" ] && { mount -t auto -o loop,rw "$1" "$2" 2>/dev/null; RC="$?"; }
-    [ "$RC" = "0" ] && return 0
-    echo ""
-    einfo "Filesystem not autodetected, trying to mount $1 with AES256 encryption"
-    a="y"
-    while [ "$a" != "n" -a "$a" != "N" ]; do
-# We need to mount crypto-loop files with initial rw support
-	mount -t auto -o loop,rw,encryption=AES256 "$1" "$2" && return 0
-	echo -n "${RED}Mount failed, retry? [Y/n] ${NORMAL}"
-	read a
-    done
-    return 1
-}
-
 # Mounts a minimod to the directory appointed to the module
 # first argument is the file seen from the mainmodule/chroot
 # second argument is the number of the module
@@ -60,47 +33,12 @@
 	mount_module $file /mnt/main/mnt/mini/mod$count $count >/dev/null 2>&1
     fi
    
-    MainTag=$(head -n 1 /mnt/main/morphix/main_module)
-    MiniTag=$(head -n 1 /mnt/main/mnt/mini/mod$count/morphix/main_module 2>/dev/null)
-    if [ -n "$MiniTag" -a -n "$MainTag" ]; then
-	if [ "$MainTag" != "$MiniTag" ] && [[ $MiniTag != ALL* ]]; then
-	    ewarn "${RED}MiniModule $file doesn't have the same tag as MainModule${NORMAL}"
-	    einfo "${GREEN} Mini: $MiniTag"
-	    einfo " Main: $MainTag${NORMAL}"
-	    chroot /mnt/main umount /mnt/mini/mod$count
-	    chroot /mnt/main rm /dev/cloop$count
-	    chroot /mnt/main rmdir /mnt/mini/mod$count
-	    return 1
-	fi
-    fi
-    MiniTagBootOption=$(head -n 1 /mnt/main/mnt/mini/mod$count/morphix/boot_option 2>/dev/null)
-    if [ -n "$MiniTagBootOption" ]; then
-	BOOTOPTIONOK=""
-	case "${CMDLINE}" in *\ ${MiniTagBootOption}*) BOOTOPTIONOK="yes"; ;; esac
-	if [ "${MiniTagBootOption}" != "ALL" ]; then
-	    if [ -z "${BOOTOPTIONOK}" ]; then
-                einfo "${GREEN} Boot Option ${RED}${MiniTagBootOption}${NORMAL} not found. Skipping MiniModule.${NORMAL}"
-	        einfo "${GREEN} Boot Options found ${RED}${CMDLINE}${NORMAL}"
-		einfo "${GREEN} Mini: $file ${NORMAL}"
-	        chroot /mnt/main umount /mnt/mini/mod$count
-		chroot /mnt/main rm /dev/cloop$count
-    	        chroot /mnt/main rm /mnt/mini/mod$count
-	        return 1
-            fi
-        fi
-    fi
-    
-    
     echo "$count" > /mnt/mini/num_loaded
 
-    # Unionfs overlaying (only if unionctl exists and the root dir in the minimodule exists
+    # Unionfs overlaying
     # Add the /root dir to be the unionfs branch after the first component (which should be 0 and rw...)
-    if [ -x /usr/sbin/unionctl -o -x /usr/bin/unionctl ];then
-	if [ -d /mnt/main/mnt/mini/mod$count/root ]; then
-	    unionctl /mnt/main --add --after 0 --mode ro /mnt/main/mnt/mini/mod$count/root
-	fi
-    else
-	einfo "No unionctl found, not applying unionfs minimodule overlaying";
+    if [ -d /mnt/main/mnt/mini/mod$count/root ]; then
+	mount -t unionfs -o remount,add=:/mnt/main/mnt/mini/mod$count/root=ro none /mnt/main
     fi
 
     if [ -e /mnt/main/mnt/mini/mod$count/morphix/loadmod.sh ]; then
@@ -121,56 +59,16 @@
 MiniModulesCount=0
 einfo "Starting MiniModule bootscript"
 
-# copied from myhome, you can specify a device to load minimods from 
-#using the mini= bootparameter. Modules would be in the root of the directory
+# checks for all minimodules on all mounted partitions
 
-MYMINIDIR="$(getbootparam mini)"
-if [ -n "$MYINIDIR" ]; then
-    case "$MYMINIDIR" in
-	/dev/*)
-	    MYMINIDEVICE="${MYMINIDIR##/dev/}"
-	    MYMINIDEVICE="/dev/${MYMINIDEVICE%%/*}"
-	    MYMINIMOUNTPOINT="/mnt/minimod}"
-	    MYMINIDIR="/mnt/${MYMINIDIR##/dev/}"
-	    ;;
-	/mnt/*)
-	    MYMINIDEVICE="${MYMINIDIR##/mnt/}"
-	    MYMINIDEVICE="/dev/${MYMINIDEVICE%%/*}"
-	    MYMINIMOUNTPOINT="/mnt/minimod}"
-	    MYMINIDIR="$MYMINIDIR"
-	    ;;
-	*)
-	    ewarn "Invalid ${CYAN}mini=${NORMAL} option '$MYMINIDIR' specified (must start with /dev/ or /mnt/)."
-	    ewarn "Option ignored."
-	    ;;
-    esac
-    if trymount "$MYMINIDEVICE" "$MYMINIMOUNTPOINT"; then
-	MntMiniModules="$(ls /mnt/minimod/*.mod 2> /dev/null)"
-	MntMiniModulesCount="$(ls /mnt/minimod/*.mod 2> /dev/null | wc -l)"
-	for file in $MntMiniModules 
-	  do
-	  load_mini_module "$file" $MiniModuleCount
-	  ((MiniModuleCount += 1))
-	done
-	einfo "Device $MYMINIDEVICE will be used for the /mnt/minimod directory..."
-    fi
-fi
-
-# checks for all minimodules on the usb device,
-# unless nousb or usbboot is being used (the latter would mean that the
-# minimodules are loaded from /cdrom instead...)
-
 echo
-USBSTORAGE="$(getbootparam nousb)"
-USBBOOTING="$(getbootparam usbboot)"
-if [ -z "$USBSTORAGE" -a -z "$USBBOOTING" ]; then
-    einfo "Checking for MiniModules on USB device"
+NOUSB="$(getbootparam nousb)"
+if [ -z "$NOUSB" ]; then
+    einfo "Checking for MiniModules on connected devices"
     modprobe usb-storage >/dev/null 2>&1
-    mkdir /mnt/main/mnt/usb  >/dev/null 2>&1
-    chroot /mnt/main mount /dev/sda1 /mnt/usb >/dev/null 2>&1
-    UsbMiniModules="$(ls /mnt/usb/minimod/*.mod 2> /dev/null)"
-    UsbMiniModulesCount="$(ls /mnt/usb/minimod/*.mod 2> /dev/null | wc -l)"
-    for file in $UsbMiniModules 
+    
+    MiniModules="$(ls /media/*/minimod/*.mod 2> /dev/null)"
+    for file in $MiniModules 
       do
       load_mini_module "$file" $MiniModuleCount
       ((MiniModuleCount += 1))
@@ -182,7 +80,6 @@
 echo 
 einfo "Checking for MiniModules on CDROM"
 CdromMiniModules="$(ls /cdrom/minimod/*.mod 2> /dev/null )"
-CdromMiniModulesCount="$(ls /cdrom/minimod/*.mod 2> /dev/null | wc -l  )"
 for file in $CdromMiniModules 
   do
   load_mini_module "$file" $MiniModuleCount

Modified: trunk/scripts-base/etc/init.d/morphix-start
===================================================================
--- trunk/scripts-base/etc/init.d/morphix-start	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/etc/init.d/morphix-start	2008-03-27 16:46:19 UTC (rev 2620)
@@ -162,8 +162,6 @@
 
     DEBS="$(chroot /mnt/main ls -1 $1/deb/*.deb 2>/dev/null | wc -l )"
     if [ $DEBS -gt 0 ]; then
-# done anyways
-#	chroot /mnt/main touch /var/lib/dpkg/status
 	chroot /mnt/main dpkg -i --force-all $1/deb/*.deb
     fi
     
@@ -224,16 +222,9 @@
 # Work out mount options so we can support minimodule overlays.
 mount_options () {
 
-    # which overlayfs?
-    TRANS="$(getbootparam translucency)"
-    UNIONFS="$(getbootparam unionfs)"
-    if [ -n "$TRANS" ]; then
-	TRANSLUCENCY="on"
-	export TRANSLUCENCY
-    else
-	UNIONFS="on"
-	export UNIONFS
-    fi # End switchboard
+    # Currently we only support unionfs
+    UNIONFS="on"
+    export UNIONFS
 
     # This shouldn't be necessary,
     # as --add overlaying is in load-minimodules.sh
@@ -267,31 +258,9 @@
 
     DIR2=/tmp/overlay
 
-    
-    ###
-    #
-    # Overlay FS switchboard
-    #
-    # Bootoption: Use either unionfs or cowloop
-    # to force the overlay fs. Default currently is unionfs
-    #
-    ###
+    UNIONFS="on"
+    export UNIONFS
 
-
-    UNIONFS="$(getbootparam unionfs)"
-    COWLOOP="$(getbootparam cowloop)"
-    if [ -n "$UNIONFS" ]; then
-	UNIONFS="on"
-	export UNIONFS
-    elif [ -n "$COWLOOP" ]; then
-	COWLOOP="on"
-	export COWLOOP
-	mknod /dev/cowloop b 241 0
-    else
-	UNIONFS="on"
-	export UNIONFS
-    fi # End switchboard
-
 ###
 #    
 # Load Module
@@ -308,19 +277,12 @@
 	exit
     fi
 
-    if [ -n "$UNIONFS" ]; then
-	mkdir /mnt/main_ro >/dev/null 2>&1
-    fi
+    mkdir /mnt/main_ro >/dev/null 2>&1
     mkdir /mnt/mainmod >/dev/null 2>&1
     mkdir /mnt/minimod >/dev/null 2>&1
     mkdir /mnt/mini >/dev/null 2>&1
 
-    if [ -n "$UNIONFS" ]; then
-	mount_module $1 /mnt/main_ro 1
-    else
-	mount_module $1 /mnt/main 1
-    fi
-
+    mount_module $1 /mnt/main_ro 1
     eend $?
 
     # End Load Module
@@ -351,28 +313,15 @@
 	mkdir -p $DIR2/dev >/dev/null 2>&1
 	mkdir -p $DIR2/modules >/dev/null 2>&1
 
-        if [ -x /sbin/unionctl -o -x /usr/bin/unionctl ];then
-	  mount -t unionfs -o dirs=/mnt/main${UNIONFS_MOUNT_OPT} none /mnt/main
-
-# debug is no longer a unionfs-option since unionfs-2.1.x.
-# Old mount-line:
-#	  mount -t unionfs -o dirs=/mnt/main${UNIONFS_MOUNT_OPT},debug=$DEBUGOVERLAY none /mnt/main
-#
-	  unionctl /mnt/main --add --mode ro /mnt/main_ro
-	  unionctl /mnt/main --add --mode rw $DIR2/root
-        else
-	  mount -t unionfs -o dirs=$DIR2/root=rw:/mnt/main_ro=ro${UNIONFS_MOUNT_OPT} none /mnt/main
+	mount -t unionfs -o dirs=$DIR2/root=rw:/mnt/main_ro=ro${UNIONFS_MOUNT_OPT} none /mnt/main
         fi
 	eend $?
 
 	mount -t unionfs -o dirs=$DIR2/modules=rw:/MorphixCD/lib/modules=ro none /mnt/main/lib/modules
+    else
+        eerror "Unionfs is currently the only supported overlay filesystem."
+    fi
 
-    elif [ -n "$COWLOOP" ]; then
-	ebegin "Overlaying using cowloop"
-	mount --bind /MorphixCD/lib/modules /mnt/main/lib/modules
-	eend $?
-    fi # End Setup Module
-
 ###
 #
 # Birect binds from Base system (mounting RWfs after overlaying )
@@ -392,69 +341,12 @@
     else
 	  if [ -n "$UNIONFS" ]; then
 	    mount -t unionfs -o dirs=$DIR2/dev=rw:/MorphixCD/dev=ro none /mnt/main/dev 2>&1
-	  else
-	    mount --bind /MorphixCD/dev /mnt/main/dev
 	  fi
       cp /usr/sbin/alsa_snddevices /mnt/main/usr/sbin/alsa_snddevices >/dev/null 2>&1
       chroot /mnt/main /usr/sbin/alsa_snddevices >/dev/null 2>&1
     fi
 
 
-if test -n "$SPLASH"; then
-    if [ -e /proc/splash ]; then
-	echo "show 52000">/proc/splash 2>/dev/null
-    fi
-fi
-
-###
-#
-# home dir section
-# Check for persistent homedir option and eventually mount /home from there,
-# or use a loopback file.
-#
-# Bootoption: home=/dev/* | home=/mnt/* | home=scan | home=create
-#
-###
-
-    HOMEDIR="$(getbootparam home)"
-    MYHOMEDEVICE=""
-    MYHOMEMOUNTPOINT=""
-    MYHOMEDIR=""
-    if [ -n "$HOMEDIR" ]; then
-	export HOMEDIR
-	case "$HOMEDIR" in
-	    /dev/*)
-		MYHOMEDEVICE="${HOMEDIR##/dev/}"
-		MYHOMEDEVICE="/dev/${MYHOMEDEVICE%%/*}"
-		MYHOMEMOUNTPOINT="/mnt/${MYHOMEDEVICE##/dev/}"
-		MYHOMEDIR="/mnt/${HOMEDIR##/dev/}"
-		;;
-	    /mnt/*)
-		MYHOMEDEVICE="${HOMEDIR##/mnt/}"
-		MYHOMEDEVICE="/dev/${MYHOMEDEVICE%%/*}"
-		MYHOMEMOUNTPOINT="/mnt/${MYHOMEDEVICE##/dev/}"
-		MYHOMEDIR="$HOMEDIR"
-		;;
-	    [Ss][Cc][Aa][Nn])
-MYHOMEDIR="$(findfile morphix.img)"
-MYHOMEDEVICE="${MYHOMEDIR##/mnt/}"
-MYHOMEDEVICE="/dev/${MYHOMEDEVICE%%/*}"
-MYHOMEMOUNTPOINT="/mnt/${MYHOMEDEVICE##/dev/}"
-;;
-[Cc][Rr][Ee][Aa][Tt][Ee])
-MYHOMEDIR="$(createfile morphix.img)"
-MYHOMEDEVICE="${MYHOMEDIR##/mnt/}"
-MYHOMEDEVICE="/dev/${MYHOMEDEVICE%%/*}"
-MYHOMEMOUNTPOINT="/mnt/${MYHOMEDEVICE##/dev/}"
-einfo "Create home file in $MYHOMEDIR"
-;;
-*)
-eerror "Invalid ${CYAN}home=${RED} option '$HOMEDIR' specified (must start with /dev/ or /mnt/ or 'scan').${NORMAL}"
-einfo "Option ignored."
-;;
-esac
-fi
-
 # Increment splash's bar, show fifth slide
 
 if test -n "$SPLASH"; then
@@ -466,94 +358,20 @@
     fi
 fi
 
-###
-#
-# Checking for persistant /home on local hdd subdirectory
-# will be merged with the main /home function
-#
-# Bootoption: fromdirectory=dirname This bootoption is set 
-#             by the windows installer
-#
-###
-
-OPT=""
-LOOPN=""
-BINDSWAP=""
-BINDHOME=""
-HD_DIRECTORY="$(getbootparam fromdirectory)"
-MOUNT_IMAGE="localrw"
-if test -n "$HD_DIRECTORY";then
-    /bin/mount -o remount,rw /$MOUNT_IMAGE
-    LOOPN=`grep -o -e "loop[0-9]*" /proc/mounts |grep -o -e "[0-9]"`
-    BINDHOME=`ls -1r /$MOUNT_IMAGE/$HD_DIRECTORY/*.home 2>/dev/null|head -n1`
-    BINDSWAP=`ls -1r /$MOUNT_IMAGE/$HD_DIRECTORY/*.swap 2>/dev/null|head -n1`
-
-    OPT="-o rw"
-#Check for swap!
-    if [ -n "$BINDSWAP" ];then
-          #must be avoid
-	if ! swapon "$BINDSWAP" 2>/dev/null;then
-            einfo "Formating swap device"
-            mkswap "$BINDSWAP" 2>/dev/null
-            swapon "$BINDSWAP"
-	fi
-	[ "$?" != "0" ] && einfo "Using swap file : ${YELLOW}$BINDSWAP ${NORMAL}"
-    fi
-fi
-
-if test -n "$BINDHOME" ; then
-    ebegin "Using home file : ${YELLOW}$BINDHOME ${NORMAL}"
-    echo -n "${YELLOW}"
-    /sbin/e2fsck -yf "$BINDHOME"  2>/dev/null
-    echo "${NORMAL}"
-    rm /home
-    mkdir /home
-    if ! /bin/mount -o loop,rw "$BINDHOME" /home 1>/dev/null;then
-        rmdir /home
-        ln -s /ramdisk/home /
-        BINDHOME=""
-	eend 1 
-	eerror "ERROR on using /home with $BINDHOME"
-    else
-        [ -d /home/$USERNAME ] && MYHOMEDIR="$BINDHOME"
-	eend 0
-    fi
-    mkdir /home/root
-fi
-
-####
-#
-# very important stuff!!
-# modify the /etc/rc0.d/ to avoid the local HDD busy
-#
-# Shouldn't this be $BINDHOME, not the bindhome boot option? Olivier?
-#
-####
-
-if checkbootparam "bindhome" ;then
-    cp /etc/init.d/morphix-umount /mnt/main/etc/rc0.d/K39morphix-umount
-fi
-
 # always bind home dir, if a home-image is found mount it over the old one
 
 mount --bind /home /mnt/main/home
-
 mount --bind /home/root /mnt/main/root
 
-# /home dir's, check permissions...
-# 
-
 # Mount all harddisk partitions read-only (backgrounded)
+# Updated for udev
 
-for i in /mnt/main/mnt/[sh]d[a-z][1-9] /mnt/[sh]d[a-z][1-9]?*; do
+for i in /mnt/main/media/[sh]d[a-z][1-9]; do
     if [ -d "$i" ]; then
-	chroot /mnt/main mount -r "$i" &
+	mount -r "$i" &
     fi
 done
 
-# /dev files, should be a better way than this
-#   as we are trying to be able to be independant of Base...
-
 mkdir /mnt/main/MorphixCD 2> /dev/null
 mount --bind -o ro /MorphixCD /mnt/main/MorphixCD
 
@@ -565,14 +383,6 @@
     fi
 fi
 
-# Copy over the hwsetup-detected symlinks 
-
-cp -a /dev/cdrom* /mnt/main/dev/ 2> /dev/null
-cp -a /dev/modem* /mnt/main/dev/ 2> /dev/null
-cp -a /dev/mouse* /mnt/main/dev/ 2> /dev/null
-cp -a /dev/scanner* /mnt/main/dev/ 2> /dev/null
-cp -a /dev/systty /mnt/main/dev/systty 2> /dev/null
-
 mkdir /mnt/main/etc/X11 2> /dev/null
 mkdir /mnt/main/etc/network 2> /dev/null
 mkdir /mnt/main/etc/sysconfig 2> /dev/null
@@ -581,24 +391,10 @@
 mkdir /mnt/main/floppy >/dev/null 2>&1
 
 mount --bind /mnt /mnt/main/mnt
-if [ -n "$BINDHOME" -a -n "$MOUNT_IMAGE" ];then
-  mount --bind -o ro /$MOUNT_IMAGE /mnt/main/cdrom
-else
-  mount --bind -o ro /cdrom /mnt/main/cdrom
-fi
+mount --bind -o ro /cdrom /mnt/main/cdrom
+
 chroot /mnt/main mount -t sysfs /sys /sys > /dev/null 2>&1
 
-# also bind the usb device/dir, fstab should already be set up
-if [ -z $USBSTORAGE ]; then
-    if [ -n $UsbMainModuleLoaded ]; then
-	mount --bind /mnt/usb /mnt/main/usb >/dev/null 2>&1 #necessary?
-    else
-	umount /mnt/usb >/dev/null 2>&1
-	mkdir /mnt/main/mnt/usb >/dev/null 2>&1
-	chroot /mnt/main mount /mnt/usb >/dev/null 2>&1
-    fi
-fi
-
 # lots of stuff, might have to check which are _really_ necessary
 # but for now it should work reasonably well...
 
@@ -680,10 +476,8 @@
 fi
 
 # Read default keyboard from config file.
-# There seems to be no reliable autoprobe possible.
-# These are started in the background for the same reason as above
+
 [ -f /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
-# Set default keyboard before interactive setup
 [ -n "$KEYTABLE" ] && chroot /mnt/main loadkeys -q $KEYTABLE &
 
 # Add configuration file of keymap distribution for the after of the
@@ -711,29 +505,10 @@
     fi
 fi
 
-####
-#
-# Only create a new home directory and set up the user
-# if no home directory exists. If it does exist, only
-# create the user
-#
-# Bootoption: home=create OR NOT home=
-#
-###
+chroot /mnt/main useradd -s /bin/bash $USERNAME
+chroot /mnt/main chown -R $USERNAME.users /home/$USERNAME
 
-HOMEDIR="$(getbootparam home)"
-if test -z "$MYHOMEDIR" -o "$HOMEDIR" = "create" ;then
-    rm -rf /mnt/main/home/$USERNAME
-# add the $USERNAME user, with a default homedir in /home/$USERNAME
-# files are copied from /etc/skel in the main module
-    chroot /mnt/main useradd -m $USERNAME -s /bin/bash
-else
-    chroot /mnt/main useradd -s /bin/bash $USERNAME
-    chroot /mnt/main chown -R $USERNAME.users /home/$USERNAME
-fi
-
 # make sure our users will have the locale exported by default
-
 echo 'for i in `cat /etc/environment`; do export $i; done' >> /mnt/main/home/$USERNAME/.bashrc && chroot /mnt/main chown $USERNAME /home/$USERNAME/.bashrc &
 echo 'for i in `cat /etc/environment`; do export $i; done' >> /mnt/main/home/$USERNAME/.bash_profile && chroot /mnt/main chown $USERNAME /home/$USERNAME/.bash_profile &
 
@@ -753,73 +528,14 @@
 # save the persistant configuration
 
 echo "HOMEDIR='$MYHOMEDIR'">> /etc/sysconfig/morphix
-
-if [ -n "$MYHOMEDIR" -a -z "$BINDHOME" ]; then
-    if trymount "$MYHOMEDEVICE" "$MYHOMEMOUNTPOINT"; then
-	[ -f "$MYHOMEMOUNTPOINT/morphix.img" ] && MYHOMEDIR="$MYHOMEMOUNTPOINT/morphix.img"
-	while read device mountpoint fs relax; do
-	    case "$mountpoint" in *$MYHOMEMOUNTPOINT*)
-		    case "$fs" in *[Nn][Tt][Ff][Ss]*)
-		    umount "$MYHOMEMOUNTPOINT"; eerror "ERROR: WON'T MOUNT NTFS FILESYSTEM ON $MYHOMEDEVICE READ/WRITE!"
-		    break
-		    ;;
-			*[Ff][Aa][Tt]*)
-# Note: This currently won't work with encrypted partitions
-			umount "$MYHOMEMOUNTPOINT"; mount -t vfat -o rw,uid=$USERNAME,gid=users,umask=002 "$MYHOMEDEVICE" "$MYHOMEMOUNTPOINT"
-			if [ ! -f "$MYHOMEDIR" ]; then
-			    ewarn "WARNING: FAT32 is not a good filesystem option for /home/$USERNAME (missing socket/symlink support)."
-			    ewarn "WARNING: Better use an ext2 loopback file on this device, and boot with home=$MYHOMEDEVICE/morphix.img."
-			fi
-			;;
-			esac
-			if mount -o remount,rw "$MYHOMEMOUNTPOINT"; then
-			    ebegin "Mounting ${YELLOW}$MYHOMEDIR${NORMAL} as ${YELLOW}/home/$USERNAME${NORMAL}... "
-			    if [ -f "$MYHOMEDIR" ]; then
-# It's a loopback file, mount it over the /home/$USERNAME directory
-				mkdir /home/$USERNAME &>/dev/null
-
-				trymount "$MYHOMEDIR" /home/$USERNAME
-				RC="$?"
-				[ "$RC" = "0" ] && ERROR="$(mount -o remount,rw,sync /home/$USERNAME 2>&1)"
-				RC="$?"
-			    else
-# Do a --bind mount
-				ERROR="$(mount --bind "$MYHOMEDIR" /home/$USERNAME 2>&1)"
-				RC="$?"
-			    fi
-			    mount --bind /home/$USERNAME /mnt/main/home/$USERNAME
-			    [ "$RC" = "0" ] && einfo "/home/$USERNAME mounted OK." || { eerror "FAILED."; einfo "$ERROR"; }
-			fi
-			eend $?
-			break
-			;;
-			esac
-			done <<EOT
-$(cat /proc/mounts)
-EOT
-			fi
-fi
-
-
 if test -n "$SPLASH"; then
     if [ -e /proc/splash ]; then
 	echo "show 64000">/proc/splash 2>/dev/null
     fi
 fi
 
-# Bedankt Luuk!
-# Permissions fixes
-chmod 0777 /dev/zero
 chmod 0777 /mnt/main/var/tmp
 
-# Small bugfix for /dev/tty0 problem
-if [ ! -x /etc/init.d/udev ];then
-  rm /dev/tty0
-  mknod /dev/tty0 c 4 0
-  chmod 660 /dev/tty0
-  chgrp tty /dev/tty0
-fi
-
 [ -n "$NEWXMODULE" ] && { XMODULE="$NEWXMODULE" ; echo "XMODULE='$XMODULE'" >> /etc/sysconfig/morphix ; echo "XMODULE='$XMODULE'" >> /etc/sysconfig/xserver; }
 
 ###
@@ -843,18 +559,6 @@
     fi
 fi
 
-# Start hotplug manager for PCI/USB/Firewire/Cardbus in mainmodule
-
-#if [ -n "$HOTPLUG" -a -x /mnt/main/sbin/hotplug ]; then
-#    echo " ${GREEN}Enabling hotplug manager.${NORMAL}"
-#    echo "/sbin/hotplug" > /proc/sys/kernel/hotplug
-#    chroot /mnt/main /etc/init.d/hotplug start >/dev/null 2>&1
-#fi
-
-#if [ ! -x /mnt/main/sbin/hotplug ]; then
-#    echo "${YELLOW} Couldn't find /sbin/hotplug in mainmodule, you probably want to add hotplug to it${NORMAL}"
-#fi
-
 ###
 #
 # Fat-Client-Version: DHCP Broadcast for IP address
@@ -1073,52 +777,43 @@
 USBBOOTING="$(getbootparam usbboot)"
 if [ -z "$USBSTORAGE" -a -z "$USBBOOTING" ]; then
     modprobe usb-storage  >/dev/null 2>&1
-    mkdir /mnt/sda1 >/dev/null 2>&1
-    ln -s /mnt/sda1 /mnt/usb >/dev/null 2>&1
-    echo "/dev/sda1 /mnt/sda1 auto noauto,users,exec,umask=000,uid=$USERNAME 0 0" >> /etc/fstab
-    mount /mnt/sda1 >/dev/null 2>&1
 fi
 
 #
-# Check USB device for mainmodules
+# Check devices for mainmodule
 #
 
 if [ -z "$USBSTORAGE" ]; then
-    if [ -d /mnt/usb/mainmod ]; then
-	UsbMainModules="$(ls -d1 /mnt/usb/mainmod/*.mod 2> /dev/null)"
-	UsbMainModulesCount="$(ls -d1 /mnt/usb/mainmod/*.mod 2> /dev/null | wc -l)"
-	if [ $UsbMainModulesCount = 0 ]; then
-	    einfo "No MainModules found on usb drive"
-	fi
-	if [ $UsbMainModulesCount = 1 ]; then
-	    einfo "Loading MainModule from usb drive"
-	    UsbMainModuleLoaded="$UsbMainModules"
-	    load_module "$UsbMainModules"
-	elif [ $UsbMainModulesCount > 1 ]; then
+    MainModules="$(ls -d1 /media/*/mainmod/*.mod 2> /dev/null)"
+    MainModulesCount="$(ls -d1 /media/*/mainmod/*.mod 2> /dev/null | wc -l)"
+    if [ $MainModulesCount = 0 ]; then
+	einfo "No MainModules found on connected devices"
+    fi
+    if [ $MainModulesCount = 1 ]; then
+	einfo "Loading MainModule from connected device"
+	MainModuleLoaded="$MainModules"
+	load_module "$MainModules"
+    elif [ $MainModulesCount > 1 ]; then
 	    echo
-	    einfo "More than one MainModule found on usb drive"
+	    einfo "More than one MainModule found on devices"
 	    einfo "List of modules:"
 	    einfo "${WHITE} $UsbMainModules ${NORMAL}" 
 	    echo
 	    PS3='Please enter the desired MainModule: '
 	    
-	    select UsbMainMod in $UsbMainModules
+	    select MainMod in $MainModules
 	    do
 	    echo
-	    einfo "Loading $UsbMainMod"
+	    einfo "Loading $MainMod"
 	    echo
-	    UsbMainModuleLoaded="$UsbMainMod"
-	    load_module "$UsbMainMod"
+	    MainModuleLoaded="$MainMod"
+	    load_module "$MainMod"
 	    break
 	    done
 	fi
     fi
 fi
 
-if [ -z "$USBSTORAGE" -a -z "$USBBOOTING" ]; then
-    umount /mnt/sda1 >/dev/null 2>&1
-fi
-
 ###
 #
 # Find MainModules from /cdrom, select if > 1

Modified: trunk/scripts-base/miniroot/debian/changelog
===================================================================
--- trunk/scripts-base/miniroot/debian/changelog	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/miniroot/debian/changelog	2008-03-27 16:46:19 UTC (rev 2620)
@@ -1,3 +1,9 @@
+miniroot-morphix (0.1-16) unstable; urgency=low
+
+  * minor cleanups
+
+ -- Alex de Landgraaf <[email protected]>  Thu, 27 Mar 2008 17:41:07 +0100
+
 miniroot-morphix (0.1-15) unstable; urgency=low
 
   * Number of minor USB drive fixes (By Markus Mandalka)

Modified: trunk/scripts-base/miniroot/linuxrc-scripts/linuxrc
===================================================================
--- trunk/scripts-base/miniroot/linuxrc-scripts/linuxrc	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/miniroot/linuxrc-scripts/linuxrc	2008-03-27 16:46:19 UTC (rev 2620)
@@ -621,27 +621,18 @@
     mkdir -p /var/run /var/backups /var/local \
         /var/tmp /var/lib /var/state/misc \
 	/mnt/cdrom /mnt/floppy /mnt/hd /mnt/test \
-	/home/root /etc/sysconfig /etc/X11
-#       /home/morph
-#	/var/nis /var/preserve 
-#	/var/spool/cups/tmp \
-#    chown morph.morph /home/morph
+	/home/root /etc/sysconfig /etc/X11 /media
+
 # Create empty utmp and wtmp
     :> /var/run/utmp
     :> /var/run/wtmp
 
     cp -a /MorphixCD/var/local /MorphixCD/var/log \
     /var/ >/dev/null
-#	/MorphixCD/var/spool 
-#    cp -a /MorphixCD/var/lib/nfs /MorphixCD/var/lib/xkb /MorphixCD/var/lib/isdn \
-#	/MorphixCD/var/lib/pcmcia /var/lib/ 2>/dev/null
-# Problematic directories in /var/lib (lots and lots of inodes)
-#    ln -s 
-#/MorphixCD/var/lib/dpkg /MorphixCD/var/lib/apt \
-#	/MorphixCD/var/lib/scrollkeeper \
-#	ln -s /var/lib/ 2>/dev/null
+
 # Debian-apt
 #    ln -s /MorphixCD/var/cache/apt /var/cache/ 2>/dev/null
+
     rm /etc/resolv.conf 2>/dev/null
     ln -s /MorphixCD/etc/skel /etc/dhcpc/resolv.conf \
 	/etc/ >/dev/null
@@ -652,8 +643,6 @@
     cp -a /MorphixCD/dev/* /ramdisk/dev/
     /bin/mount --bind /ramdisk/dev /dev
 
-# Index files can be HUGE, so better replace cache/man tree by links later
-# cp -a /MorphixCD/var/cache/man /var/cache/ 2>/dev/null
 # Create links from CDROM for UNWRITABLE (remaining) files
     cp -aus /MorphixCD/var/* /var/ >/dev/null
 
@@ -661,24 +650,12 @@
 
     cp -a /MorphixCD/etc/* /ramdisk/etc/
     cp -a /etc/fstab /ramdisk/etc/ 2>/dev/null
-#    cp -a /etc/mtab /ramdisk/etc/ 2>/dev/null
     /bin/mount --bind /ramdisk/etc /etc
 
-# Make SURE that these are files, not links!
-#    rm -rf /etc/passwd /etc/shadow /etc/group \
-#	/etc/ppp /etc/isdn /etc/ssh /etc/ioctl.save \
-#	/etc/inittab /etc/network /etc/sudoers \
-#	/etc/init /etc/localtime /etc/dhcpc /etc/pnm2ppa.conf >/dev/null
-
-#    cp -a /MorphixCD/etc/passwd /MorphixCD/etc/shadow /MorphixCD/etc/group \
-#	/MorphixCD/etc/ppp /MorphixCD/etc/isdn /MorphixCD/etc/ssh \
-#	/MorphixCD/etc/inittab /MorphixCD/etc/network /MorphixCD/etc/sudoers \
-#	/MorphixCD/sbin/init /MorphixCD/etc/dhcpc /etc/ >/dev/null
 # Extremely important, init crashes on shutdown if this is only a link
     :> /etc/ioctl.save
     :> /etc/pnm2ppa.conf
-# Diet libc bug workaround
-#    cp -f /MorphixCD/etc/localtime /etc/localtime
+
     echo "${BLUE}Done.${NORMAL}"
 
 # Now tell kernel where the real modprobe lives

Added: trunk/scripts-base/usr/sbin/linux_devices.py
===================================================================
--- trunk/scripts-base/usr/sbin/linux_devices.py	                        (rev 0)
+++ trunk/scripts-base/usr/sbin/linux_devices.py	2008-03-27 16:46:19 UTC (rev 2620)
@@ -0,0 +1,45 @@
+import os
+
+def get_device_partitions(prefix="usb-"):
+    """
+    Assume: udev is enabled
+    """
+
+    udev_disks = "/dev/disk/by-id"
+    files = os.listdir(udev_disks)
+    disk_partitions = []
+    for file in files:
+        if not file.startswith(prefix + "-") or file.find("-part") == -1:
+            continue
+
+        file_str = file[4:]
+        parts = file_str.split("_")
+        if len(parts) < 2:
+            continue
+        if len(parts) < 3:
+            parts += [""]
+
+        dest = os.readlink(udev_disks + "/" + file)
+        dest_dev = dest[-4:]
+        if len(dest_dev) != 4:
+            continue
+
+        disk_partitions += [[file, parts[0] + " " + parts[1] + " " + parts[2], dest_dev]]
+
+    return disk_partitions
+
+def get_partition_size(partition):
+    proc_partitions = "/proc/partitions"
+
+    fd = open(proc_partitions, "r")
+    data = fd.read()
+    fd.close()
+
+    data = data.split("\n")
+    for line in data[2:]:
+        line_data = line.split()
+        if len(line_data) != 4:
+            continue
+        if line_data[3] == partition:
+            return line_data[2]
+    return -1

Modified: trunk/scripts-base/usr/sbin/rebuildfstab
===================================================================
--- trunk/scripts-base/usr/sbin/rebuildfstab	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/usr/sbin/rebuildfstab	2008-03-27 16:46:19 UTC (rev 2620)
@@ -4,101 +4,7 @@
 # slightly editted for morphix usage
 #
 # $Id$
-#
 
-PATH="/bin:/sbin:/usr/bin:/usr/sbin"
-export PATH
-umask 022
+# Removed, now using rebuildfstab-morphix instead
 
-[ ! -e /proc/partitions ] && { echo "$0: /proc not mounted, exiting" >&2; exit 1; }
-
-if [ -e /var/run/rebuildfstab.pid ]; then
- ps "$(</var/run/rebuildfstab.pid)" >/dev/null 2>&1 && exit 0
- rm -f /var/run/rebuildfstab.pid
-fi
-
-echo "$$" >/var/run/rebuildfstab.pid
-
-XSH=""
-[ -n "$DISPLAY" ] && XSH="rxvt -bg black -fg green -cr red -T $0 -e"
-
-[ "`id -u`" != "0" ] && { exec $XSH sudo $0 "$@"; }
-
-
-TMP="/tmp/fstab.$$.tmp"
-ADDEDBYKNOPPIX="# Added by Morphix"
-
-# Simple shell grep, searches for lines STARTING with string
-stringinfile(){
-while read line; do
-case "$line" in $1*) return 0;; esac
-done <"$2"
-return 1
-}
-
-removeentries(){
-# Remove comment line $1 and the following line from file $2
-# sed '/^# Added by KNOPPIX/{N;d;}'
-while read line; do
-case "$line" in $1) read line; continue ;; esac
-echo "$line"
-done <"$2"
-}
-
-verbose=""
-remove=""
-user=""
-group=""
-arg="$1"
-while [ -n "$arg" ]; do
- case "$arg" in
-  -v*) verbose="yes" ;;
-  -r*) remove="yes" ;;
-  -u*) shift; user="$1" ;;
-  -g*) shift; group="$1" ;;
-  *) echo "Usage: $0 [-v[erbose]] [-r[emove_old]] [-u[ser] uid] [ -g[roup] gid]" ;;
- esac
- shift
- arg="$1"
-done
-
-[ -n "$verbose" ] && echo "Scanning for new harddisks/partitions..." >&2
-rm -f "$TMP"
-
-if [ -n "$remove" ]; then
- removeentries "$ADDEDBYKNOPPIX" /etc/fstab >"$TMP"
-else
- cat /etc/fstab >"$TMP"
-fi
-
-count=0
-while read device mountpoint fstype relax; do
- stringinfile "$device " "$TMP" || \
- { count="$((count + 1))"
-   [ -d "$mountpoint" ] || mkdir -p "$mountpoint" 2>/dev/null
-   options="noauto,users,exec"
-   case "$fstype" in
-    ntfs) options="${options},ro,umask=000" ;;
-    vfat|msdos) options="${options},umask=000" ;;
-    swap) options="defaults" ;;
-   esac
-   case "$fstype" in
-   ntfs|vfat|msdos)
-   [ -n "$user" ] && options="$options,uid=$user"
-   [ -n "$group" ] && options="$options,gid=$group"
-   ;;
-   esac
-   echo "$ADDEDBYKNOPPIX"
-   echo "$device $mountpoint $fstype $options 0 0"; }
-done >>"$TMP" <<EOT
-$(scanpartitions)
-EOT
-
-[ -n "$verbose" ] && { [ "$count" -gt 0 ] && echo "Adding $count new partitions to /etc/fstab." >&2 || echo "No new partitions found." >&2; }
-mv -f "$TMP" /etc/fstab
-
-rm -f /var/run/rebuildfstab.pid
-
-[ -n "$DISPLAY" ] && sleep 2
-
 exit 0

Added: trunk/scripts-base/usr/sbin/rebuildfstab-morphix
===================================================================
--- trunk/scripts-base/usr/sbin/rebuildfstab-morphix	                        (rev 0)
+++ trunk/scripts-base/usr/sbin/rebuildfstab-morphix	2008-03-27 16:46:19 UTC (rev 2620)
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# $Id$
+
+# A small script to rebuild the fstab file using udev
+# (instead of the aging Knoppix-routine in rebuildfstab)
+# We assume udev has been enabled for /dev before running this script
+# Also makes the directories under /media for all devices
+
+# Makes use of the python-minimal package, in order to minimize base size
+
+# First argument to this script should be the username of the Morphix user,
+# else this is 'morph'
+
+from linux_devices import get_device_partitions, get_partition_size
+import sys, os
+
+if len(sys.argv) > 1:
+    username = sys.argv[1]
+else:
+    username = "morph"
+
+# Basic initial fstab
+
+fstab = "/proc /proc proc defaults 0 0\n\
+/sys /sys sysfs noauto 0 0\n\
+/dev/pts /dev/pts devpts mode=0622 0 0\n\
+/dev/fd0 /media/floppy auto user,noauto,exec,umask=000,uid=" + username + " 0 0\n\
+/dev/cdrom /media/cdrom auto user,noauto,exec,ro,uid=" + username + " 0 0\n"
+
+def add_to_fstab(fstab, partitions, username):
+
+    for p in partitions:
+        system("mkdir -p /media/" + p[2])
+        line = "/dev/" + p[2] + " /media/" + p[2] + " auto defaults,users,uid=" + username + " 0 0\n"
+        fstab += line
+    return fstab
+
+# Add these to the fstab
+
+fstab = add_to_fstab(fstab, get_device_partitions("ata"), username)
+fstab = add_to_fstab(fstab, get_device_partitions("scsi"), username)
+fstab = add_to_fstab(fstab, get_device_partitions("usb"), username)
+
+fd = open("/etc/fstab", "w")
+fd.write(fstab)
+fd.close()
+
+


Property changes on: trunk/scripts-base/usr/sbin/rebuildfstab-morphix
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/scripts-base/usr/sbin/scanpartitions
===================================================================
--- trunk/scripts-base/usr/sbin/scanpartitions	2008-03-19 23:12:50 UTC (rev 2619)
+++ trunk/scripts-base/usr/sbin/scanpartitions	2008-03-27 16:46:19 UTC (rev 2620)
@@ -1,91 +1,4 @@
 #!/bin/bash
-# (C) Klaus Knopper Nov 2002
-# Reads /proc/partitions, returns table of the form
-# basename(devicefile) mountpoint filesystemtype
-# Useful for automatic generation of /etc/fstab entries (you
-# still may have to add noauto 0 0).
-#
 # $Id$
-#
 
-[ ! -e /proc/partitions ] && { echo "$0: /proc not mounted, exiting" >&2; exit 1; }
-
-fstype(){
-[ -n "$1" ] || return 1
-
-# Check if partition is already mounted
-while read device mountpoint filesystem relax; do
-case "$device" in *$1*) echo "$filesystem"; return 0;; esac
-done <<EOT
-$(cat /proc/mounts)
-EOT
-
-# Check if a device/medium is present at all
-dd if="$1" count=1 bs=1024 >/dev/null 2>&1 || return 2
-FILE="$(LANG=C LC_ALL=C LC_MESSAGES=C file -Ls "$1")"
-[ "$?" = "0" ] || return 2
-
-# File systems to try first
-FILESYSTEMS=""
-case "$FILE" in
-*[Ff][Aa][Tt]*|*[Xx]86*) FILESYSTEMS="vfat msdos ntfs";;
-*[Rr][Ee][Ii][Ss][Ee][Rr]*)  echo "reiserfs"; return 0;;
-*[Xx][Ff][Ss]*)  echo "xfs"; return 0;;
-*[Ee][Xx][Tt]3*) echo "ext3"; return 0;;
-*[Ee][Xx][Tt]2*) echo "ext2"; return 0;;
-*[Ss][Ww][Aa][Pp]*) echo "swap"; return 0;;
-esac
-# It seems that only reliable way to identify the filesystem is to attempt a mount
-TMPDIR="/tmp/autmount.${1##*/}.$$.dir"
-mkdir -p "$TMPDIR" || return 3
-FS=""
-# Don't clobber console while attemting a mount
-read LOGLEVEL relax < /proc/sys/kernel/printk
-echo "0" >/proc/sys/kernel/printk
-for f in $FILESYSTEMS $(</etc/filesystems); do
-mount -r -t "$f" "$1" "$TMPDIR" >/dev/null 2>&1 && { umount "$TMPDIR"; FS="$f"; break; }
-umount -f "$TMPDIR" >/dev/null 2>&1
-done
-echo "$LOGLEVEL" >/proc/sys/kernel/printk
-rmdir "$TMPDIR"
-[ -n "$FS" ] && echo "$FS" || return 4
-}
-
-###
-
-if [ -z "$1" ]; then
-partitions=""
-disks=""
-pold="none"
-while read major minor blocks partition relax; do
-partition="${partition##*/}"
-[ -z "$partition" -o ! -e "/dev/$partition" ] && continue
-[ "$blocks" -lt 2 ] && continue
-case "$partition" in
-[hs]d?) disks="$disks $partition";;
-loop*) continue;;
-*) partitions="$partitions /dev/$partition";;
-esac
-done <<EOT
-$(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $0}}}' /proc/partitions)
-EOT
-
-# Add disks without partition table (probably ZIP drives)
-for d in $disks; do
-case "$partitions" in */dev/$d*) continue;; esac
-partitions="$partitions /dev/$d"
-done
-else
-partitions="$*"
-fi
-
-for p in $partitions; do
-fs="auto"
-scanfs="$(fstype $p)"
-[ -n "$scanfs" ] && fs="$scanfs"
-mountpoint="/mnt/${p##*/}"
-[ "$fs" = "swap" ] && mountpoint="none"
-echo "${p}" "${mountpoint}" "${fs}"
-done
-
-exit 0
+# Removed, see rebuildfstab-morphix


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace