All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts
@ 2020-10-26 11:12 Diego Sueiro
  2020-10-26 11:12 ` [PATCH 2/2] arm-autonomy/xenguest-manager: Allow guests named 'guest' Diego Sueiro
  2020-10-26 20:45 ` [meta-arm] [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts Jon Mason
  0 siblings, 2 replies; 3+ messages in thread
From: Diego Sueiro @ 2020-10-26 11:12 UTC (permalink / raw)
  To: meta-arm; +Cc: nd, Nathan Dunne

From: Nathan Dunne <Nathan.Dunne@arm.com>

source init scripts in xenguest manager instead of executing
directly, so they can immediately access functions and
variables from the parent script.

Also added a check that init scripts are executable, and will
skip if not.

Change-Id: Ie6bbb1b480a7bfe5af095addcf1aefd122b57c50
Issue-Id: SCM-1587
Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
---
 .../documentation/xenguest-manager.md              | 38 +++++++++++-
 .../xenguest/files/network-bridge.sh.in            |  9 ++-
 .../xenguest/files/xenguest-manager                | 68 ++++++++++++++--------
 3 files changed, 82 insertions(+), 33 deletions(-)

diff --git a/meta-arm-autonomy/documentation/xenguest-manager.md b/meta-arm-autonomy/documentation/xenguest-manager.md
index 387af94..93453bf 100644
--- a/meta-arm-autonomy/documentation/xenguest-manager.md
+++ b/meta-arm-autonomy/documentation/xenguest-manager.md
@@ -48,16 +48,16 @@ project compilation (those can be set in your project local.conf, for example).
 
 The following parameters are available:
 
-- XENGUEST_MANAGER_VOLUME_DEVICE: This is the device path used by the 
+- XENGUEST_MANAGER_VOLUME_DEVICE: This is the device path used by the
   xenguest-manager on the device to create LVM disks when guests have a disk
   configuration.
   This is set by default to "/dev/sda2".
 
-- XENGUEST_MANAGER_VOLUME_NAME: This is the LVM volume name that the 
+- XENGUEST_MANAGER_VOLUME_NAME: This is the LVM volume name that the
   xenguest-manager will create and use to create guest LVM disks.
   This is set by default to "vg-xen".
 
-- XENGUEST_MANAGER_GUEST_DIR: This is the directory on Dom0 where the 
+- XENGUEST_MANAGER_GUEST_DIR: This is the directory on Dom0 where the
   xenguest-manager will look for xenguest images to create during init. That's
   the place where xenguest images can be added to have them automatically
   created during next Dom0 boot. The xenguests found there will only be created
@@ -65,3 +65,35 @@ The following parameters are available:
   name).
   This is set by default to "/usr/share/guests".
 
+Init scripts
+------------
+
+Shell scripts can be executed on the host when a guest is started. Depending on
+when the script should be executed it should be installed in a different
+directory on the target:
+
+- /etc/xenguest/init.pre  : Executed first, prior to guest creation
+
+- /etc/xenguest/init.d    : Executed after guest creation, but before it is started
+
+- /etc/xenguest/init.post : Executed after starting the guest
+
+Inside the directory, scripts will be executed in alphabetical order.
+
+Since these scripts are sourced by xenguest-manager they can acccess functions
+and variables from the parent file's scope, including:
+
+- ${guestname} : The name of the guest being created
+
+- ${guestdir}  : The path to the guest directory
+
+- ${LOGFILE}   : The file to append any logging to, e.g.
+                     echo "Hello, World" >> ${LOGFILE}
+
+Sourcing also allows the script to access params.cfg.
+
+
+An example of how to create the directory and install an init shell script can
+be found in:
+  recipes-extended/xenguest/xenguest-network.bb
+Where network-bridge.sh is installed from network-bridge.sh.in
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 752f498..42ccb70 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
@@ -1,14 +1,13 @@
 #!/bin/sh
 # This script is setting up a virtual network interface connected to the
 # xenguest-network-bridge if NETWORK_BRIDGE is set to 1 in the guest params
-
-guestname="${1}"
+#
+# Since this script is sourced by xenguest-manager, it can access variables
+# such as ${guestname} from the parent file's scope, as well as those in
+# params.cfg, for example XENGUEST_NETWORK_TYPE
 
 BRIDGE_NAME="###BRIDGE_NAME###"
 
-# get guest parameters
-. ./params.cfg
-
 case "${XENGUEST_NETWORK_TYPE:-}" in
     nat)
         # Create the symlinks for the files that vif-nat script expects
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
index d55c9ff..4d59845 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
@@ -475,6 +475,9 @@ function xenguest_guest_start()
 
     # Build init script lists (ignore non existing dirs errors,
     # sort alphabetically and run global scripts first)
+    #
+    # These scripts are sourced throughout the start operation if they
+    # are executable
     init_pre="$(find ${XENGUEST_CONF_BASE}/init.pre -type f 2> /dev/null | \
             sort) $(find ${guestdir}/init.pre -type f 2> /dev/null | sort)"
     init_d="$(find ${XENGUEST_CONF_BASE}/init.d -type f 2> /dev/null | \
@@ -484,13 +487,18 @@ function xenguest_guest_start()
 
     # call pre init scripts
     for f in ${init_pre}; do
-        echo "$f ${guestname}" >> ${LOGFILE} 2>&1
-        $f ${guestname} >> ${LOGFILE} 2>&1
-        if [ $? -ne 0 ]; then
-            rm -f ${guestname}.cfg
-            popd > /dev/null 2>&1
-            echo "${PREF} Error during pre init script of ${guestname}"
-            exit 1
+        if [ -x "$f" ]; then
+            echo "( . $f )" >> ${LOGFILE} 2>&1
+            ( . $f ) >> ${LOGFILE} 2>&1
+            if [ $? -ne 0 ]; then
+                rm -f ${guestname}.cfg
+                popd > /dev/null 2>&1
+                echo "Error in init script $f" >> ${LOGFILE} 2>&1
+                echo "${PREF} Error during pre init script of ${guestname}"
+                exit 1
+            fi
+        else
+            echo "$f is not executable. Skipping." >> ${LOGFILE}
         fi
     done
 
@@ -506,15 +514,20 @@ function xenguest_guest_start()
 
     # call init scripts
     for f in ${init_d}; do
-        echo "$f ${guestname}" >> ${LOGFILE} 2>&1
-        $f ${guestname} >> ${LOGFILE} 2>&1
-        if [ $? -ne 0 ]; then
-            rm -f ${guestname}.cfg
-            echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
-            xl destroy ${guestname} >> ${LOGFILE} 2>&1
-            popd > /dev/null 2>&1
-            echo "${PREF} Error during init script of ${guestname}"
-            exit 1
+        if [ -x "$f" ]; then
+            echo "( . $f )" >> ${LOGFILE} 2>&1
+            ( . $f ) >> ${LOGFILE} 2>&1
+            if [ $? -ne 0 ]; then
+                rm -f ${guestname}.cfg
+                echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
+                xl destroy ${guestname} >> ${LOGFILE} 2>&1
+                popd > /dev/null 2>&1
+                echo "Error in init script $f" >> ${LOGFILE} 2>&1
+                echo "${PREF} Error during init script of ${guestname}"
+                exit 1
+            fi
+        else
+            echo "$f is not executable. Skipping." >> ${LOGFILE}
         fi
     done
 
@@ -530,15 +543,20 @@ function xenguest_guest_start()
 
     # call post init scripts
     for f in ${init_post}; do
-        echo "$f ${guestname}" >> ${LOGFILE} 2>&1
-        $f ${guestname} >> ${LOGFILE} 2>&1
-        if [ $? -ne 0 ]; then
-            rm -f ${guestname}.cfg
-            echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
-            xl destroy ${guestname} >> ${LOGFILE} 2>&1
-            popd > /dev/null 2>&1
-            echo "${PREF} Error during post init script of ${guestname}"
-            exit 1
+        if [ -x "$f" ]; then
+            echo "( . $f )" >> ${LOGFILE} 2>&1
+            ( . $f ) >> ${LOGFILE} 2>&1
+            if [ $? -ne 0 ]; then
+                rm -f ${guestname}.cfg
+                echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
+                xl destroy ${guestname} >> ${LOGFILE} 2>&1
+                popd > /dev/null 2>&1
+                echo "Error in init script $f" >> ${LOGFILE} 2>&1
+                echo "${PREF} Error during post init script of ${guestname}"
+                exit 1
+            fi
+        else
+            echo "$f is not executable. Skipping." >> ${LOGFILE}
         fi
     done
 
-- 
2.7.4


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

* [PATCH 2/2] arm-autonomy/xenguest-manager: Allow guests named 'guest'
  2020-10-26 11:12 [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts Diego Sueiro
@ 2020-10-26 11:12 ` Diego Sueiro
  2020-10-26 20:45 ` [meta-arm] [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts Jon Mason
  1 sibling, 0 replies; 3+ messages in thread
From: Diego Sueiro @ 2020-10-26 11:12 UTC (permalink / raw)
  To: meta-arm; +Cc: nd, Nathan Dunne

From: Nathan Dunne <Nathan.Dunne@arm.com>

Prevented name collision on file guest.cfg when the name of the
guest is exactly 'guest'. Config is now piped into a tmp file
which can safely be deleted at the end of the start operation.

Change-Id: Id08ac08e52e9e64c508c841b257ecb28ed9d44ae
Issue-Id: SCM-1518
Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
---
 meta-arm-autonomy/documentation/xenguest-manager.md  |  8 +++++---
 .../xenguest/files/network-bridge.sh.in              |  4 ++--
 .../recipes-extended/xenguest/files/xenguest-manager | 20 +++++++++++---------
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/meta-arm-autonomy/documentation/xenguest-manager.md b/meta-arm-autonomy/documentation/xenguest-manager.md
index 93453bf..5a66e8a 100644
--- a/meta-arm-autonomy/documentation/xenguest-manager.md
+++ b/meta-arm-autonomy/documentation/xenguest-manager.md
@@ -83,11 +83,13 @@ Inside the directory, scripts will be executed in alphabetical order.
 Since these scripts are sourced by xenguest-manager they can acccess functions
 and variables from the parent file's scope, including:
 
-- ${guestname} : The name of the guest being created
+- ${guestname}    : The name of the guest being created
 
-- ${guestdir}  : The path to the guest directory
+- ${guestdir}     : The path to the guest directory
 
-- ${LOGFILE}   : The file to append any logging to, e.g.
+- ${guestcfgfile} : The name of the config file for the starting guest
+
+- ${LOGFILE}      : The file to append any logging to, e.g.
                      echo "Hello, World" >> ${LOGFILE}
 
 Sourcing also allows the script to access params.cfg.
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 42ccb70..27306e4 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
@@ -20,10 +20,10 @@ case "${XENGUEST_NETWORK_TYPE:-}" in
         if [ ! -f /etc/default/dhcp3-server ]; then
             ln -s dhcp-server /etc/default/dhcp3-server
         fi
-        echo "vif = ['script=vif-nat']" >> ${guestname}.cfg
+        echo "vif = ['script=vif-nat']" >> ${guestcfgfile}
         ;;
     bridge)
-        echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestname}.cfg
+        echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestcfgfile}
         ;;
     *)
         echo "${@}: XENGUEST_NETWORK_TYPE=$XENGUEST_NETWORK_TYPE invalid"
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
index 4d59845..78ac55d 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
@@ -465,13 +465,15 @@ function xenguest_guest_start()
     guestname="${1}"
     guestdir=${XENGUEST_CONF_BASE}/guests/${guestname}
 
+    guestcfgfile=$(mktemp -u "${guestname}.XXXXXX" --tmpdir="${guestdir}" --suffix=".cfg")
+
     # Get guest configuration
     source ${guestdir}/params.cfg
 
     pushd ${guestdir} > /dev/null 2>&1
 
     # create config by merging all configurations together
-    cat guest.cfg $(find guest.d -type f 2> /dev/null) > ${guestname}.cfg
+    cat guest.cfg $(find guest.d -type f 2> /dev/null) > ${guestcfgfile}
 
     # Build init script lists (ignore non existing dirs errors,
     # sort alphabetically and run global scripts first)
@@ -491,7 +493,7 @@ function xenguest_guest_start()
             echo "( . $f )" >> ${LOGFILE} 2>&1
             ( . $f ) >> ${LOGFILE} 2>&1
             if [ $? -ne 0 ]; then
-                rm -f ${guestname}.cfg
+                rm -f ${guestcfgfile}
                 popd > /dev/null 2>&1
                 echo "Error in init script $f" >> ${LOGFILE} 2>&1
                 echo "${PREF} Error during pre init script of ${guestname}"
@@ -503,10 +505,10 @@ function xenguest_guest_start()
     done
 
     # Create non started guest
-    echo "xl create -p ${guestname}.cfg" >> ${LOGFILE} 2>&1
-    xl create -p ${guestname}.cfg >> ${LOGFILE} 2>&1
+    echo "xl create -p ${guestcfgfile}" >> ${LOGFILE} 2>&1
+    xl create -p ${guestcfgfile} >> ${LOGFILE} 2>&1
     if [ $? -ne 0 ]; then
-        rm -f ${guestname}.cfg
+        rm -f ${guestcfgfile}
         popd > /dev/null 2>&1
         echo "${PREF} Error starting ${guestname}"
         exit 1
@@ -518,7 +520,7 @@ function xenguest_guest_start()
             echo "( . $f )" >> ${LOGFILE} 2>&1
             ( . $f ) >> ${LOGFILE} 2>&1
             if [ $? -ne 0 ]; then
-                rm -f ${guestname}.cfg
+                rm -f ${guestcfgfile}
                 echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
                 xl destroy ${guestname} >> ${LOGFILE} 2>&1
                 popd > /dev/null 2>&1
@@ -535,7 +537,7 @@ function xenguest_guest_start()
     echo "xl unpause ${guestname}" >> ${LOGFILE} 2>&1
     xl unpause ${guestname} >> ${LOGFILE} 2>&1
     if [ $? -ne 0 ]; then
-        rm -f ${guestname}.cfg
+        rm -f ${guestcfgfile}
         popd > /dev/null 2>&1
         echo "${PREF} Error starting ${guestname}"
         exit 1
@@ -547,7 +549,7 @@ function xenguest_guest_start()
             echo "( . $f )" >> ${LOGFILE} 2>&1
             ( . $f ) >> ${LOGFILE} 2>&1
             if [ $? -ne 0 ]; then
-                rm -f ${guestname}.cfg
+                rm -f ${guestcfgfile}
                 echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
                 xl destroy ${guestname} >> ${LOGFILE} 2>&1
                 popd > /dev/null 2>&1
@@ -560,7 +562,7 @@ function xenguest_guest_start()
         fi
     done
 
-    rm -f ${guestname}.cfg
+    rm -f ${guestcfgfile}
     popd > /dev/null 2>&1
 }
 
-- 
2.7.4


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

* Re: [meta-arm] [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts
  2020-10-26 11:12 [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts Diego Sueiro
  2020-10-26 11:12 ` [PATCH 2/2] arm-autonomy/xenguest-manager: Allow guests named 'guest' Diego Sueiro
@ 2020-10-26 20:45 ` Jon Mason
  1 sibling, 0 replies; 3+ messages in thread
From: Jon Mason @ 2020-10-26 20:45 UTC (permalink / raw)
  To: Diego Sueiro; +Cc: meta-arm, nd, Nathan Dunne

On Mon, Oct 26, 2020 at 11:12:22AM +0000, Diego Sueiro wrote:
> From: Nathan Dunne <Nathan.Dunne@arm.com>
> 
> source init scripts in xenguest manager instead of executing
> directly, so they can immediately access functions and
> variables from the parent script.
> 
> Also added a check that init scripts are executable, and will
> skip if not.
> 
> Change-Id: Ie6bbb1b480a7bfe5af095addcf1aefd122b57c50
> Issue-Id: SCM-1587
> Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>

Series applied to master.

Thanks,
Jon

> ---
>  .../documentation/xenguest-manager.md              | 38 +++++++++++-
>  .../xenguest/files/network-bridge.sh.in            |  9 ++-
>  .../xenguest/files/xenguest-manager                | 68 ++++++++++++++--------
>  3 files changed, 82 insertions(+), 33 deletions(-)
> 
> diff --git a/meta-arm-autonomy/documentation/xenguest-manager.md b/meta-arm-autonomy/documentation/xenguest-manager.md
> index 387af94..93453bf 100644
> --- a/meta-arm-autonomy/documentation/xenguest-manager.md
> +++ b/meta-arm-autonomy/documentation/xenguest-manager.md
> @@ -48,16 +48,16 @@ project compilation (those can be set in your project local.conf, for example).
>  
>  The following parameters are available:
>  
> -- XENGUEST_MANAGER_VOLUME_DEVICE: This is the device path used by the 
> +- XENGUEST_MANAGER_VOLUME_DEVICE: This is the device path used by the
>    xenguest-manager on the device to create LVM disks when guests have a disk
>    configuration.
>    This is set by default to "/dev/sda2".
>  
> -- XENGUEST_MANAGER_VOLUME_NAME: This is the LVM volume name that the 
> +- XENGUEST_MANAGER_VOLUME_NAME: This is the LVM volume name that the
>    xenguest-manager will create and use to create guest LVM disks.
>    This is set by default to "vg-xen".
>  
> -- XENGUEST_MANAGER_GUEST_DIR: This is the directory on Dom0 where the 
> +- XENGUEST_MANAGER_GUEST_DIR: This is the directory on Dom0 where the
>    xenguest-manager will look for xenguest images to create during init. That's
>    the place where xenguest images can be added to have them automatically
>    created during next Dom0 boot. The xenguests found there will only be created
> @@ -65,3 +65,35 @@ The following parameters are available:
>    name).
>    This is set by default to "/usr/share/guests".
>  
> +Init scripts
> +------------
> +
> +Shell scripts can be executed on the host when a guest is started. Depending on
> +when the script should be executed it should be installed in a different
> +directory on the target:
> +
> +- /etc/xenguest/init.pre  : Executed first, prior to guest creation
> +
> +- /etc/xenguest/init.d    : Executed after guest creation, but before it is started
> +
> +- /etc/xenguest/init.post : Executed after starting the guest
> +
> +Inside the directory, scripts will be executed in alphabetical order.
> +
> +Since these scripts are sourced by xenguest-manager they can acccess functions
> +and variables from the parent file's scope, including:
> +
> +- ${guestname} : The name of the guest being created
> +
> +- ${guestdir}  : The path to the guest directory
> +
> +- ${LOGFILE}   : The file to append any logging to, e.g.
> +                     echo "Hello, World" >> ${LOGFILE}
> +
> +Sourcing also allows the script to access params.cfg.
> +
> +
> +An example of how to create the directory and install an init shell script can
> +be found in:
> +  recipes-extended/xenguest/xenguest-network.bb
> +Where network-bridge.sh is installed from network-bridge.sh.in
> 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 752f498..42ccb70 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
> @@ -1,14 +1,13 @@
>  #!/bin/sh
>  # This script is setting up a virtual network interface connected to the
>  # xenguest-network-bridge if NETWORK_BRIDGE is set to 1 in the guest params
> -
> -guestname="${1}"
> +#
> +# Since this script is sourced by xenguest-manager, it can access variables
> +# such as ${guestname} from the parent file's scope, as well as those in
> +# params.cfg, for example XENGUEST_NETWORK_TYPE
>  
>  BRIDGE_NAME="###BRIDGE_NAME###"
>  
> -# get guest parameters
> -. ./params.cfg
> -
>  case "${XENGUEST_NETWORK_TYPE:-}" in
>      nat)
>          # Create the symlinks for the files that vif-nat script expects
> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
> index d55c9ff..4d59845 100755
> --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
> +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
> @@ -475,6 +475,9 @@ function xenguest_guest_start()
>  
>      # Build init script lists (ignore non existing dirs errors,
>      # sort alphabetically and run global scripts first)
> +    #
> +    # These scripts are sourced throughout the start operation if they
> +    # are executable
>      init_pre="$(find ${XENGUEST_CONF_BASE}/init.pre -type f 2> /dev/null | \
>              sort) $(find ${guestdir}/init.pre -type f 2> /dev/null | sort)"
>      init_d="$(find ${XENGUEST_CONF_BASE}/init.d -type f 2> /dev/null | \
> @@ -484,13 +487,18 @@ function xenguest_guest_start()
>  
>      # call pre init scripts
>      for f in ${init_pre}; do
> -        echo "$f ${guestname}" >> ${LOGFILE} 2>&1
> -        $f ${guestname} >> ${LOGFILE} 2>&1
> -        if [ $? -ne 0 ]; then
> -            rm -f ${guestname}.cfg
> -            popd > /dev/null 2>&1
> -            echo "${PREF} Error during pre init script of ${guestname}"
> -            exit 1
> +        if [ -x "$f" ]; then
> +            echo "( . $f )" >> ${LOGFILE} 2>&1
> +            ( . $f ) >> ${LOGFILE} 2>&1
> +            if [ $? -ne 0 ]; then
> +                rm -f ${guestname}.cfg
> +                popd > /dev/null 2>&1
> +                echo "Error in init script $f" >> ${LOGFILE} 2>&1
> +                echo "${PREF} Error during pre init script of ${guestname}"
> +                exit 1
> +            fi
> +        else
> +            echo "$f is not executable. Skipping." >> ${LOGFILE}
>          fi
>      done
>  
> @@ -506,15 +514,20 @@ function xenguest_guest_start()
>  
>      # call init scripts
>      for f in ${init_d}; do
> -        echo "$f ${guestname}" >> ${LOGFILE} 2>&1
> -        $f ${guestname} >> ${LOGFILE} 2>&1
> -        if [ $? -ne 0 ]; then
> -            rm -f ${guestname}.cfg
> -            echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
> -            xl destroy ${guestname} >> ${LOGFILE} 2>&1
> -            popd > /dev/null 2>&1
> -            echo "${PREF} Error during init script of ${guestname}"
> -            exit 1
> +        if [ -x "$f" ]; then
> +            echo "( . $f )" >> ${LOGFILE} 2>&1
> +            ( . $f ) >> ${LOGFILE} 2>&1
> +            if [ $? -ne 0 ]; then
> +                rm -f ${guestname}.cfg
> +                echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
> +                xl destroy ${guestname} >> ${LOGFILE} 2>&1
> +                popd > /dev/null 2>&1
> +                echo "Error in init script $f" >> ${LOGFILE} 2>&1
> +                echo "${PREF} Error during init script of ${guestname}"
> +                exit 1
> +            fi
> +        else
> +            echo "$f is not executable. Skipping." >> ${LOGFILE}
>          fi
>      done
>  
> @@ -530,15 +543,20 @@ function xenguest_guest_start()
>  
>      # call post init scripts
>      for f in ${init_post}; do
> -        echo "$f ${guestname}" >> ${LOGFILE} 2>&1
> -        $f ${guestname} >> ${LOGFILE} 2>&1
> -        if [ $? -ne 0 ]; then
> -            rm -f ${guestname}.cfg
> -            echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
> -            xl destroy ${guestname} >> ${LOGFILE} 2>&1
> -            popd > /dev/null 2>&1
> -            echo "${PREF} Error during post init script of ${guestname}"
> -            exit 1
> +        if [ -x "$f" ]; then
> +            echo "( . $f )" >> ${LOGFILE} 2>&1
> +            ( . $f ) >> ${LOGFILE} 2>&1
> +            if [ $? -ne 0 ]; then
> +                rm -f ${guestname}.cfg
> +                echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
> +                xl destroy ${guestname} >> ${LOGFILE} 2>&1
> +                popd > /dev/null 2>&1
> +                echo "Error in init script $f" >> ${LOGFILE} 2>&1
> +                echo "${PREF} Error during post init script of ${guestname}"
> +                exit 1
> +            fi
> +        else
> +            echo "$f is not executable. Skipping." >> ${LOGFILE}
>          fi
>      done
>  
> -- 
> 2.7.4
> 

> 
> 
> 


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

end of thread, other threads:[~2020-10-26 20:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 11:12 [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts Diego Sueiro
2020-10-26 11:12 ` [PATCH 2/2] arm-autonomy/xenguest-manager: Allow guests named 'guest' Diego Sueiro
2020-10-26 20:45 ` [meta-arm] [PATCH 1/2] arm-autonomy/xenguest-manager: source init scripts 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.