#!/bin/bash function detect_version() { version="" if has_label Share; then version="1.0" elif has_label MDVUSBROOT; then version="1.05" elif has_label Mdv_Flash; then version="2.0" elif has_label MDV_FLASH; then version="2.05" fi usbroot_device=$_device source_version_variables [ -n "$version" ] } function source_version_variables { local _version _version=$1 [ -z "$_version" ] && _version=$version if [ "$_version" = "1.0" ]; then label=MDVUSBROOT boot_rel="/boot" loopbacks_rel="/loopbacks" elif [ "$_version" = "1.05" ]; then label=MDVUSBROOT boot_rel="/.boot" loopbacks_rel="/.loopbacks" elif [ "$_version" = "2.0" ]; then label=Mdv_Flash boot_rel="/.boot" loopbacks_rel="/.loopbacks" elif [ "$_version" = "2.05" ]; then label=MDV_FLASH boot_rel="/.boot" loopbacks_rel="/.loopbacks" fi } function has_label() { local _label _tmpdir _label=$1 _tmpdir="/tmp/$$" mkdir -p $_tmpdir nash --force > /dev/null 2>&1 < /dev/null rmdir $_tmpdir 2> /dev/null return $rc } function check_vendor() { # list of supported vendors/models # mandriva flash 1.0 (france) vendors[0]="13fe" models[0]="1a00" # mandriva flash 1.0 (brazil) vendors[1]="0930" models[1]="653e" # mandriva flash 4GB (france) vendors[2]="13fe" models[2]="1d00" rc=1 mount -t usbfs none /proc/bus/usb 2> /dev/null i=0 while [ ! -z "${vendors[$i]}" ]; do grep "P:" /proc/bus/usb/devices | grep -q \ "Vendor=${vendors[$i]} ProdID=${models[$i]}" if [ $? -eq 0 ]; then rc=0 break fi let i++ done umount /proc/bus/usb 2> /dev/null return $rc } function insert_pendrive() { _tmpdir="/tmp/rescue-temp" mkdir -p $_tmpdir modprobe usb-storage > /dev/null 2>&1 modprobe vfat > /dev/null 2>&1 echo echo -n 'Please insert your Mandriva Flash pen drive and press ENTER when ready: ' read READY echo echo -n 'Detecting pen drive: ' for ((i=0; $i <= 15 ; i++)); do detect_version && nash --force > /dev/null 2>&1 < /tmp/rescue-device umount $_tmpdir rmdir $_tmpdir 2> /dev/null return 0 fi done rmdir $_tmpdir 2> /dev/null echo echo echo "Couldn't detect Mandriva Flash pen drive!" echo return 1 } function mount_usbroot() { nash --force > /dev/null 2>&1 < /dev/null 2>&1 <