diff options
author | Maxim Devaev <[email protected]> | 2022-06-24 16:05:10 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-06-24 16:05:10 +0300 |
commit | 9f4c2412049e21ed6d1bd0237ba1d98ea338f7bb (patch) | |
tree | 9e12351602400f60d4ac3406d0292effb5844c1e | |
parent | f8e90369860cadef10744d6c4fe98bea0fc6260b (diff) |
shellcheck
-rw-r--r-- | PKGBUILD | 1 | ||||
-rwxr-xr-x | scripts/kvmd-bootconfig | 29 | ||||
-rwxr-xr-x | scripts/kvmd-udev-hdmiusb-check | 2 | ||||
-rw-r--r-- | testenv/Dockerfile | 1 | ||||
-rw-r--r-- | testenv/tox.ini | 6 |
5 files changed, 23 insertions, 16 deletions
@@ -94,6 +94,7 @@ depends=( e2fsprogs openssh wpa_supplicant + run-parts # Misc hostapd diff --git a/scripts/kvmd-bootconfig b/scripts/kvmd-bootconfig index 16ccd593..5b968dee 100755 --- a/scripts/kvmd-bootconfig +++ b/scripts/kvmd-bootconfig @@ -23,7 +23,7 @@ set -ex -if [ `whoami` != root ]; then +if [ "$(whoami)" != root ]; then echo "Only root can do that" exit 1 fi @@ -39,6 +39,7 @@ fi if [ ! -f /boot/pikvm.txt ]; then exit 0 fi +# shellcheck disable=SC1090 source <(dos2unix < /boot/pikvm.txt) rw @@ -62,25 +63,27 @@ if [ -n "$FIRSTBOOT$FIRST_BOOT" ]; then kvmd-gencert --do-the-thing --vnc if grep -q 'X-kvmd\.otgmsd' /etc/fstab; then - part=`grep 'X-kvmd\.otgmsd' /etc/fstab | awk '{print $1}'` + part=$(grep 'X-kvmd\.otgmsd' /etc/fstab | awk '{print $1}') + # shellcheck disable=SC2206 splitted=(${part//=/ }) - if [ ${splitted[0]} == "LABEL" ]; then + if [ "${splitted[0]}" == LABEL ]; then label=${splitted[1]} - part=`blkid -c /dev/null -L $label` + part=$(blkid -c /dev/null -L "$label") else label=PIMSD fi unset splitted - disk=/dev/`lsblk -no pkname $part` - npart=`cat /sys/class/block/${part//\/dev\//}/partition` - umount $part - parted $disk -a optimal -s resizepart $npart 100% - yes | mkfs.ext4 -L $label -F -m 0 $part - mount $part + disk=/dev/$(lsblk -no pkname "$part") + npart=$(cat "/sys/class/block/${part//\/dev\//}/partition") + umount "$part" + parted "$disk" -a optimal -s resizepart "$npart" 100% + yes | mkfs.ext4 -L "$label" -F -m 0 "$part" + mount "$part" unset disk part npart label fi # fc-cache is required for installed X server + # shellcheck disable=SC2015 which fc-cache && fc-cache || true fi @@ -121,7 +124,7 @@ fi if [ -n "$WIFI_REGDOM" ]; then sed -i \ -e 's/^\(WIRELESS_REGDOM=.*\)$/#\1/' \ - -e 's/^#\(WIRELESS_REGDOM="'$WIFI_REGDOM'"\)/\1/' \ + -e 's/^#\(WIRELESS_REGDOM="'"$WIFI_REGDOM"'"\)/\1/' \ /etc/conf.d/wireless-regdom fi @@ -149,9 +152,7 @@ fi # ========== Custom scripts ========== if [ -d /boot/pikvm-scripts.d ]; then - for script in `ls /boot/pikvm-scripts.d | sort`; do - /boot/pikvm-scripts.d/"$script" || true - done + run-parts --regex='^.+$' /boot/pikvm-scripts.d || true fi diff --git a/scripts/kvmd-udev-hdmiusb-check b/scripts/kvmd-udev-hdmiusb-check index 350bbf10..db118e96 100755 --- a/scripts/kvmd-udev-hdmiusb-check +++ b/scripts/kvmd-udev-hdmiusb-check @@ -29,7 +29,7 @@ board="$1" port="$2" # https://gist.github.com/mdevaev/6eb65be689142e5ac16da7542f50830f -model="`tr < /proc/device-tree/model -d '\000'`" +model="$(tr < /proc/device-tree/model -d '\000')" case "$board" in "rpi2") diff --git a/testenv/Dockerfile b/testenv/Dockerfile index 36d0fb3a..874f84a0 100644 --- a/testenv/Dockerfile +++ b/testenv/Dockerfile @@ -60,6 +60,7 @@ RUN pacman --noconfirm --ask=4 -Syy \ socat \ eslint \ npm \ + shellcheck \ && (pacman -Sc --noconfirm || true) \ && rm -rf /var/cache/pacman/pkg/* diff --git a/testenv/tox.ini b/testenv/tox.ini index e0eb0d53..2e904e0e 100644 --- a/testenv/tox.ini +++ b/testenv/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint +envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint, shellcheck skipsdist = true [testenv] @@ -60,3 +60,7 @@ commands = eslint --cache-location=/tmp --config=testenv/linters/eslintrc.yaml - [testenv:htmlhint] whitelist_externals = htmlhint commands = htmlhint --config=testenv/linters/htmlhint.json web/*.html web/*/*.html + +[testenv:shellcheck] +whitelist_externals = bash +commands = bash -c 'shellcheck --color=always scripts/*' |