61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Bash
		
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Bash
		
	
	
| #!/bin/bash
 | |
| 
 | |
| type getarg > /dev/null 2>&1 || source /lib/dracut-lib.sh
 | |
| 
 | |
| [ ! -d /run/void-usb/container ] && mkdir -p /run/void-usb/container
 | |
| 
 | |
| CONTAINER="$(getarg void-usb-container)"
 | |
| case "$CONTAINER" in
 | |
|   LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
 | |
|     CONTAINER="$(label_uuid_to_dev "$CONTAINER")"
 | |
|     ;;
 | |
|   /dev/*)
 | |
|     true
 | |
|     ;;
 | |
|   *)
 | |
|     echo -e "Invalid value for 'void-usb-container' kernel command line parameter!\nDropping into emergency shell."
 | |
|     emergency_shell
 | |
| esac
 | |
| 
 | |
| # try to wait for $CONTAINER to be available
 | |
| function mount_container {
 | |
|   mount -t f2fs -o nodev,nosuid "$CONTAINER" /run/void-usb/container;
 | |
| }
 | |
| 
 | |
| if [ -b "$CONTAINER" ]; then
 | |
|   mount_container
 | |
| else
 | |
|   sleep 1
 | |
|   if [ -b "$CONTAINER" ]; then
 | |
|     mount_container
 | |
|   else
 | |
|     sleep 1
 | |
|     if [ -b "$CONTAINER" ]; then
 | |
|       mount_container
 | |
|     else
 | |
|       sleep 3
 | |
|       if [ -b "$CONTAINER" ]; then
 | |
|         mount_container
 | |
|       else
 | |
|         sleep 5
 | |
|         if [ -b "$CONTAINER" ]; then
 | |
|           mount_container
 | |
|         else
 | |
|           sleep 10
 | |
|           if [ -b "$CONTAINER" ]; then
 | |
|             mount_container
 | |
|           fi
 | |
|           # assume that the drive won't show up after more than 20s
 | |
|         fi
 | |
|       fi
 | |
|     fi
 | |
|   fi
 | |
| fi
 | |
| 
 | |
| if [ -f /run/void-usb/container/squashfs.img ]; then
 | |
|   losetup -r -f /run/void-usb/container/squashfs.img
 | |
| else
 | |
|   echo "Failed to find squashfs image. Dropping into an emergency shell. Good luck!"
 | |
|   emergency_shell
 | |
| fi
 |