Improvements in CLI operations.

1. Install extlinux under Linux for NTFS filesystem
2. Check for root previlage when using CLI
3. Fix crash when installing ISO from CLI due to GPT check
4. Fix crash when installing syslinux from CLI due to GPT check
5. Correct usage instructions
pull/252/head
Sundar 7 years ago
parent d5882766a3
commit 151077da7b

@ -102,7 +102,7 @@ class pkg():
with open("stdeb.cfg", "w") as f:
f.write(stdcfg)
if subprocess.call('python3 setup.py --command-packages=stdeb.command bdist_deb', shell=True) == 0 and \
if subprocess.call('python3.5 setup.py --command-packages=stdeb.command bdist_deb', shell=True) == 0 and \
os.path.exists(os.path.join("deb_dist", "python3-multibootusb_" + self.version + "-1_all.deb")):
try:
shutil.copy2(os.path.join("deb_dist", "python3-multibootusb_" + self.version + "-1_all.deb"),
@ -130,7 +130,7 @@ class pkg():
"Requires = " + require)
with open("setup.cfg", "w") as f:
f.write(setup_cfg)
if subprocess.call('python3 setup.py bdist_rpm', shell=True) == 0 and \
if subprocess.call('python3.5 setup.py bdist_rpm', shell=True) == 0 and \
os.path.exists(os.path.join("dist", "multibootusb-" + self.version + "-1.noarch.rpm")):
if self.pkg_name == 'suse':
package = "multibootusb-" + self.version + "-1suse.noarch.rpm"

@ -91,7 +91,7 @@ Example for installing multiple distros without user intervention:
python3 multibootusb -c -y -i ../../favourite.iso,../../other-distro.iso -t /dev/sdb1
Windows:
python3 multibootusb -c -i ../../favourite.iso,../../other-distro.iso -t G:
python3 multibootusb -c -y -i ../../favourite.iso,../../other-distro.iso -t G:
Example for writing ISO image to target USB disk (will destroy data on USB disk):
@ -99,7 +99,7 @@ Example for writing ISO image to target USB disk (will destroy data on USB disk)
python3 multibootusb -c -r -i ../../favourite.iso -t /dev/sdb
Windows:
python3 multibootusb -c -i -r ../../favourite.iso -t G:
python3 multibootusb -c -r -i ../../favourite.iso -t G:
''')
sys.exit(2)
@ -167,6 +167,7 @@ if config.debug is True:
if gui is False:
check_admin()
if uninstall is True and config.usb_disk is not '':
cli_uninstall_distro()
elif uninstall is True and config.usb_disk is '':

@ -8,6 +8,7 @@
import os
import ctypes
import platform
from . import usb
from . import gen
from .iso import *
@ -29,29 +30,23 @@ def read_input_uninstall():
return response
def is_root():
def check_admin():
"""
Check if user has admin rights
:return:
"""
if platform.system() == 'Linux':
if os.getuid() == 0:
return True
if os.getuid() != 0:
exit("You need to have root privileges to run this application."
"\nPlease try again using 'sudo'. Exiting.")
elif platform.system() == 'Windows':
if ctypes.windll.shell32.IsUserAnAdmin() == 1:
return True
if ctypes.windll.shell32.IsUserAnAdmin() != 1:
exit("You need to have admin privileges to run this application."
"\nPlease open command window with admin rights. Exiting.")
return False
def cli_install_distro():
# if platform.system() == 'Linux':
# if os.getuid() != 0:
# exit("You need to have root privileges to run this script.\nPlease try again using 'sudo'. Exiting.")
# elif platform.system() == 'Windows':
#
# if admin.isUserAdmin():
# admin.elevate()
log('Starting multibootusb from Command line...')
if usb.is_block(config.usb_disk) is False:
log(config.usb_disk + ' is not a valid device partition...')
@ -64,6 +59,8 @@ def cli_install_distro():
config.usb_mount = usb_details['mount_point']
config.usb_uuid = usb_details['uuid']
config.usb_label = usb_details['label']
# Get the GPT status of the disk and store it on a variable
usb.gpt_device(config.usb_disk)
prepare_mbusb_host_dir()
if isinstance(config.image_path, str) is True:
iso_install(config.image_path)
@ -144,9 +141,6 @@ def cli_dd():
if config.usb_disk[-1].isdigit() is True:
log('Selected USB is a disk partition. Please select the whole disk eg. \'/dev/sdb\'')
sys.exit(2)
elif is_root() is False:
log("You need to have root privileges to run this script.\nPlease try again using admin privilege (sudo).")
sys.exit(2)
if not os.path.exists(config.image_path):
log('ISO image path does not exist. Please correct the path.')
@ -174,21 +168,19 @@ def cli_dd():
def cli_install_syslinux():
"""
Install syslinux on a target USB disk. It will installed on 'multibootusb' directory
Install syslinux on a target USB disk. It will be installed on 'multibootusb' directory
:return:
"""
usb.gpt_device(config.usb_disk)
if platform.system() == 'Linux':
if config.usb_disk[-1].isdigit() is not True:
log('Selected USB disk is not a partition. Please enter the partition eg. \'/dev/sdb1\'')
sys.exit(2)
elif is_root() is False:
log("You need to have root privileges to run this script.\nPlease try again using admin privilege (sudo).")
sys.exit(2)
if config.yes is not True:
log('\nInitiating process for installing syslinux on ' + config.usb_disk)
log('Selected target device is : ' + quote(config.usb_disk))
log('Syslinux install directory : \'multibootusb\'\n')
log('Syslinux install directory : ' + quote('multibootusb'))
log('Please confirm the option.')
log('Y/y/Yes/yes/YES or N/n/No/no/NO')
if read_input_yes() is True:

@ -16,10 +16,15 @@ from . import config
extlinux_path = os.path.join(multibootusb_host_dir(), "syslinux", "bin", "extlinux4")
syslinux_path = os.path.join(multibootusb_host_dir(), "syslinux", "bin", "syslinux4")
extlinux_fs = ["ext2", "ext3", "ext4", "Btrfs"]
syslinux_fs = ["vfat", "ntfs", "FAT32", "NTFS"]
mbr_bin = resource_path(os.path.join("data", "tools", "mbr.bin"))
win_gdisk = resource_path(os.path.join('data', 'tools', 'gdisk', 'gdisk.exe'))
# Force Linux to install extlinux on NTFS
if platform.system() == 'Linux':
extlinux_fs = ["ext2", "ext3", "ext4", "Btrfs", "NTFS", "ntfs"]
syslinux_fs = ["vfat", "FAT32"]
else:
extlinux_fs = ["ext2", "ext3", "ext4", "Btrfs"]
syslinux_fs = ["vfat", "ntfs", "FAT32", "NTFS"]
def gpt_part_table(usb_disk):

Loading…
Cancel
Save