mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
Merge branch 'master' of github.com:OpenELEC/OpenELEC.tv
This commit is contained in:
commit
c2a493b89a
@ -20,46 +20,56 @@
|
|||||||
# http://www.gnu.org/copyleft/gpl.html
|
# http://www.gnu.org/copyleft/gpl.html
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# usage: sudo ./create_virtualmachine <path> <size(MB)> [<type>]
|
# usage: sudo ./create_virtualmachine <path> <size(MB)> [<type>] [system partition size(MB)]
|
||||||
# example: sudo ./create_virtualmachine /home/test/VM 512 [vdi]
|
# example: sudo ./create_virtualmachine /home/test/VM 512 [vdi] [128]
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
clear
|
clear
|
||||||
echo "###########################################################"
|
echo "##############################################################"
|
||||||
echo "# please execute with 'sudo' or -DANGEROUS!!!- as root #"
|
echo "# please execute with 'sudo' or -DANGEROUS!!!- as root #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
||||||
echo "###########################################################"
|
echo "##############################################################"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$1" -o -z "$2" ]; then
|
if [ -z "$1" -o -z "$2" ]; then
|
||||||
clear
|
clear
|
||||||
echo "###########################################################"
|
echo "##############################################################"
|
||||||
echo "# please execute as follows #"
|
echo "# please execute as follows #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
echo "# sudo ./create_virtualmachine <path> <size(MB)> [<type>] #"
|
||||||
echo "###########################################################"
|
echo "##############################################################"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
clear
|
||||||
|
echo "##############################################################"
|
||||||
|
echo "# please create target directory #"
|
||||||
|
echo "# example: #"
|
||||||
|
echo "# mkdir <path> #"
|
||||||
|
echo "##############################################################"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$2" -lt "200" -o "$2" -gt "2048" ]; then
|
if [ "$2" -lt "200" -o "$2" -gt "2048" ]; then
|
||||||
clear
|
clear
|
||||||
echo "#########################################################"
|
echo "##############################################################"
|
||||||
echo "# use a value between 200MB and 2048MB (2GB) #"
|
echo "# use a value between 200MB and 2048MB (2GB) #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine /home/test/VM 512 #"
|
echo "# sudo ./create_virtualmachine /home/test/VM 512 #"
|
||||||
echo "#########################################################"
|
echo "##############################################################"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$3" -a "$3" != "vdi" -a "$3" != "vmdk" ]; then
|
if [ ! -z "$3" -a "$3" != "vdi" -a "$3" != "vmdk" ]; then
|
||||||
clear
|
clear
|
||||||
echo "#########################################################"
|
echo "##############################################################"
|
||||||
echo "# only vdi or vmdk types are supported #"
|
echo "# only vdi or vmdk types are supported #"
|
||||||
echo "# example: #"
|
echo "# example: #"
|
||||||
echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] #"
|
echo "# sudo ./create_virtualmachine /home/test/VM 512 [vdi] #"
|
||||||
echo "#########################################################"
|
echo "##############################################################"
|
||||||
exit 1
|
exit 1
|
||||||
elif [ "$3" = "vdi" ]; then
|
elif [ "$3" = "vdi" ]; then
|
||||||
TYPE="vdi"
|
TYPE="vdi"
|
||||||
@ -67,9 +77,21 @@ elif [ -z "$3" -o "$3" = "vmdk" ]; then
|
|||||||
TYPE="vmdk"
|
TYPE="vmdk"
|
||||||
fi
|
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"
|
DISK="$1/OpenELEC.img"
|
||||||
IMAGE="$1/OpenELEC.$TYPE"
|
IMAGE="$1/OpenELEC.$TYPE"
|
||||||
LOOP=$(losetup -f)
|
LOOP=$(losetup -f)
|
||||||
|
SYSTEM_PART_SIZE=$(( $4 / 8 ))
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo "#########################################################"
|
echo "#########################################################"
|
||||||
@ -101,6 +123,22 @@ echo "#########################################################"
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# this is needed by syslinux
|
||||||
which mcopy > /dev/null
|
which mcopy > /dev/null
|
||||||
if [ "$?" = "1" ]; then
|
if [ "$?" = "1" ]; then
|
||||||
@ -185,7 +223,7 @@ echo "#########################################################"
|
|||||||
|
|
||||||
# create an image
|
# create an image
|
||||||
echo "creating new empty harddisk image: $DISK..."
|
echo "creating new empty harddisk image: $DISK..."
|
||||||
dd if=/dev/zero of="$DISK" bs=1M count=1024
|
dd if=/dev/zero of="$DISK" bs=1M count="$2"
|
||||||
|
|
||||||
# write a disklabel
|
# write a disklabel
|
||||||
echo "creating new partition table: $DISK..."
|
echo "creating new partition table: $DISK..."
|
||||||
@ -194,11 +232,11 @@ echo "#########################################################"
|
|||||||
|
|
||||||
# create partition1
|
# create partition1
|
||||||
echo "creating partition1 on $DISK..."
|
echo "creating partition1 on $DISK..."
|
||||||
parted -s "$LOOP" unit cyl mkpart primary ext2 -- 0 16
|
parted -s "$LOOP" unit cyl mkpart primary ext2 -- 0 "$SYSTEM_PART_SIZE"
|
||||||
|
|
||||||
# create partition2
|
# create partition2
|
||||||
echo "creating partition2 on $DISK..."
|
echo "creating partition2 on $DISK..."
|
||||||
parted -s "$LOOP" unit cyl mkpart primary ext2 -- 16 -2
|
parted -s "$LOOP" unit cyl mkpart primary ext2 -- "$(( $SYSTEM_PART_SIZE + 1 ))" -2
|
||||||
|
|
||||||
# make partition1 active (bootable)
|
# make partition1 active (bootable)
|
||||||
echo "marking partition1 active..."
|
echo "marking partition1 active..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user