-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxboot
More file actions
executable file
·58 lines (52 loc) · 2.57 KB
/
xboot
File metadata and controls
executable file
·58 lines (52 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: xboot
# Created: Tuesday, 2020/02/04 - 00:07:38
# Author.: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 17:38:37
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.0.5.122
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# shellcheck disable=SC1090,SC2154
source "$xSHELL_INIT"
use args
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
xrequirements qemu-system-x86_64 sudo fallocate rm
# _cmd_="sudo qemu-system-x86_64 -usb -usbdevice disk:<disk> -boot menu=on -m 512"
# _cmd_="sudo qemu-system-x86_64 -device piix3-usb-uhci -drive id=pendrive,file=<disk>,format=raw,if=none -device usb-storage,drive=pendrive -boot menu=on -m 512"
# _cmd_="sudo qemu-system-x86_64 -hdc /tmp/vda.img -hdb <disk> -boot menu=on -m 512"
_cmd_="sudo qemu-system-x86_64 -hdc /tmp/vda.img -boot menu=on -m <memory>"
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
xarg --id -d,--disk --var disk --desc "create disk to install"
xarg --id -i,--iso --var iso+r --desc "ISO file to boot"
xarg --id -u,--usb --var usb+r --desc "boot usb stick"
xarg --id -s,--size --var size+r --desc "size of install disk"
xarg --id -m,--memory --var memory+r --desc "set memory of new VM"
xarg --header "use qemu to boot an iso/usb stick"
xarg --footer "* this script requires 'qemu-system-x86_64' and root privileges"
xrun --xreject-unknow --xrequire-one --xversionrc --xcolors "$@"
[ -z "$size" ] && size=5G
[ -n "$iso" ] && _cmd_+=" -drive file=$iso,index=0,media=cdrom"
[ -n "$usb" ] && _cmd_+=" -drive file=$usb,format=raw,index=0,media=disk"
if [ -n "$memory" ]; then
_cmd_+=${_cmd_/<memory>/$memory}
else
_cmd_+=${_cmd_/<memory>/512}
fi
if sudo fallocate -l $size /tmp/vda.img; then
echo "$_cmd_"
eval "$_cmd_"
sudo rm /tmp/vda.img
else
echo "Failed to create /tmp/vda.img! Check your disk space"
fi