shellcheck

This commit is contained in:
Maxim Devaev 2022-06-24 16:05:10 +03:00
parent f8e9036986
commit 9f4c241204
5 changed files with 23 additions and 16 deletions

View File

@ -94,6 +94,7 @@ depends=(
e2fsprogs e2fsprogs
openssh openssh
wpa_supplicant wpa_supplicant
run-parts
# Misc # Misc
hostapd hostapd

View File

@ -23,7 +23,7 @@
set -ex set -ex
if [ `whoami` != root ]; then if [ "$(whoami)" != root ]; then
echo "Only root can do that" echo "Only root can do that"
exit 1 exit 1
fi fi
@ -39,6 +39,7 @@ fi
if [ ! -f /boot/pikvm.txt ]; then if [ ! -f /boot/pikvm.txt ]; then
exit 0 exit 0
fi fi
# shellcheck disable=SC1090
source <(dos2unix < /boot/pikvm.txt) source <(dos2unix < /boot/pikvm.txt)
rw rw
@ -62,25 +63,27 @@ if [ -n "$FIRSTBOOT$FIRST_BOOT" ]; then
kvmd-gencert --do-the-thing --vnc kvmd-gencert --do-the-thing --vnc
if grep -q 'X-kvmd\.otgmsd' /etc/fstab; then 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//=/ }) splitted=(${part//=/ })
if [ ${splitted[0]} == "LABEL" ]; then if [ "${splitted[0]}" == LABEL ]; then
label=${splitted[1]} label=${splitted[1]}
part=`blkid -c /dev/null -L $label` part=$(blkid -c /dev/null -L "$label")
else else
label=PIMSD label=PIMSD
fi fi
unset splitted unset splitted
disk=/dev/`lsblk -no pkname $part` disk=/dev/$(lsblk -no pkname "$part")
npart=`cat /sys/class/block/${part//\/dev\//}/partition` npart=$(cat "/sys/class/block/${part//\/dev\//}/partition")
umount $part umount "$part"
parted $disk -a optimal -s resizepart $npart 100% parted "$disk" -a optimal -s resizepart "$npart" 100%
yes | mkfs.ext4 -L $label -F -m 0 $part yes | mkfs.ext4 -L "$label" -F -m 0 "$part"
mount $part mount "$part"
unset disk part npart label unset disk part npart label
fi fi
# fc-cache is required for installed X server # fc-cache is required for installed X server
# shellcheck disable=SC2015
which fc-cache && fc-cache || true which fc-cache && fc-cache || true
fi fi
@ -121,7 +124,7 @@ fi
if [ -n "$WIFI_REGDOM" ]; then if [ -n "$WIFI_REGDOM" ]; then
sed -i \ sed -i \
-e 's/^\(WIRELESS_REGDOM=.*\)$/#\1/' \ -e 's/^\(WIRELESS_REGDOM=.*\)$/#\1/' \
-e 's/^#\(WIRELESS_REGDOM="'$WIFI_REGDOM'"\)/\1/' \ -e 's/^#\(WIRELESS_REGDOM="'"$WIFI_REGDOM"'"\)/\1/' \
/etc/conf.d/wireless-regdom /etc/conf.d/wireless-regdom
fi fi
@ -149,9 +152,7 @@ fi
# ========== Custom scripts ========== # ========== Custom scripts ==========
if [ -d /boot/pikvm-scripts.d ]; then if [ -d /boot/pikvm-scripts.d ]; then
for script in `ls /boot/pikvm-scripts.d | sort`; do run-parts --regex='^.+$' /boot/pikvm-scripts.d || true
/boot/pikvm-scripts.d/"$script" || true
done
fi fi

View File

@ -29,7 +29,7 @@ board="$1"
port="$2" port="$2"
# https://gist.github.com/mdevaev/6eb65be689142e5ac16da7542f50830f # 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 case "$board" in
"rpi2") "rpi2")

View File

@ -60,6 +60,7 @@ RUN pacman --noconfirm --ask=4 -Syy \
socat \ socat \
eslint \ eslint \
npm \ npm \
shellcheck \
&& (pacman -Sc --noconfirm || true) \ && (pacman -Sc --noconfirm || true) \
&& rm -rf /var/cache/pacman/pkg/* && rm -rf /var/cache/pacman/pkg/*

View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint, shellcheck
skipsdist = true skipsdist = true
[testenv] [testenv]
@ -60,3 +60,7 @@ commands = eslint --cache-location=/tmp --config=testenv/linters/eslintrc.yaml -
[testenv:htmlhint] [testenv:htmlhint]
whitelist_externals = htmlhint whitelist_externals = htmlhint
commands = htmlhint --config=testenv/linters/htmlhint.json web/*.html web/*/*.html commands = htmlhint --config=testenv/linters/htmlhint.json web/*.html web/*/*.html
[testenv:shellcheck]
whitelist_externals = bash
commands = bash -c 'shellcheck --color=always scripts/*'