All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm-autonomy/xenguest: Fix issues raised by shellcheck
@ 2021-03-01 13:04 Peter Hoyes
  2021-03-02 14:28 ` [meta-arm] " Jon Mason
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Hoyes @ 2021-03-01 13:04 UTC (permalink / raw)
  To: meta-arm; +Cc: nd, Peter Hoyes

From: Peter Hoyes <Peter.Hoyes@arm.com>

Ignore issues in xenguest-manager and xenguest-mkimage as these
will soon be rewritten.

Issue-Id: SCM-1526
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I733b4bfaaa5002f7a64c577e16548af62c425ebf
---
 .../xenguest/files/kea-restore-default-config |  2 +-
 .../xenguest/files/network-bridge.sh.in       |  4 ++--
 .../xenguest/files/xenguest-init              | 22 +++++++++----------
 .../xenguest/files/xenguest-network-bridge.in |  2 +-
 .../files/xenguest-network-init-post.sh       | 11 +++++-----
 5 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config
index 424fd0a..9776ddf 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config
@@ -22,7 +22,7 @@ case "$1" in
   *)
         # do not advertise unreasonable commands that there is no reason
         # to use with this device
-        echo $"Usage: $0 {start|stop|status|restart|force-reload}"
+        echo "Usage: $0 {start|stop|status|restart|force-reload}"
         exit 1
 esac
 
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in b/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in
index 3f87b76..e697f7e 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in
@@ -10,11 +10,11 @@ BRIDGE_NAME="###BRIDGE_NAME###"
 
 case "${XENGUEST_NETWORK_TYPE:=}" in
     nat)
-        echo "vif = ['script=vif-nat']" >> ${guestcfgfile}
+        echo "vif = ['script=vif-nat']" >> "${guestcfgfile:?}"
         log info "Network type is NAT"
         ;;
     bridge)
-        echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestcfgfile}
+        echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> "${guestcfgfile:?}"
         log info "Network type is bridge: ${BRIDGE_NAME}"
         ;;
     *)
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
index c6b0c83..5862cb9 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
@@ -25,19 +25,19 @@ case "$1" in
         echo "Starting xenguest"
 
         # Create unconfigured guests
-        if [ -d ${XENGUEST_GUEST_DIR} ]; then
-            for f in $(find ${XENGUEST_GUEST_DIR} -name "*.xenguest" \
-                -exec basename {} .xenguest \;); do
-                if [ ! -f ${XENGUEST_CONF_BASE}/guests/${f}/guest.cfg ]; then
+        if [ -d "${XENGUEST_GUEST_DIR}" ]; then
+            shopt -s nullglob
+            for path in "${XENGUEST_GUEST_DIR}"/*.xenguest; do
+                f=$(basename "${path}" .xenguest)
+                if [ ! -f "${XENGUEST_CONF_BASE}/guests/${f}/guest.cfg" ]; then
                     # Check if this guest should be auto booted
                     autoboot=$(/usr/bin/xenguest-mkimage dump-paramsconfig \
-                        ${XENGUEST_GUEST_DIR}/${f}.xenguest | \
+                        "${path}" | \
                         grep GUEST_AUTOBOOT | sed -e "s,.*=,," | tr -d '"')
                     if [ "$autoboot" = "0" ]; then
                         echo "Do not create $f, autoboot disabled"
                     else
-                        /usr/bin/xenguest-manager create \
-                            ${XENGUEST_GUEST_DIR}/${f}.xenguest
+                        /usr/bin/xenguest-manager create "${path}"
                         # Update guestlist
                         if [ $? -eq 0 ]; then
                             guestlist="${guestlist} ${f}"
@@ -49,11 +49,11 @@ case "$1" in
         if [ -n "${guestlist}" ]; then
             for f in ${guestlist}; do
                 GUEST_AUTOBOOT="1"
-                if [ -f ${XENGUEST_CONF_BASE}/guests/${f}/params.cfg ]; then
-                    source ${XENGUEST_CONF_BASE}/guests/${f}/params.cfg
+                if [ -f "${XENGUEST_CONF_BASE}/guests/${f}/params.cfg" ]; then
+                    source "${XENGUEST_CONF_BASE}/guests/${f}/params.cfg"
                 fi
                 if [ "${GUEST_AUTOBOOT}" = "1" ]; then
-                    /usr/bin/xenguest-manager start ${f}
+                    /usr/bin/xenguest-manager start "${f}"
                 fi
             done
         else
@@ -68,7 +68,7 @@ case "$1" in
         # update guest list
         guestlist=$(xenguest-manager status | grep Running | cut -d ":" -f1)
         for f in ${guestlist}; do
-            xenguest-manager shutdown ${f} --kill
+            xenguest-manager shutdown "${f}" --kill
         done
         ;;
   reload)
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in
index 2278b80..54b5a2f 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in
@@ -36,7 +36,7 @@ case "$1" in
   *)
         # do not advertise unreasonable commands that there is no reason
         # to use with this device
-        echo $"Usage: $0 {start|stop|status|restart|force-reload}"
+        echo "Usage: $0 {start|stop|status|restart|force-reload}"
         exit 1
 esac
 
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh
index ce5e6de..b63c6a2 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh
@@ -11,19 +11,20 @@ set +u
 #
 
 check_if_vif_is_ready() {
-    ret=($(xl network-list "${guestname}" | grep  "${1}"))
-    # ${ret[4]} is network interface status value
+    ret=$(xl network-list "${guestname:?}" | grep  "${1}" \
+        | tr -s ' ' | cut -d' ' -f5)
+    # ${ret} is network interface status value
     # 1 means vif is not ready
     # 4 means vif is ready
-    [ "${ret[4]}" = "4" ] && return 0
+    [ "${ret}" = "4" ] && return 0
     return 1
 }
 
 case "${XENGUEST_NETWORK_TYPE:-}" in
     nat)
-        vif_name="$(xl network-list ${guestname} | grep -o vif.*)"
+        vif_name="$(xl network-list "${guestname:?}" | grep -o "vif.*")"
 
-        for try in {1..20}
+        for try in $(seq 20)
         do
             if check_if_vif_is_ready "${vif_name}"; then
                 claim_lock "vif-nat-kea"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [meta-arm] [PATCH] arm-autonomy/xenguest: Fix issues raised by shellcheck
  2021-03-01 13:04 [PATCH] arm-autonomy/xenguest: Fix issues raised by shellcheck Peter Hoyes
@ 2021-03-02 14:28 ` Jon Mason
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Mason @ 2021-03-02 14:28 UTC (permalink / raw)
  To: Peter Hoyes; +Cc: meta-arm, nd

On Mon, Mar 01, 2021 at 01:04:51PM +0000, Peter Hoyes wrote:
> From: Peter Hoyes <Peter.Hoyes@arm.com>
> 
> Ignore issues in xenguest-manager and xenguest-mkimage as these
> will soon be rewritten.
> 
> Issue-Id: SCM-1526
> Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
> Change-Id: I733b4bfaaa5002f7a64c577e16548af62c425ebf
> ---

Applied to master.

Thanks,
Jon

>  .../xenguest/files/kea-restore-default-config |  2 +-
>  .../xenguest/files/network-bridge.sh.in       |  4 ++--
>  .../xenguest/files/xenguest-init              | 22 +++++++++----------
>  .../xenguest/files/xenguest-network-bridge.in |  2 +-
>  .../files/xenguest-network-init-post.sh       | 11 +++++-----
>  5 files changed, 21 insertions(+), 20 deletions(-)
> 
> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config
> index 424fd0a..9776ddf 100755
> --- a/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config
> +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config
> @@ -22,7 +22,7 @@ case "$1" in
>    *)
>          # do not advertise unreasonable commands that there is no reason
>          # to use with this device
> -        echo $"Usage: $0 {start|stop|status|restart|force-reload}"
> +        echo "Usage: $0 {start|stop|status|restart|force-reload}"
>          exit 1
>  esac
>  
> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in b/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in
> index 3f87b76..e697f7e 100755
> --- a/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in
> +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in
> @@ -10,11 +10,11 @@ BRIDGE_NAME="###BRIDGE_NAME###"
>  
>  case "${XENGUEST_NETWORK_TYPE:=}" in
>      nat)
> -        echo "vif = ['script=vif-nat']" >> ${guestcfgfile}
> +        echo "vif = ['script=vif-nat']" >> "${guestcfgfile:?}"
>          log info "Network type is NAT"
>          ;;
>      bridge)
> -        echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestcfgfile}
> +        echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> "${guestcfgfile:?}"
>          log info "Network type is bridge: ${BRIDGE_NAME}"
>          ;;
>      *)
> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
> index c6b0c83..5862cb9 100755
> --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
> +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
> @@ -25,19 +25,19 @@ case "$1" in
>          echo "Starting xenguest"
>  
>          # Create unconfigured guests
> -        if [ -d ${XENGUEST_GUEST_DIR} ]; then
> -            for f in $(find ${XENGUEST_GUEST_DIR} -name "*.xenguest" \
> -                -exec basename {} .xenguest \;); do
> -                if [ ! -f ${XENGUEST_CONF_BASE}/guests/${f}/guest.cfg ]; then
> +        if [ -d "${XENGUEST_GUEST_DIR}" ]; then
> +            shopt -s nullglob
> +            for path in "${XENGUEST_GUEST_DIR}"/*.xenguest; do
> +                f=$(basename "${path}" .xenguest)
> +                if [ ! -f "${XENGUEST_CONF_BASE}/guests/${f}/guest.cfg" ]; then
>                      # Check if this guest should be auto booted
>                      autoboot=$(/usr/bin/xenguest-mkimage dump-paramsconfig \
> -                        ${XENGUEST_GUEST_DIR}/${f}.xenguest | \
> +                        "${path}" | \
>                          grep GUEST_AUTOBOOT | sed -e "s,.*=,," | tr -d '"')
>                      if [ "$autoboot" = "0" ]; then
>                          echo "Do not create $f, autoboot disabled"
>                      else
> -                        /usr/bin/xenguest-manager create \
> -                            ${XENGUEST_GUEST_DIR}/${f}.xenguest
> +                        /usr/bin/xenguest-manager create "${path}"
>                          # Update guestlist
>                          if [ $? -eq 0 ]; then
>                              guestlist="${guestlist} ${f}"
> @@ -49,11 +49,11 @@ case "$1" in
>          if [ -n "${guestlist}" ]; then
>              for f in ${guestlist}; do
>                  GUEST_AUTOBOOT="1"
> -                if [ -f ${XENGUEST_CONF_BASE}/guests/${f}/params.cfg ]; then
> -                    source ${XENGUEST_CONF_BASE}/guests/${f}/params.cfg
> +                if [ -f "${XENGUEST_CONF_BASE}/guests/${f}/params.cfg" ]; then
> +                    source "${XENGUEST_CONF_BASE}/guests/${f}/params.cfg"
>                  fi
>                  if [ "${GUEST_AUTOBOOT}" = "1" ]; then
> -                    /usr/bin/xenguest-manager start ${f}
> +                    /usr/bin/xenguest-manager start "${f}"
>                  fi
>              done
>          else
> @@ -68,7 +68,7 @@ case "$1" in
>          # update guest list
>          guestlist=$(xenguest-manager status | grep Running | cut -d ":" -f1)
>          for f in ${guestlist}; do
> -            xenguest-manager shutdown ${f} --kill
> +            xenguest-manager shutdown "${f}" --kill
>          done
>          ;;
>    reload)
> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in
> index 2278b80..54b5a2f 100755
> --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in
> +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-bridge.in
> @@ -36,7 +36,7 @@ case "$1" in
>    *)
>          # do not advertise unreasonable commands that there is no reason
>          # to use with this device
> -        echo $"Usage: $0 {start|stop|status|restart|force-reload}"
> +        echo "Usage: $0 {start|stop|status|restart|force-reload}"
>          exit 1
>  esac
>  
> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh
> index ce5e6de..b63c6a2 100755
> --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh
> +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh
> @@ -11,19 +11,20 @@ set +u
>  #
>  
>  check_if_vif_is_ready() {
> -    ret=($(xl network-list "${guestname}" | grep  "${1}"))
> -    # ${ret[4]} is network interface status value
> +    ret=$(xl network-list "${guestname:?}" | grep  "${1}" \
> +        | tr -s ' ' | cut -d' ' -f5)
> +    # ${ret} is network interface status value
>      # 1 means vif is not ready
>      # 4 means vif is ready
> -    [ "${ret[4]}" = "4" ] && return 0
> +    [ "${ret}" = "4" ] && return 0
>      return 1
>  }
>  
>  case "${XENGUEST_NETWORK_TYPE:-}" in
>      nat)
> -        vif_name="$(xl network-list ${guestname} | grep -o vif.*)"
> +        vif_name="$(xl network-list "${guestname:?}" | grep -o "vif.*")"
>  
> -        for try in {1..20}
> +        for try in $(seq 20)
>          do
>              if check_if_vif_is_ready "${vif_name}"; then
>                  claim_lock "vif-nat-kea"
> -- 
> 2.25.1
> 

> 
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-02 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 13:04 [PATCH] arm-autonomy/xenguest: Fix issues raised by shellcheck Peter Hoyes
2021-03-02 14:28 ` [meta-arm] " Jon Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.