diff options
| author | Andrei Gherzan <andrei@gherzan.ro> | 2020-07-24 18:12:04 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-07-27 10:37:58 +0100 |
| commit | 383b86e921b46635752cb80c6d1f43db08e4e90f (patch) | |
| tree | 1a0e9b9e1ac8de45abe9e87bef866833f6d39a7c | |
| parent | c1a56579ff9c435a49114b15f54c2f481f7d928a (diff) | |
| download | poky-383b86e921b46635752cb80c6d1f43db08e4e90f.tar.gz | |
initscripts: Fix various shellcheck warnings in populate-volatile.sh
(From OE-Core rev: 0a128a238f63d52aa82f8c63ee2f84ab528b3346)
Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rwxr-xr-x | meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh index 1c525b71bd..3a265329f0 100755 --- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh | |||
| @@ -9,10 +9,10 @@ | |||
| 9 | ### END INIT INFO | 9 | ### END INIT INFO |
| 10 | 10 | ||
| 11 | # Get ROOT_DIR | 11 | # Get ROOT_DIR |
| 12 | DIRNAME=`dirname $0` | 12 | DIRNAME="$(dirname "$0")" |
| 13 | ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'` | 13 | ROOT_DIR="$(echo "$DIRNAME" | sed -ne 's:/etc/.*::p')" |
| 14 | 14 | ||
| 15 | [ -e ${ROOT_DIR}/etc/default/rcS ] && . ${ROOT_DIR}/etc/default/rcS | 15 | [ -e "${ROOT_DIR}/etc/default/rcS" ] && . "${ROOT_DIR}/etc/default/rcS" |
| 16 | # When running populate-volatile.sh at rootfs time, disable cache. | 16 | # When running populate-volatile.sh at rootfs time, disable cache. |
| 17 | [ -n "$ROOT_DIR" ] && VOLATILE_ENABLE_CACHE=no | 17 | [ -n "$ROOT_DIR" ] && VOLATILE_ENABLE_CACHE=no |
| 18 | # If rootfs is read-only, disable cache. | 18 | # If rootfs is read-only, disable cache. |
| @@ -46,13 +46,13 @@ create_file() { | |||
| 46 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." | 46 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." |
| 47 | } || { | 47 | } || { |
| 48 | if [ -z "$ROOT_DIR" ]; then | 48 | if [ -z "$ROOT_DIR" ]; then |
| 49 | eval $EXEC | 49 | eval "$EXEC" |
| 50 | else | 50 | else |
| 51 | # Creating some files at rootfs time may fail and should fail, | 51 | # Creating some files at rootfs time may fail and should fail, |
| 52 | # but these failures should not be logged to make sure the do_rootfs | 52 | # but these failures should not be logged to make sure the do_rootfs |
| 53 | # process doesn't fail. This does no harm, as this script will | 53 | # process doesn't fail. This does no harm, as this script will |
| 54 | # run on target to set up the correct files and directories. | 54 | # run on target to set up the correct files and directories. |
| 55 | eval $EXEC > /dev/null 2>&1 | 55 | eval "$EXEC" > /dev/null 2>&1 |
| 56 | fi | 56 | fi |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| @@ -68,11 +68,11 @@ mk_dir() { | |||
| 68 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." | 68 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." |
| 69 | } || { | 69 | } || { |
| 70 | if [ -z "$ROOT_DIR" ]; then | 70 | if [ -z "$ROOT_DIR" ]; then |
| 71 | eval $EXEC | 71 | eval "$EXEC" |
| 72 | else | 72 | else |
| 73 | # For the same reason with create_file(), failures should | 73 | # For the same reason with create_file(), failures should |
| 74 | # not be logged. | 74 | # not be logged. |
| 75 | eval $EXEC > /dev/null 2>&1 | 75 | eval "$EXEC" > /dev/null 2>&1 |
| 76 | fi | 76 | fi |
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| @@ -96,11 +96,11 @@ link_file() { | |||
| 96 | test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build | 96 | test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build |
| 97 | 97 | ||
| 98 | if [ -z "$ROOT_DIR" ]; then | 98 | if [ -z "$ROOT_DIR" ]; then |
| 99 | eval $EXEC | 99 | eval "$EXEC" |
| 100 | else | 100 | else |
| 101 | # For the same reason with create_file(), failures should | 101 | # For the same reason with create_file(), failures should |
| 102 | # not be logged. | 102 | # not be logged. |
| 103 | eval $EXEC > /dev/null 2>&1 | 103 | eval "$EXEC" > /dev/null 2>&1 |
| 104 | fi | 104 | fi |
| 105 | } | 105 | } |
| 106 | 106 | ||
| @@ -117,11 +117,11 @@ check_requirements() { | |||
| 117 | TMP_DEFINED="${TMPROOT}/tmpdefined.$$" | 117 | TMP_DEFINED="${TMPROOT}/tmpdefined.$$" |
| 118 | TMP_COMBINED="${TMPROOT}/tmpcombined.$$" | 118 | TMP_COMBINED="${TMPROOT}/tmpcombined.$$" |
| 119 | 119 | ||
| 120 | sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/passwd | sort | uniq > "${TMP_DEFINED}" | 120 | sed 's@\(^:\)*:.*@\1@' "${ROOT_DIR}/etc/passwd" | sort | uniq > "${TMP_DEFINED}" |
| 121 | cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 2 > "${TMP_INTERMED}" | 121 | grep -v "^#" "${CFGFILE}" | cut -s -d " " -f 2 > "${TMP_INTERMED}" |
| 122 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" | 122 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" |
| 123 | NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`" | 123 | NR_DEFINED_USERS="$(wc -l < "${TMP_DEFINED}")" |
| 124 | NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`" | 124 | NR_COMBINED_USERS="$(wc -l < "${TMP_COMBINED}")" |
| 125 | 125 | ||
| 126 | [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && { | 126 | [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && { |
| 127 | echo "Undefined users:" | 127 | echo "Undefined users:" |
| @@ -131,12 +131,12 @@ check_requirements() { | |||
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/group | sort | uniq > "${TMP_DEFINED}" | 134 | sed 's@\(^:\)*:.*@\1@' "${ROOT_DIR}/etc/group" | sort | uniq > "${TMP_DEFINED}" |
| 135 | cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 3 > "${TMP_INTERMED}" | 135 | grep -v "^#" "${CFGFILE}" | cut -s -d " " -f 3 > "${TMP_INTERMED}" |
| 136 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" | 136 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" |
| 137 | 137 | ||
| 138 | NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`" | 138 | NR_DEFINED_GROUPS="$(wc -l < "${TMP_DEFINED}")" |
| 139 | NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`" | 139 | NR_COMBINED_GROUPS="$(wc -l < "${TMP_COMBINED}")" |
| 140 | 140 | ||
| 141 | [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && { | 141 | [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && { |
| 142 | echo "Undefined groups:" | 142 | echo "Undefined groups:" |
| @@ -157,13 +157,13 @@ apply_cfgfile() { | |||
| 157 | 157 | ||
| 158 | [ "${VERBOSE}" != "no" ] && echo "Applying ${CFGFILE}" | 158 | [ "${VERBOSE}" != "no" ] && echo "Applying ${CFGFILE}" |
| 159 | 159 | ||
| 160 | [ "${SKIP_REQUIREMENTS}" == "yes" ] || check_requirements "${CFGFILE}" || { | 160 | [ "${SKIP_REQUIREMENTS}" = "yes" ] || check_requirements "${CFGFILE}" || { |
| 161 | echo "Skipping ${CFGFILE}" | 161 | echo "Skipping ${CFGFILE}" |
| 162 | return 1 | 162 | return 1 |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | cat ${CFGFILE} | sed 's/#.*//' | \ | 165 | sed 's/#.*//' "${CFGFILE}" | \ |
| 166 | while read TTYPE TUSER TGROUP TMODE TNAME TLTARGET; do | 166 | while read -r TTYPE TUSER TGROUP TMODE TNAME TLTARGET; do |
| 167 | test -z "${TLTARGET}" && continue | 167 | test -z "${TLTARGET}" && continue |
| 168 | TNAME=${ROOT_DIR}${TNAME} | 168 | TNAME=${ROOT_DIR}${TNAME} |
| 169 | [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." | 169 | [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." |
| @@ -187,9 +187,9 @@ apply_cfgfile() { | |||
| 187 | 187 | ||
| 188 | [ -L "${TNAME}" ] && { | 188 | [ -L "${TNAME}" ] && { |
| 189 | [ "${VERBOSE}" != "no" ] && echo "Found link." | 189 | [ "${VERBOSE}" != "no" ] && echo "Found link." |
| 190 | NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'` | 190 | NEWNAME=$(ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/') |
| 191 | echo ${NEWNAME} | grep -v "^/" >/dev/null && { | 191 | echo "${NEWNAME}" | grep -v "^/" >/dev/null && { |
| 192 | TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}" | 192 | TNAME="$(echo "${TNAME}" | sed -e 's@\(.*\)/.*@\1@')/${NEWNAME}" |
| 193 | [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-." | 193 | [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-." |
| 194 | } || { | 194 | } || { |
| 195 | TNAME="${NEWNAME}" | 195 | TNAME="${NEWNAME}" |
| @@ -217,7 +217,7 @@ apply_cfgfile() { | |||
| 217 | 217 | ||
| 218 | clearcache=0 | 218 | clearcache=0 |
| 219 | exec 9</proc/cmdline | 219 | exec 9</proc/cmdline |
| 220 | while read line <&9 | 220 | while read -r line <&9 |
| 221 | do | 221 | do |
| 222 | case "$line" in | 222 | case "$line" in |
| 223 | *clearcache*) clearcache=1 | 223 | *clearcache*) clearcache=1 |
| @@ -228,11 +228,11 @@ do | |||
| 228 | done | 228 | done |
| 229 | exec 9>&- | 229 | exec 9>&- |
| 230 | 230 | ||
| 231 | if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" | 231 | if test -e "${ROOT_DIR}/etc/volatile.cache" -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" |
| 232 | then | 232 | then |
| 233 | sh ${ROOT_DIR}/etc/volatile.cache | 233 | sh "${ROOT_DIR}/etc/volatile.cache" |
| 234 | else | 234 | else |
| 235 | rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build | 235 | rm -f "${ROOT_DIR}/etc/volatile.cache" "${ROOT_DIR}/etc/volatile.cache.build" |
| 236 | 236 | ||
| 237 | # Apply the core file with out checking requirements. ${TMPROOT} is | 237 | # Apply the core file with out checking requirements. ${TMPROOT} is |
| 238 | # needed by check_requirements but is setup by this file, so it must be | 238 | # needed by check_requirements but is setup by this file, so it must be |
| @@ -246,7 +246,7 @@ else | |||
| 246 | TMP_FILE="${TMPROOT}/tmp_volatile.$$" | 246 | TMP_FILE="${TMPROOT}/tmp_volatile.$$" |
| 247 | rm -f "$TMP_FILE" | 247 | rm -f "$TMP_FILE" |
| 248 | 248 | ||
| 249 | CFGFILES="`ls -1 "${CFGDIR}" | grep -v "^${COREDEF}\$" | sort`" | 249 | CFGFILES="$(ls -1 "${CFGDIR}" | grep -v "^${COREDEF}\$" | sort)" |
| 250 | for file in ${CFGFILES}; do | 250 | for file in ${CFGFILES}; do |
| 251 | cat "${CFGDIR}/${file}" >> "$TMP_FILE" | 251 | cat "${CFGDIR}/${file}" >> "$TMP_FILE" |
| 252 | done | 252 | done |
| @@ -264,7 +264,7 @@ else | |||
| 264 | fi | 264 | fi |
| 265 | rm "$TMP_FILE" | 265 | rm "$TMP_FILE" |
| 266 | 266 | ||
| 267 | [ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache | 267 | [ -e "${ROOT_DIR}/etc/volatile.cache.build" ] && sync && mv "${ROOT_DIR}/etc/volatile.cache.build" "${ROOT_DIR}/etc/volatile.cache" |
| 268 | fi | 268 | fi |
| 269 | 269 | ||
| 270 | if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ] | 270 | if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ] |
