Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: collection of fixes and resolution for shellcheck warnings #1172

Merged
merged 38 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a2bc3f8
fix(quickget): add daily-live to ubuntu-server
flexiondotorg May 6, 2024
ec43639
chore(quickget): remove obsolete daily check from ubuntu
flexiondotorg May 6, 2024
40385db
refactor: simplify get_tuxedo-os()
flexiondotorg May 6, 2024
6485c45
fix(shellcheck): add missing local variable in get_truenas-scale()
flexiondotorg May 6, 2024
2e4b8aa
style: add braces around variable names
flexiondotorg May 6, 2024
9023809
chore(quickget): remove obsolete logic for guix
flexiondotorg May 6, 2024
8f94fcf
chore(quickget): remove how-to from code; added to the wiki
flexiondotorg May 6, 2024
f39b730
docs: replace screenshot with asciinema
flexiondotorg May 7, 2024
2977078
style(quickget): drop shorthand arguments for consistency
flexiondotorg May 7, 2024
044a1c1
style: update help_message() to remove shorthand arguments
flexiondotorg May 7, 2024
44b4b2b
docs(README.md): update social links
flexiondotorg May 7, 2024
ea38677
docs(README.md): sign post the documentation for adding a new OS
flexiondotorg May 7, 2024
da01185
refactor(quickget): special case image processing shellcheck compliant
flexiondotorg May 7, 2024
b6c66e5
fix(quickget): make open_homepage() shellcheck compliant (SC2034)
flexiondotorg May 7, 2024
7415e8f
fix(quickget): correct shellcheck SC2076 warnings
flexiondotorg May 7, 2024
e1abe68
refactor(quickget): remove single use function error_not_supported_os()
flexiondotorg May 7, 2024
dec49fa
style(quickget): make not supported release and edition output consis…
flexiondotorg May 7, 2024
efeb726
refactor(quickget): remove unnecessary string literals
flexiondotorg May 7, 2024
188e88f
fix(quickget): disable shellcheck SC2317 for cleanup()
flexiondotorg May 7, 2024
b8bf99d
fix(quickget): make show_os_info() shellcheck compliant
flexiondotorg May 7, 2024
3146193
fix(quickget): make editions parsing shellcheck SC2207 compliant
flexiondotorg May 7, 2024
9418f9c
fix(quickget): disable shellcheck SC2207 warnings for ubuntu releases
flexiondotorg May 7, 2024
a51410f
fix(quickget): disable SC2317 as many functions are called indirectly
flexiondotorg May 7, 2024
7af6ee0
fix(quickemu): disable shellcheck SC2054 and SC2140 warning
flexiondotorg May 7, 2024
14ea71c
fix(quickemu): resolve shellcheck SC2155 warnings
flexiondotorg May 7, 2024
f0a3725
fix(quickemu): resolve shellcheck SC2206 warnings
flexiondotorg May 7, 2024
95e2d3c
fix(quickemu): resolve shellcheck SC2236
flexiondotorg May 7, 2024
076b194
fix(quickemu): resolve shellcheck SC2069 warnings
flexiondotorg May 7, 2024
2beef37
fix(quickemu): remove unused variable monitor_cmd SC2034
flexiondotorg May 7, 2024
cea933b
fix(quickemu): correct shellcheck SC2207 warnings
flexiondotorg May 7, 2024
11a8568
fix(quickget): resolve some shellcheck SC2086 notices
flexiondotorg May 7, 2024
5de87e7
fix(quickget): update get_manjaro() to support new sway release
flexiondotorg May 7, 2024
b0c07a6
fix(quickget): resolve shellcheck SC2004 notice
flexiondotorg May 7, 2024
837f401
fix(quickget): make --check work for releases and editions
flexiondotorg May 7, 2024
b76117a
style: correct AlmaLinux pretty name
flexiondotorg May 7, 2024
c628a42
style: correct Crunchbangplusplus pretty name
flexiondotorg May 7, 2024
926d4f6
style: correct HoloISO pretty name
flexiondotorg May 7, 2024
4f5dca1
chore: remove Whonix from os_info(); it doesn't have any generators
flexiondotorg May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .github/screenshot.png
Binary file not shown.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

**Quickly create and run optimised Windows, macOS and Linux virtual machines:**

<img src=".github/screenshot.png" alt="Quickemu Screenshot" />

**Made with 💝 for <img src=".github/tux.png" align="top" width="24" alt="Tux (Linux)"/>**

We have a Discord for this project:

[![Discord](https://img.shields.io/discord/712850672223125565?color=0C306A&label=WimpysWorld%20Discord&logo=Discord&logoColor=ffffff&style=flat-square)](https://discord.gg/sNmz3uw)
</div>
<p align="center">
&nbsp;<a href="https://wimpysworld.io/discord" target="_blank"><img alt="Discord" src="https://img.shields.io/discord/712850672223125565?style=for-the-badge&logo=discord&logoColor=%23ffffff&label=Discord&labelColor=%234253e8&color=%23e4e2e2"></a>&nbsp;
&nbsp;<a href="https://fosstodon.org/@wimpy" target="_blank"><img alt="Mastodon" src="https://img.shields.io/badge/Mastodon-6468fa?style=for-the-badge&logo=mastodon&logoColor=%23ffffff"></a>&nbsp;
&nbsp;<a href="https://twitter.com/m_wimpress" target="_blank"><img alt="Twitter" src="https://img.shields.io/badge/Twitter-303030?style=for-the-badge&logo=x&logoColor=%23ffffff"></a>&nbsp;
&nbsp;<a href="https://linkedin.com/in/martinwimpress" target="_blank"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-1667be?style=for-the-badge&logo=linkedin&logoColor=%23ffffff"></a>&nbsp;
</p>

# Introduction

Expand Down Expand Up @@ -85,6 +85,10 @@ quickemu --vm nixos-unstable.conf
- Execute `quickget` (with no arguments) to see a list of all the
supported operating systems.

## Demo

<div align="center"><a href="https://asciinema.org/a/658148?autoplay=1" target="_blank"><img src="https://asciinema.org/a/658148.svg" /></a></div>

# Documentation

The wiki describes how to get up and running with Quickemu and also
Expand Down Expand Up @@ -129,6 +133,7 @@ We welcome contributions to Quickemu.
- Submit [Quickemu Pull
requests](https://github.com/quickemu-project/quickemu/pulls) to fix
bugs 🐞 or add new features ✨
- Follow our [guide to adding a new OS to quickget](https://github.com/quickemu-project/quickemu/wiki/06-Advanced-quickget-features#adding-a-new-os-to-quickget)
- Commit messages must [conform to the Conventional Commits
specification](https://www.conventionalcommits.org/).
specification](https://www.conventionalcommits.org/)
- [Sponsor the project](https://github.com/sponsors/flexiondotorg) 💖
55 changes: 38 additions & 17 deletions quickemu
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ function vm_boot() {
local OSK=""
local SOUND=""
local SMM="${SMM:-off}"
local TEMP_PORT=""
local USB_HOST_PASSTHROUGH_CONTROLLER="qemu-xhci"
local VGA=""
local VIDEO=""
Expand Down Expand Up @@ -400,6 +401,7 @@ function vm_boot() {
if [ -n "${EFI_CODE}" ] || [ ! -e "${EFI_CODE}" ]; then
case ${secureboot} in
on)
# shellcheck disable=SC2054,SC2140
ovmfs=("/usr/share/OVMF/OVMF_CODE_4M.secboot.fd","/usr/share/OVMF/OVMF_VARS_4M.fd" \
"/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd","/usr/share/edk2/ovmf/OVMF_VARS.fd" \
"/usr/share/OVMF/x64/OVMF_CODE.secboot.fd","/usr/share/OVMF/x64/OVMF_VARS.fd" \
Expand All @@ -410,6 +412,7 @@ function vm_boot() {
)
;;
*)
# shellcheck disable=SC2054,SC2140
ovmfs=("/usr/share/OVMF/OVMF_CODE_4M.fd","/usr/share/OVMF/OVMF_VARS_4M.fd" \
"/usr/share/edk2/ovmf/OVMF_CODE.fd","/usr/share/edk2/ovmf/OVMF_VARS.fd" \
"/usr/share/OVMF/OVMF_CODE.fd","/usr/share/OVMF/OVMF_VARS.fd" \
Expand Down Expand Up @@ -443,7 +446,7 @@ function vm_boot() {
echo " Please install OVMF firmware."
exit 1
fi
if [ ! -z "${EFI_EXTRA_VARS}" ]; then
if [ -n "${EFI_EXTRA_VARS}" ]; then
if [ ! -e "${EFI_EXTRA_VARS}" ]; then
echo " - EFI: ERROR! EFI_EXTRA_VARS file ${EFI_EXTRA_VARS} does not exist."
exit 1
Expand Down Expand Up @@ -992,7 +995,8 @@ function vm_boot() {

# Only enable SPICE is using SPICE display
if [ "${OUTPUT}" == "none" ] || [ "${OUTPUT}" == "spice" ] || [ "${OUTPUT}" == "spice-app" ]; then
args+=(-spice ${SPICE}
# shellcheck disable=SC2054
args+=(-spice "${SPICE}"
-device virtio-serial-pci
-chardev socket,id=agent0,path="${VMDIR}/${VMNAME}-agent.sock",server=on,wait=off
-device virtserialport,chardev=agent0,name=org.qemu.guest_agent.0
Expand All @@ -1002,9 +1006,10 @@ function vm_boot() {
-device virtserialport,chardev=webdav0,name=org.spice-space.webdav.0)
fi

# shellcheck disable=SC2054
args+=(-device virtio-rng-pci,rng=rng0
-object rng-random,id=rng0,filename=/dev/urandom
-device ${USB_HOST_PASSTHROUGH_CONTROLLER},id=spicepass
-device "${USB_HOST_PASSTHROUGH_CONTROLLER}",id=spicepass
-chardev spicevmc,id=usbredirchardev1,name=usbredir
-device usb-redir,chardev=usbredirchardev1,id=usbredirdev1
-chardev spicevmc,id=usbredirchardev2,name=usbredir
Expand All @@ -1016,6 +1021,7 @@ function vm_boot() {
)

if "${QEMU}" -chardev spicevmc,id=ccid,name= 2>&1 | grep -q smartcard; then
# shellcheck disable=SC2054
args+=(-chardev spicevmc,id=ccid,name=smartcard
-device ccid-card-passthru,chardev=ccid)
else
Expand All @@ -1025,8 +1031,10 @@ function vm_boot() {
# setup usb-controller
[ -z "${USB_CONTROLLER}" ] && USB_CONTROLLER="$usb_controller"
if [ "${USB_CONTROLLER}" == "ehci" ]; then
# shellcheck disable=SC2054
args+=(-device usb-ehci,id=input)
elif [ "${USB_CONTROLLER}" == "xhci" ]; then
# shellcheck disable=SC2054
args+=(-device qemu-xhci,id=input)
elif [ -z "${USB_CONTROLLER}" ] || [ "${USB_CONTROLLER}" == "none" ]; then
# add nothing
Expand All @@ -1039,8 +1047,10 @@ function vm_boot() {
# @INFO: must be set after usb-controller
[ -z "${KEYBOARD}" ] && KEYBOARD="$keyboard"
if [ "${KEYBOARD}" == "usb" ]; then
# shellcheck disable=SC2054
args+=(-device usb-kbd,bus=input.0)
elif [ "${KEYBOARD}" == "virtio" ]; then
# shellcheck disable=SC2054
args+=(-device virtio-keyboard)
elif [ "${KEYBOARD}" == "ps2" ] || [ -z "${KEYBOARD}" ]; then
# add nothing, default is ps/2 keyboard
Expand All @@ -1053,7 +1063,7 @@ function vm_boot() {
# @INFO: When using the VNC display, you must use the -k parameter to set the keyboard layout if you are not using en-us.
[ -z "${KEYBOARD_LAYOUT}" ] && KEYBOARD_LAYOUT="$keyboard_layout"
if [ -n "${KEYBOARD_LAYOUT}" ]; then
args+=(-k ${KEYBOARD_LAYOUT})
args+=(-k "${KEYBOARD_LAYOUT}")
fi

# FIXME: Check for device availability. qemu will fail to start otherwise
Expand All @@ -1067,10 +1077,13 @@ function vm_boot() {
# @INFO: must be set after usb-controller
[ -z "${MOUSE}" ] && MOUSE="$mouse"
if [ "${MOUSE}" == "usb" ]; then
# shellcheck disable=SC2054
args+=(-device usb-mouse,bus=input.0)
elif [ "${MOUSE}" == "tablet" ]; then
# shellcheck disable=SC2054
args+=(-device usb-tablet,bus=input.0)
elif [ "${MOUSE}" == "virtio" ]; then
# shellcheck disable=SC2054
args+=(-device virtio-mouse)
elif [ "${MOUSE}" == "ps2" ] || [ -z "${MOUSE}" ]; then
# add nothing, default is ps/2 mouse
Expand Down Expand Up @@ -1189,6 +1202,7 @@ function vm_boot() {
args+=(-drive if=ide,index=0,media=disk,file="${disk_img}")

elif [ "${guest_os}" == "windows-server" ]; then
# shellcheck disable=SC2054,SC2206
args+=(-device ide-hd,drive=SystemDisk
-drive id=SystemDisk,if=none,format=qcow2,file="${disk_img}" ${STATUS_QUO})

Expand Down Expand Up @@ -1239,16 +1253,18 @@ function vm_boot() {
echo " - Monitor: (off)"
elif [ "${MONITOR}" == "telnet" ]; then
# Find a free port to expose monitor-telnet to the guest
local temp_port="$(get_port ${MONITOR_TELNET_PORT} 9)"
if [ -z "${temp_port}" ]; then
TEMP_PORT="$(get_port ${MONITOR_TELNET_PORT} 9)"
if [ -z "${TEMP_PORT}" ]; then
echo " - Monitor: All Monitor-Telnet ports have been exhausted."
else
MONITOR_TELNET_PORT="${temp_port}"
args+=(-monitor telnet:${MONITOR_TELNET_HOST}:${MONITOR_TELNET_PORT},server,nowait)
MONITOR_TELNET_PORT="${TEMP_PORT}"
# shellcheck disable=SC2054
args+=(-monitor telnet:"${MONITOR_TELNET_HOST}:${MONITOR_TELNET_PORT}",server,nowait)
echo " - Monitor: On host: telnet ${MONITOR_TELNET_HOST} ${MONITOR_TELNET_PORT}"
echo "monitor-telnet,${MONITOR_TELNET_PORT},${MONITOR_TELNET_HOST}" >> "${VMDIR}/${VMNAME}.ports"
fi
elif [ "${MONITOR}" == "socket" ]; then
# shellcheck disable=SC2054,SC2206
args+=(-monitor unix:${VM_MONITOR_SOCKETPATH},server,nowait)
echo " - Monitor: On host: nc -U \"${VM_MONITOR_SOCKETPATH}\""
echo " or : socat -,echo=0,icanon=0 unix-connect:${VM_MONITOR_SOCKETPATH}"
Expand Down Expand Up @@ -1276,16 +1292,18 @@ function vm_boot() {
args+=(-serial none)
elif [ "${SERIAL}" == "telnet" ]; then
# Find a free port to expose serial-telnet to the guest
local temp_port="$(get_port ${SERIAL_TELNET_PORT} 9)"
if [ -z "${temp_port}" ]; then
TEMP_PORT="$(get_port ${SERIAL_TELNET_PORT} 9)"
if [ -z "${TEMP_PORT}" ]; then
echo " - Serial: All Serial-Telnet ports have been exhausted."
else
SERIAL_TELNET_PORT="${temp_port}"
SERIAL_TELNET_PORT="${TEMP_PORT}"
# shellcheck disable=SC2054,SC2206
args+=(-serial telnet:${SERIAL_TELNET_HOST}:${SERIAL_TELNET_PORT},server,nowait)
echo " - Serial: On host: telnet ${SERIAL_TELNET_HOST} ${SERIAL_TELNET_PORT}"
echo "serial-telnet,${SERIAL_TELNET_PORT},${SERIAL_TELNET_HOST}" >> "${VMDIR}/${VMNAME}.ports"
fi
elif [ "${SERIAL}" == "socket" ]; then
# shellcheck disable=SC2054,SC2206
args+=(-serial unix:${VM_SERIAL_SOCKETPATH},server,nowait)
echo " - Serial: On host: nc -U \"${VM_SERIAL_SOCKETPATH}\""
echo " or : socat -,echo=0,icanon=0 unix-connect:${VM_SERIAL_SOCKETPATH}"
Expand All @@ -1298,6 +1316,7 @@ function vm_boot() {
EXTRA_ARGS="${extra_args}"
fi
if [ -n "${EXTRA_ARGS}" ]; then
# shellcheck disable=SC2206
args+=(${EXTRA_ARGS})
fi

Expand Down Expand Up @@ -1468,9 +1487,12 @@ function parse_ports_from_file {
local FILE="${VMDIR}/${VMNAME}.ports"

# parse ports
local port_name=( $(cat "$FILE" | cut -d, -f1) )
local port_number=( $(cat "$FILE" | cut -d, -f2) )
local host_name=( $(cat "$FILE" | gawk 'FS="," {print $3,"."}') )
# shellcheck disable=SC2207
local port_name=( $(cat "${FILE}" | cut -d',' -f 1) )
# shellcheck disable=SC2207
local port_number=( $(cat "${FILE}" | cut -d',' -f 2) )
# shellcheck disable=SC2207
local host_name=( $(cat "${FILE}" | gawk 'FS="," {print $3,"."}') )

for ((i=0; i<${#port_name[@]}; i++)); do
if [ "${port_name[$i]}" == "ssh" ]; then
Expand Down Expand Up @@ -1562,7 +1584,6 @@ public_dir=""
monitor="socket"
monitor_telnet_port="4440"
monitor_telnet_host="localhost"
monitor_cmd=""
serial="socket"
serial_telnet_port="6660"
serial_telnet_host="localhost"
Expand Down Expand Up @@ -1675,7 +1696,7 @@ else
shift
shift;;
-screenpct|--screenpct)
if [ ! -z "${2##*[!0-9]*}" ] ; then
if [ -n "${2##*[!0-9]*}" ] ; then
if [[ ${2} -ge 25 && ${2} -lt 100 ]] ; then
SCREENPCT=${2}
else
Expand Down Expand Up @@ -1924,7 +1945,7 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then
VM_UP=0
if [ -r "${VMDIR}/${VMNAME}.pid" ]; then
VM_PID=$(head -c50 "${VMDIR}/${VMNAME}.pid")
kill -0 ${VM_PID} 2>&1 >/dev/null
kill -0 ${VM_PID} > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "VM already started!"
VM_UP=1
Expand Down
Loading