diff options
author | Phil Wise <phil@advancedtelematic.com> | 2017-06-22 12:15:21 +0200 |
---|---|---|
committer | Phil Wise <phil@advancedtelematic.com> | 2017-06-22 12:19:56 +0200 |
commit | 64e2fb483f6d4df8929af9ada31a72e218121f0e (patch) | |
tree | eaeba64aefcd48675f6805a2701bd851d66c2792 /recipes-sota/ostree-initrd | |
parent | ae8a5db4668b153baa1b4aaf814f2cdd685e6466 (diff) | |
download | meta-updater-64e2fb483f6d4df8929af9ada31a72e218121f0e.tar.gz |
Fix warnings from shellcheck shell linter
Diffstat (limited to 'recipes-sota/ostree-initrd')
-rw-r--r-- | recipes-sota/ostree-initrd/files/init.sh | 26 |
1 files changed, 10 insertions, 16 deletions
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 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | set -eu | |
3 | # global variables | ||
4 | |||
5 | SMACK=n | ||
6 | DEBUG=n | ||
7 | 3 | ||
8 | # ------------------------------------------- | 4 | # ------------------------------------------- |
9 | 5 | ||
10 | log_info() { echo "$0[$$]: $@" >&2; } | 6 | log_info() { echo "$0[$$]: $*" >&2; } |
11 | log_error() { echo "$0[$$]: ERROR $@" >&2; } | 7 | log_error() { echo "$0[$$]: ERROR $*" >&2; } |
12 | 8 | ||
13 | do_mount_fs() { | 9 | do_mount_fs() { |
14 | log_info "mounting FS: $@" | 10 | log_info "mounting FS: $*" |
15 | [[ -e /proc/filesystems ]] && { grep -q "$1" /proc/filesystems || { log_error "Unknown filesystem"; return 1; } } | 11 | [[ -e /proc/filesystems ]] && { grep -q "$1" /proc/filesystems || { log_error "Unknown filesystem"; return 1; } } |
16 | [[ -d "$2" ]] || mkdir -p "$2" | 12 | [[ -d "$2" ]] || mkdir -p "$2" |
17 | [[ -e /proc/mounts ]] && { grep -q -e "^$1 $2 $1" /proc/mounts && { log_info "$2 ($1) already mounted"; return 0; } } | 13 | [[ -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() { | |||
26 | } | 22 | } |
27 | 23 | ||
28 | get_ostree_sysroot() { | 24 | get_ostree_sysroot() { |
29 | for opt in `cat /proc/cmdline`; do | 25 | for opt in $(cat /proc/cmdline); do |
30 | arg=`echo $opt | cut -d'=' -f1` | 26 | arg=$(echo "$opt" | cut -d'=' -f1) |
31 | if [ $arg == "ostree_root" ]; then | 27 | if [ "$arg" == "ostree_root" ]; then |
32 | echo $opt | cut -d'=' -f2- | 28 | echo "$opt" | cut -d'=' -f2- |
33 | return | 29 | return |
34 | fi | 30 | fi |
35 | done | 31 | done |
@@ -38,7 +34,7 @@ get_ostree_sysroot() { | |||
38 | 34 | ||
39 | export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/ostree | 35 | export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/ostree |
40 | 36 | ||
41 | log_info "starting initrd script" | 37 | log_info "Starting OSTree initrd script" |
42 | 38 | ||
43 | do_mount_fs proc /proc | 39 | do_mount_fs proc /proc |
44 | do_mount_fs sysfs /sys | 40 | do_mount_fs sysfs /sys |
@@ -50,8 +46,6 @@ do_mount_fs tmpfs /run | |||
50 | 46 | ||
51 | # check if smack is active (and if so, mount smackfs) | 47 | # check if smack is active (and if so, mount smackfs) |
52 | grep -q smackfs /proc/filesystems && { | 48 | grep -q smackfs /proc/filesystems && { |
53 | SMACK=y | ||
54 | |||
55 | do_mount_fs smackfs /sys/fs/smackfs | 49 | do_mount_fs smackfs /sys/fs/smackfs |
56 | 50 | ||
57 | # adjust current label and network label | 51 | # adjust current label and network label |
@@ -69,7 +63,7 @@ ostree-prepare-root /sysroot | |||
69 | cd /sysroot | 63 | cd /sysroot |
70 | for x in dev proc; do | 64 | for x in dev proc; do |
71 | log_info "Moving /$x to new rootfs" | 65 | log_info "Moving /$x to new rootfs" |
72 | mount -o move /$x $x | 66 | mount -o move "/$x" "$x" |
73 | done | 67 | done |
74 | 68 | ||
75 | # switch to new rootfs | 69 | # switch to new rootfs |