From 7fe88321e6456ad989354453b492f515e77fbfed Mon Sep 17 00:00:00 2001 From: Phil Date: Fri, 4 Mar 2022 00:37:46 +0000 Subject: [PATCH] Start some pacification of shellcheck not overly obsessive but focussing on safety --- lib/set_CMDLINE.sh | 10 +++++----- lib/set_MODULES.sh | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/set_CMDLINE.sh b/lib/set_CMDLINE.sh index 54268ed..da2277b 100755 --- a/lib/set_CMDLINE.sh +++ b/lib/set_CMDLINE.sh @@ -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 @@ -33,8 +33,8 @@ the required information that the QuickEMU project can hook into and use to add ###################################################################### #### In the future, when I have enough confirmation that this script works for other people. -#### This page will get replaced with a prompt asking if you want to apply the changes and make backups -#### of your current system config. +#### This page will get replaced with a prompt asking if you want to apply the changes and make backups +#### of your current system config. ###################################################################### " @@ -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 } diff --git a/lib/set_MODULES.sh b/lib/set_MODULES.sh index e3dbacc..dda523f 100755 --- a/lib/set_MODULES.sh +++ b/lib/set_MODULES.sh @@ -9,9 +9,9 @@ function set_MODULES () { # 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 " @@ -27,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"