#!/bin/sh RDIR=/dev/tty4 NDIR=/dev/null TMP=/var/log/setup/tmp DRIVE_FOUND="" if [ ! -d $TMP ]; then mkdir -p $TMP fi T_PX="`cat $TMP/SeTT_PX`" rm -f $TMP/SeTmount $TMP/SeTDS $TMP/reply # Run "rescan-scsi-bus -l" to discover our USB stick if needed: /sbin/rescan-scsi-bus -l 1>$RDIR 2>$RDIR # Search the SCSI partitions found by the kernel: dialog --title "SCANNING" --infobox "Scanning for a USB \ drive containing a Slackware signature..." 4 56 sleep 3 # Try to find the Slackware packages partition label. We can not know in # advance where we will find our USB stick, so the best non-interactive method # I could come up with is using the ext2 disk label. for device in $( /bin/grep sd[a-h]2 /proc/partitions | /bin/tr -s ' ' | /bin/cut -d' ' -f5 ) do label=$( /sbin/e2label /dev/$device 2>/dev/null ) if [ ! -z "$label" ] ; then if [ "$label" = "USBSLACKINSTALL" ] ; then DRIVE_FOUND="/dev/$device" break fi fi done if [ "${DRIVE_FOUND}" = "" ]; then dialog --title "SLACKWARE USB STICK NOT FOUND" --msgbox \ "A Slackware USB stick could not be found among any of the devices that \ were scanned. Possible reasons include: you use your own branded stick \ instead of a Slackware branded stick. We are expecting the packages to be \ on the second partition of your stick, formatted as a 'ext2' filesystem \ and with a disk label of 'USBSLACKINSTALL'. \ Or else, the USB stick was not detected properly - try unplugging and \ re-plugging it and then return to this menu.\n\ You can still install Slackware from your USB stick, but you will have to \ select \"Install from a hard drive partition\" from the \"SOURCE\" menu.\n\ \n\ You will now be returned to the main menu. If you want to try looking for \ the USB stick again, you may skip directly to the SOURCE menu selection." \ 0 0 rm -f $TMP/SeTDS $TMP/SeTmount $TMP/errordo exit fi while [ 0 ]; do # time to try to mount the USB device: mount -o ro -t ext2 ${DRIVE_FOUND} /var/log/mount 1> $RDIR 2> $RDIR if [ $? = 0 ]; then # mounted successfully dialog --title "SLACKWARE USB STICK FOUND" --sleep 3 --infobox \ "A Slackware signature was found on ${DRIVE_FOUND}." 3 52 break else # failed to mount dialog --title "MOUNT ERROR" --menu "There was an error \ attempting to mount the USB stick partition ${DRIVE_FOUND}. \ Maybe the device name is incorrect, the partition is corrupt \ or has the wrong filesystem type on it. \ What would you like to do now?" \ 13 70 3 \ "1" "Abort USB stick installation" \ "2" "Attempt to mount the USB device again" \ "3" "Ignore the error and continue" 2> $TMP/errordo if [ ! $? = 0 ]; then rm -f $TMP/SeTDS $TMP/SeTmount $TMP/errordo exit; fi DOWHAT="`cat $TMP/errordo`" rm -f $TMP/errordo if [ $DOWHAT = 1 ]; then rm -f $TMP/SeTDS $TMP/SeTmount exit elif [ $DOWHAT = 2 ]; then dialog --title "ATTEMPTING TO MOUNT USB STICK on ${DRIVE_FOUND}" \ --infobox "Attempting to mount your USB stick again with the \ following command: mount -o ro -t ext2 ${DRIVE_FOUND} \ /var/log/mount" 4 69 umount /var/log/mount 1> $NDIR 2> $NDIR sleep 5 elif [ $DOWHAT = 3 ]; then # Ignore error, really bad plan but whatever break fi fi done # Pass information about the source directory to the next install stage: echo "/var/log/mount/slackware" > $TMP/SeTDS echo "-source_mounted" > $TMP/SeTmount echo "/dev/null" > $TMP/SeTsource