diff --git a/packages/tools/syslinux/files/create_virtualimage b/packages/tools/syslinux/files/create_virtualimage index 4b9b97e548..bdb8feeee1 100755 --- a/packages/tools/syslinux/files/create_virtualimage +++ b/packages/tools/syslinux/files/create_virtualimage @@ -20,56 +20,46 @@ # http://www.gnu.org/copyleft/gpl.html ################################################################################ -# usage: sudo ./create_virtualmachine [] [system partition size(MB)] -# example: sudo ./create_virtualmachine /home/test/VM 512 [vdi] [128] +# usage: sudo ./create_virtualmachine [] +# example: sudo ./create_virtualmachine /home/test/VM 512 [vdi] if [ "$(id -u)" != "0" ]; then clear - echo "##############################################################" - echo "# please execute with 'sudo' or -DANGEROUS!!!- as root #" - echo "# example: #" - echo "# sudo ./create_virtualmachine [] #" - echo "##############################################################" + echo "###########################################################" + echo "# please execute with 'sudo' or -DANGEROUS!!!- as root #" + echo "# example: #" + echo "# sudo ./create_virtualmachine [] #" + echo "###########################################################" exit 1 fi if [ -z "$1" -o -z "$2" ]; then clear - echo "##############################################################" - echo "# please execute as follows #" - echo "# example: #" - echo "# sudo ./create_virtualmachine [] #" - echo "##############################################################" - exit 1 -fi - -if [ ! -d "$1" ]; then - clear - echo "##############################################################" - echo "# please create target directory #" - echo "# example: #" - echo "# mkdir #" - echo "##############################################################" + echo "###########################################################" + echo "# please execute as follows #" + echo "# example: #" + echo "# sudo ./create_virtualmachine [] #" + echo "###########################################################" exit 1 fi if [ "$2" -lt "200" -o "$2" -gt "2048" ]; then clear - echo "##############################################################" - echo "# use a value between 200MB and 2048MB (2GB) #" - echo "# example: #" - echo "# sudo ./create_virtualmachine /home/test/VM 512 #" - echo "##############################################################" + echo "#########################################################" + echo "# use a value between 200MB and 2048MB (2GB) #" + echo "# example: #" + echo "# sudo ./create_virtualmachine /home/test/VM 512 #" + echo "#########################################################" exit 1 fi if [ ! -z "$3" -a "$3" != "vdi" -a "$3" != "vmdk" ]; then clear - echo "##############################################################" - echo "# only vdi or vmdk types are supported #" - echo "# example: #" - echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] #" - echo "##############################################################" + echo "#########################################################" + echo "# only vdi or vmdk types are supported #" + echo "# example: #" + echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] #" + echo "#########################################################" exit 1 elif [ "$3" = "vdi" ]; then TYPE="vdi" @@ -77,21 +67,9 @@ elif [ -z "$3" -o "$3" = "vmdk" ]; then TYPE="vmdk" fi -if [ "$4" -lt "128" -o "$4" -gt "1024" -o "$4" -gt "$2" ]; then - clear - echo "##############################################################" - echo "# use a value between 128MB and 1024MB #" - echo "# example: #" - echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] [256] #" - echo "##############################################################" - exit 1 -fi - - DISK="$1/OpenELEC.img" IMAGE="$1/OpenELEC.$TYPE" LOOP=$(losetup -f) -SYSTEM_PART_SIZE=$(( $4 / 8 )) clear echo "#########################################################" @@ -123,22 +101,6 @@ echo "#########################################################" exit 1 fi - # this is needed to create a bootloader - which extlinux > /dev/null - if [ "$?" = "1" ]; then - clear - echo "#########################################################" - echo "# #" - echo "# OpenELEC.tv missing tool - Installation will quit #" - echo "# #" - echo "# We can't find the required tool \"extlinux\" #" - echo "# on your system. #" - echo "# Please install it via your package manager. #" - echo "# #" - echo "#########################################################" - exit 1 - fi - # this is needed by syslinux which mcopy > /dev/null if [ "$?" = "1" ]; then @@ -223,7 +185,7 @@ echo "#########################################################" # create an image echo "creating new empty harddisk image: $DISK..." - dd if=/dev/zero of="$DISK" bs=1M count="$2" + dd if=/dev/zero of="$DISK" bs=1M count=1024 # write a disklabel echo "creating new partition table: $DISK..." @@ -232,11 +194,11 @@ echo "#########################################################" # create partition1 echo "creating partition1 on $DISK..." - parted -s "$LOOP" unit cyl mkpart primary ext2 -- 0 "$SYSTEM_PART_SIZE" + parted -s "$LOOP" unit cyl mkpart primary ext2 -- 0 16 # create partition2 echo "creating partition2 on $DISK..." - parted -s "$LOOP" unit cyl mkpart primary ext2 -- "$(( $SYSTEM_PART_SIZE + 1 ))" -2 + parted -s "$LOOP" unit cyl mkpart primary ext2 -- 16 -2 # make partition1 active (bootable) echo "marking partition1 active..."