From 64e2fb483f6d4df8929af9ada31a72e218121f0e Mon Sep 17 00:00:00 2001 From: Phil Wise Date: Thu, 22 Jun 2017 12:15:21 +0200 Subject: Fix warnings from shellcheck shell linter --- recipes-sota/ostree-initrd/files/init.sh | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'recipes-sota/ostree-initrd/files') diff --git a/recipes-sota/ostree-initrd/files/init.sh b/recipes-sota/ostree-initrd/files/init.sh index 1814ca3..b88716c 100644 --- a/recipes-sota/ostree-initrd/files/init.sh +++ b/recipes-sota/ostree-initrd/files/init.sh @@ -1,17 +1,13 @@ #!/bin/sh - -# global variables - -SMACK=n -DEBUG=n +set -eu # ------------------------------------------- -log_info() { echo "$0[$$]: $@" >&2; } -log_error() { echo "$0[$$]: ERROR $@" >&2; } +log_info() { echo "$0[$$]: $*" >&2; } +log_error() { echo "$0[$$]: ERROR $*" >&2; } do_mount_fs() { - log_info "mounting FS: $@" + log_info "mounting FS: $*" [[ -e /proc/filesystems ]] && { grep -q "$1" /proc/filesystems || { log_error "Unknown filesystem"; return 1; } } [[ -d "$2" ]] || mkdir -p "$2" [[ -e /proc/mounts ]] && { grep -q -e "^$1 $2 $1" /proc/mounts && { log_info "$2 ($1) already mounted"; return 0; } } @@ -26,10 +22,10 @@ bail_out() { } get_ostree_sysroot() { - for opt in `cat /proc/cmdline`; do - arg=`echo $opt | cut -d'=' -f1` - if [ $arg == "ostree_root" ]; then - echo $opt | cut -d'=' -f2- + for opt in $(cat /proc/cmdline); do + arg=$(echo "$opt" | cut -d'=' -f1) + if [ "$arg" == "ostree_root" ]; then + echo "$opt" | cut -d'=' -f2- return fi done @@ -38,7 +34,7 @@ get_ostree_sysroot() { export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/ostree -log_info "starting initrd script" +log_info "Starting OSTree initrd script" do_mount_fs proc /proc do_mount_fs sysfs /sys @@ -50,8 +46,6 @@ do_mount_fs tmpfs /run # check if smack is active (and if so, mount smackfs) grep -q smackfs /proc/filesystems && { - SMACK=y - do_mount_fs smackfs /sys/fs/smackfs # adjust current label and network label @@ -69,7 +63,7 @@ ostree-prepare-root /sysroot cd /sysroot for x in dev proc; do log_info "Moving /$x to new rootfs" - mount -o move /$x $x + mount -o move "/$x" "$x" done # switch to new rootfs -- cgit v1.2.3-54-g00ecf