Merge pull request #3 from philclifford/small-suggestions
Small bash suggestions, looks good 😄
This commit is contained in:
commit
cfde379c5b
9 changed files with 50 additions and 46 deletions
|
@ -33,7 +33,7 @@ DO NOT use any of the files from $SCRIPTDIR/config !
|
|||
}
|
||||
|
||||
function main () {
|
||||
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
|
||||
get_GPU
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ USB_CTL_ID=()
|
|||
}
|
||||
|
||||
function main () {
|
||||
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
|
||||
get_GROUP $1
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ function get_GPU_ROM () {
|
|||
# Get the config paths
|
||||
source "$SCRIPTDIR/lib/paths.sh"
|
||||
|
||||
VBIOS_PATH=$(find /sys/devices -name rom | grep $1)
|
||||
VBIOS_PATH=$(find /sys/devices -name rom | grep "$1")
|
||||
printf "We will now attempt to dump the vbios of your selected GPU.
|
||||
Passing a VBIOS rom to the card used for passthrough is required for some cards, but not all.
|
||||
Some cards also requires you to patch your VBIOS romfile, check online if this is neccessary for your card.
|
||||
|
@ -20,14 +20,14 @@ echo 0 | sudo tee $VBIOS_PATH
|
|||
read -p "Do you want to dump the VBIOS, choosing N will skip this step [y/N]: " YESNO
|
||||
case "${YESNO}" in
|
||||
[Yy]*)
|
||||
echo 1 | sudo tee $VBIOS_PATH
|
||||
sudo cat $VBIOS_PATH > "$SCRIPTDIR/$QUICKEMU/vfio_card.rom"
|
||||
sudo md5sum $VBIOS_PATH | cut -d " " -f 1 > "$SCRIPTDIR/$QUICKEMU/vfio_card.rom.md5"
|
||||
local ROM_MD5=$(sudo md5sum $VBIOS_PATH | cut -d " " -f 1)
|
||||
echo 0 | sudo tee $VBIOS_PATH
|
||||
echo 1 | sudo tee "$VBIOS_PATH"
|
||||
sudo cat "$VBIOS_PATH" > "$SCRIPTDIR/$QUICKEMU/vfio_card.rom"
|
||||
sudo md5sum "$VBIOS_PATH" | cut -d " " -f 1 > "$SCRIPTDIR/$QUICKEMU/vfio_card.rom.md5"
|
||||
local ROM_MD5=$(sudo md5sum "$VBIOS_PATH" | cut -d " " -f 1)
|
||||
echo 0 | sudo tee "$VBIOS_PATH"
|
||||
local ROMFILE_MD5=$(md5sum "$SCRIPTDIR/$QUICKEMU/vfio_card.rom" | cut -d " " -f 1)
|
||||
|
||||
if [ -f $SCRIPTDIR/$QUICKEMU/vfio_card.rom ];
|
||||
if [ -f "$SCRIPTDIR"/$QUICKEMU/vfio_card.rom ];
|
||||
then
|
||||
if [ "$ROM_MD5" == "$ROMFILE_MD5" ];
|
||||
then
|
||||
|
@ -59,7 +59,7 @@ echo 0 | sudo tee $VBIOS_PATH
|
|||
|
||||
|
||||
function main () {
|
||||
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
|
||||
get_GPU_ROM $1
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ Press q to quit
|
|||
}
|
||||
|
||||
function main () {
|
||||
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
|
||||
get_USB_CTL
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ To return to the previous page just press ENTER.
|
|||
}
|
||||
|
||||
function main () {
|
||||
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
|
||||
get_USB_CTL_GROUP $1
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
function set_CMDLINE () {
|
||||
clear
|
||||
# Get the config paths
|
||||
source "$SCRIPTDIR/lib/paths.sh"
|
||||
source "${SCRIPTDIR}/lib/paths.sh"
|
||||
|
||||
local CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args")
|
||||
local CMDLINE=$(cat "${SCRIPTDIR}/config/kernel_args")
|
||||
|
||||
printf "Configuration is now complete, however no changes have been done to your system.
|
||||
The files needed have just been written to $SCRIPTDIR/config/etc
|
||||
|
@ -42,7 +42,7 @@ the required information that the QuickEMU project can hook into and use to add
|
|||
|
||||
|
||||
function main () {
|
||||
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
set_CMDLINE
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,18 @@ function set_MODULES () {
|
|||
source "$SCRIPTDIR/lib/paths.sh"
|
||||
|
||||
# Write "/etc/modules"
|
||||
printf "vfio
|
||||
printf "
|
||||
# Generated by vfio-setup
|
||||
vfio
|
||||
vfio_iommu_type1
|
||||
vfio_pci ids=$1
|
||||
vfio_pci ids=%s
|
||||
vfio_virqfd
|
||||
" >> "$SCRIPTDIR/$MODULES"
|
||||
" "$1" >> "$SCRIPTDIR/$MODULES"
|
||||
|
||||
# Write "/etc/initramfs-tools/modules"
|
||||
printf "vfio
|
||||
printf "
|
||||
# Generated by vfio-setup
|
||||
vfio
|
||||
vfio_iommu_type1
|
||||
vfio_pci
|
||||
vfio_virqfd
|
||||
|
@ -23,42 +27,42 @@ vfio_virqfd
|
|||
|
||||
# Update the kernel_args file
|
||||
CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args")
|
||||
echo "$CMDLINE vfio_pci.ids=$GPU_DEVID" > "$SCRIPTDIR/config/kernel_args"
|
||||
echo "${CMDLINE} vfio_pci.ids=$GPU_DEVID" > "$SCRIPTDIR/config/kernel_args"
|
||||
|
||||
# Ask if we shall disable video output on this card
|
||||
read -p "Do you want to force disable video output in linux on this card? [Y/n]: " DISABLE_VGA
|
||||
case "${DISABLE_VGA}" in
|
||||
[Yy]*)
|
||||
GPU_DEVID="$GPU_DEVID disable_vga=1"
|
||||
GPU_DEVID="${GPU_DEVID} disable_vga=1"
|
||||
;;
|
||||
[Nn]*)
|
||||
echo ""
|
||||
;;
|
||||
*)
|
||||
GPU_DEVID="$GPU_DEVID disable_vga=1"
|
||||
GPU_DEVID="${GPU_DEVID} disable_vga=1"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Write the vfio modprobe config
|
||||
printf "# This is an autogenerated file that stubs your graphic card for use with vfio
|
||||
# This file should be placed inside /etc/modprobe.d/
|
||||
options vfio_pci ids=$GPU_DEVID
|
||||
options vfio_pci ids=%s
|
||||
|
||||
# Make sure vfio_pci is loaded before these modules: nvidia, nouveau, amdgpu and radeon
|
||||
softdep nvidia pre: vfio vfio_pci
|
||||
softdep nouveau pre: vfio vfio_pci
|
||||
softdep amdgpu pre: vfio vfio_pci
|
||||
softdep radeon pre: vfio vfio_pci
|
||||
" > "$SCRIPTDIR/$MODPROBE/vfio.conf"
|
||||
" "${GPU_DEVID}" > "$SCRIPTDIR/$MODPROBE/vfio.conf"
|
||||
|
||||
exec "$SCRIPTDIR/lib/get_USB_CTL.sh"
|
||||
}
|
||||
|
||||
|
||||
function main () {
|
||||
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
|
||||
set_MODULES $1
|
||||
set_MODULES "$1"
|
||||
}
|
||||
|
||||
main $1
|
||||
main "$1"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Get the scripts directory
|
||||
SCRIPTDIR=$(dirname `which $0`)
|
||||
cd $SCRIPTDIR
|
||||
SCRIPTDIR=$(dirname "$(which $0)")
|
||||
cd "$SCRIPTDIR"
|
||||
|
||||
# Get the config paths
|
||||
source "$SCRIPTDIR/lib/paths.sh"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Get the scripts directory
|
||||
SCRIPTDIR=$(dirname `which $0`)
|
||||
SCRIPTDIR=$(dirname "$(which $0)")
|
||||
cd $SCRIPTDIR
|
||||
|
||||
# If there is a config generated, then $SCRIPTDIR/config/kernel_args
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue