Correcting typo in description of the ip boot parameter in live-initramfs manpage...
[live-boot-grml.git] / scripts / live
index 5d5b978..683afa2 100755 (executable)
@@ -773,9 +773,11 @@ do_httpmount ()
                                        then
                                                case "$url" in
                                                        tftp*)
-                                                               ip="$(dirname $url | sed -e 's|tftp://||g')"
-                                                               log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url})  -l ${dest}/$(basename ${url}) $ip"
-                                                               tftp -g -b 10240 -r $(basename ${url})  -l ${dest}/$(basename ${url}) $ip
+                                                               ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
+                                                               rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
+                                                               lfile="$(basename $url)"
+                                                               log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
+                                                               tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
                                                        ;;
 
                                                        *)
@@ -944,7 +946,7 @@ try_snap ()
        snap_mount="${2}"
        snap_type="${3}"
 
-       if [ ! -z "${snapdata}" ]
+       if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
        then
                log_success_msg "found snapshot: ${snapdata}"
                snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
@@ -983,12 +985,11 @@ try_snap ()
                        log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
                fi
 
-
        elif [ -b "${snapdata}" ]
        then
                # Try to find if it could be a snapshot partition
                dev="${snapdata}"
-               log_success_msg "found snapshot device on ${dev}"
+               log_success_msg "found snapshot ${snap_type} device on ${dev}"
                if echo "${dev}" | grep -qs loop
                then
                        # strange things happens, user confused?
@@ -1401,13 +1402,52 @@ find_livefs ()
        fi
 
        # first look at the one specified in the command line
-       if [ ! -z "${LIVE_MEDIA}" ]
-       then
-               if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
-               then
-                       return 0
-               fi
-       fi
+       case "${LIVE_MEDIA}" in
+               removable-usb)
+                       for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+                       do
+                               if [ "$(cat ${sysblock}/removable)" = "1" ]
+                               then
+                                       if readlink ${sysblock}/device | grep -q usb
+                                       then
+                                               for dev in $(subdevices "${sysblock}")
+                                               do
+                                                       if check_dev "${dev}"
+                                                       then
+                                                               return 0
+                                                       fi
+                                               done
+                                       fi
+                               fi
+                       done
+                       ;;
+
+               removable)
+                       for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+                       do
+                               if [ "$(cat ${sysblock}/removable)" = "1" ]
+                               then
+                                       for dev in $(subdevices "${sysblock}")
+                                       do
+                                               if check_dev "${dev}"
+                                               then
+                                                       return 0
+                                               fi
+                                       done
+                               fi
+                       done
+                       ;;
+
+               *)
+                       if [ ! -z "${LIVE_MEDIA}" ]
+                       then
+                               if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
+                               then
+                                       return 0
+                               fi
+                       fi
+                       ;;
+       esac
 
        # or do the scan of block devices
        for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")