Browse Source

fix(dracut-systemd): shellcheck for modules.d/98dracut-systemd

master
Harald Hoyer 3 years ago committed by Harald Hoyer
parent
commit
7b584edac0
  1. 0
      modules.d/98dracut-systemd/.shchkdir
  2. 2
      modules.d/98dracut-systemd/dracut-cmdline-ask.sh
  3. 2
      modules.d/98dracut-systemd/dracut-cmdline.sh
  4. 6
      modules.d/98dracut-systemd/dracut-emergency.sh
  5. 25
      modules.d/98dracut-systemd/dracut-initqueue.sh
  6. 3
      modules.d/98dracut-systemd/dracut-mount.sh
  7. 2
      modules.d/98dracut-systemd/dracut-pre-udev.sh
  8. 12
      modules.d/98dracut-systemd/module-setup.sh
  9. 20
      modules.d/98dracut-systemd/rootfs-generator.sh

0
modules.d/98dracut-systemd/.shchkdir

2
modules.d/98dracut-systemd/dracut-cmdline-ask.sh

@ -14,7 +14,7 @@ echo @@ -14,7 +14,7 @@ echo
echo
echo
echo "Enter additional kernel command line parameter (end with ctrl-d or .)"
while read -e -p "> " line || [ -n "$line" ]; do
while read -r -e -p "> " line || [ -n "$line" ]; do
[ "$line" = "." ] && break
[ -n "$line" ] && printf -- "%s\n" "$line" >> /etc/cmdline.d/99-cmdline-ask.conf
done

2
modules.d/98dracut-systemd/dracut-cmdline.sh

@ -14,7 +14,7 @@ if ! getargbool 1 'rd.hostonly'; then @@ -14,7 +14,7 @@ if ! getargbool 1 'rd.hostonly'; then
[ -f /tmp/99-cmdline-ask.conf ] && mv /tmp/99-cmdline-ask.conf /etc/cmdline.d/99-cmdline-ask.conf
fi

info "Using kernel command line parameters:" $(getcmdline)
info "Using kernel command line parameters:" "$(getcmdline)"

getargbool 0 rd.udev.log-priority=info -d rd.udev.info -d -n -y rdudevinfo && echo 'udev_log="info"' >> /etc/udev/udev.conf
getargbool 0 rd.udev.log-priority=debug -d rd.udev.debug -d -n -y rdudevdebug && echo 'udev_log="debug"' >> /etc/udev/udev.conf

6
modules.d/98dracut-systemd/dracut-emergency.sh

@ -17,10 +17,10 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then @@ -17,10 +17,10 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
FSTXT="/run/dracut/fsck/fsck_help_$fstype.txt"
RDSOSREPORT="$(rdsosreport)"
source_hook "$hook"
while read _tty rest; do
while read -r _tty rest; do
(
echo
echo $RDSOSREPORT
echo "$RDSOSREPORT"
echo
echo
echo 'Entering emergency mode. Exit the shell to continue.'
@ -30,7 +30,7 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then @@ -30,7 +30,7 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
echo
echo
[ -f "$FSTXT" ] && cat "$FSTXT"
) > /dev/$_tty
) > /dev/"$_tty"
done < /proc/consoles
[ -f /etc/profile ] && . /etc/profile
[ -z "$PS1" ] && export PS1="$_name:\${PWD}# "

25
modules.d/98dracut-systemd/dracut-initqueue.sh

@ -23,25 +23,27 @@ while :; do @@ -23,25 +23,27 @@ while :; do

check_finished && break

udevadm settle --exit-if-exists=$hookdir/initqueue/work
udevadm settle --exit-if-exists="$hookdir"/initqueue/work

check_finished && break

if [ -f $hookdir/initqueue/work ]; then
if [ -f "$hookdir"/initqueue/work ]; then
rm -f -- "$hookdir/initqueue/work"
fi

for job in $hookdir/initqueue/*.sh; do
for job in "$hookdir"/initqueue/*.sh; do
[ -e "$job" ] || break
job=$job . $job
# shellcheck disable=SC2097 disable=SC1090 disable=SC2098
job=$job . "$job"
check_finished && break 2
done

udevadm settle --timeout=0 > /dev/null 2>&1 || continue

for job in $hookdir/initqueue/settled/*.sh; do
for job in "$hookdir"/initqueue/settled/*.sh; do
[ -e "$job" ] || break
job=$job . $job
# shellcheck disable=SC2097 disable=SC1090 disable=SC2098
job=$job . "$job"
check_finished && break 2
done

@ -56,16 +58,17 @@ while :; do @@ -56,16 +58,17 @@ while :; do

if [ $main_loop -gt $((2 * RDRETRY / 3)) ]; then
warn "dracut-initqueue: timeout, still waiting for following initqueue hooks:"
for _f in $hookdir/initqueue/finished/*.sh; do
for _f in "$hookdir"/initqueue/finished/*.sh; do
warn "$_f: \"$(cat "$_f")\""
done
if [ "$(ls -A $hookdir/initqueue/finished)" ]; then
if [ "$(ls -A "$hookdir"/initqueue/finished)" ]; then
warn "dracut-initqueue: starting timeout scripts"
for job in $hookdir/initqueue/timeout/*.sh; do
for job in "$hookdir"/initqueue/timeout/*.sh; do
[ -e "$job" ] || break
job=$job . $job
# shellcheck disable=SC2097 disable=SC1090 disable=SC2098
job=$job . "$job"
udevadm settle --timeout=0 > /dev/null 2>&1 || main_loop=0
[ -f $hookdir/initqueue/work ] && main_loop=0
[ -f "$hookdir"/initqueue/work ] && main_loop=0
[ $main_loop -eq 0 ] && break
done
fi

3
modules.d/98dracut-systemd/dracut-mount.sh

@ -18,7 +18,8 @@ while :; do @@ -18,7 +18,8 @@ while :; do
usable_root "$NEWROOT" && break
umount "$NEWROOT"
fi
for f in $hookdir/mount/*.sh; do
for f in "$hookdir"/mount/*.sh; do
# shellcheck disable=SC1090
[ -f "$f" ] && . "$f"
if ismounted "$NEWROOT"; then
usable_root "$NEWROOT" && break

2
modules.d/98dracut-systemd/dracut-pre-udev.sh

@ -26,7 +26,7 @@ for i in $(getargs rd.driver.pre -d rdloaddriver=); do @@ -26,7 +26,7 @@ for i in $(getargs rd.driver.pre -d rdloaddriver=); do
(
IFS=,
for p in $i; do
modprobe $p 2>&1 | vinfo
modprobe "$p" 2>&1 | vinfo
done
)
done

12
modules.d/98dracut-systemd/module-setup.sh

@ -19,11 +19,10 @@ installkernel() { @@ -19,11 +19,10 @@ installkernel() {

# called by dracut
install() {
local _mods
inst_script "$moddir/dracut-emergency.sh" /bin/dracut-emergency
inst_simple "$moddir/emergency.service" ${systemdsystemunitdir}/emergency.service
inst_simple "$moddir/dracut-emergency.service" ${systemdsystemunitdir}/dracut-emergency.service
inst_simple "$moddir/emergency.service" ${systemdsystemunitdir}/rescue.service
inst_simple "$moddir/emergency.service" "${systemdsystemunitdir}"/emergency.service
inst_simple "$moddir/dracut-emergency.service" "${systemdsystemunitdir}"/dracut-emergency.service
inst_simple "$moddir/emergency.service" "${systemdsystemunitdir}"/rescue.service

ln_r "${systemdsystemunitdir}/initrd.target" "${systemdsystemunitdir}/default.target"

@ -36,7 +35,7 @@ install() { @@ -36,7 +35,7 @@ install() {
inst_script "$moddir/dracut-mount.sh" /bin/dracut-mount
inst_script "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot

inst_script "$moddir/rootfs-generator.sh" $systemdutildir/system-generators/dracut-rootfs-generator
inst_script "$moddir/rootfs-generator.sh" "$systemdutildir"/system-generators/dracut-rootfs-generator

for i in \
dracut-cmdline.service \
@ -46,8 +45,7 @@ install() { @@ -46,8 +45,7 @@ install() {
dracut-pre-mount.service \
dracut-pre-pivot.service \
dracut-pre-trigger.service \
dracut-pre-udev.service \
${NULL}; do
dracut-pre-udev.service; do
inst_simple "$moddir/${i}" "$systemdsystemunitdir/${i}"
$SYSTEMCTL -q --root "$initdir" add-wants initrd.target "$i"
done

20
modules.d/98dracut-systemd/rootfs-generator.sh

@ -22,24 +22,24 @@ if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetu @@ -22,24 +22,24 @@ if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetu
fi
EOF
{
printf '[ -e "%s" ] || ' $1
printf 'warn "\"%s\" does not exist"\n' $1
printf '[ -e "%s" ] || ' "$1"
printf 'warn "\"%s\" does not exist"\n' "$1"
} >> "$hookdir/emergency/80-${_name}.sh"
fi

_name=$(dev_unit_name "$1")
if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/${_name}.device ]; then
if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/"${_name}".device ]; then
[ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants
ln -s ../${_name}.device "$GENERATOR_DIR"/initrd.target.wants/${_name}.device
ln -s ../"${_name}".device "$GENERATOR_DIR"/initrd.target.wants/"${_name}".device
fi

if ! [ -f "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then
mkdir -p "$GENERATOR_DIR"/${_name}.device.d
if ! [ -f "$GENERATOR_DIR"/"${_name}".device.d/timeout.conf ]; then
mkdir -p "$GENERATOR_DIR"/"${_name}".device.d
{
echo "[Unit]"
echo "JobTimeoutSec=$_timeout"
echo "JobRunningTimeoutSec=$_timeout"
} > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf
} > "$GENERATOR_DIR"/"${_name}".device.d/timeout.conf
fi
}

@ -77,12 +77,12 @@ generator_fsck_after_pre_mount() { @@ -77,12 +77,12 @@ generator_fsck_after_pre_mount() {
[ -z "$1" ] && return 0

_name=$(dev_unit_name "$1")
[ -d /run/systemd/generator/systemd-fsck@${_name}.service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@${_name}.service.d
if ! [ -f /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf ]; then
[ -d /run/systemd/generator/systemd-fsck@"${_name}".service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@"${_name}".service.d
if ! [ -f /run/systemd/generator/systemd-fsck@"${_name}".service.d/after-pre-mount.conf ]; then
{
echo "[Unit]"
echo "After=dracut-pre-mount.service"
} > /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf
} > /run/systemd/generator/systemd-fsck@"${_name}".service.d/after-pre-mount.conf
fi

}

Loading…
Cancel
Save