Skip to content

Commit 3cf43f7

Browse files
committed
image-shell now accepts multiple commands
These will be run in order, without parallel with the first waiting to exit before the second runs in a seperate chroot. signal passing, paralellism and exit code status passing are not supported at this time. "Quotes" will allow you run parameters for a command, the quoted content will be passed to the shell as if it was typed. Debian patching now works
1 parent a8df0fb commit 3cf43f7

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

gen_cloud_template.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ _update_image(){
270270
_image_shell "pacman -Syu"
271271
;;
272272
debian)
273-
_image_shell "apt update && apt upgrade"
273+
# Nasty kludge that we can't get both to run in the same choort.
274+
_image_shell "apt update" "apt upgrade"
274275
;;
275276
redhat)
276277
_image_shell "yum update"
@@ -287,9 +288,8 @@ _image_shell(){
287288
local mount_point="$(mktemp -d)"
288289
local mount_dev=""
289290
local mount_target=""
290-
local command=""
291-
[ ! -z "${1}" ] && command="${1}"
292-
291+
local commands=""
292+
[ ! -z "${1}" ] && commands=("${@}")
293293
[ ! -f "${TARGET}/${BASE_IMAGE}" ] && exit_with_error 1 "Base install cannot be found. perhaps you forgot to init-image?"
294294

295295
# Set up mount and get unmount data
@@ -299,12 +299,14 @@ _image_shell(){
299299

300300
# Run command
301301
# Don't let the name fool you, arch-chroot also works on debian
302-
if [ -z "${command}" ];then
302+
if [ -z "${commands}" ];then
303303
message "Opening shell in base install"
304304
as_root arch-chroot "${mount_point}" || warn "Shell failed!"
305305
else
306-
message "Running ${command} in base install"
307-
as_root arch-chroot "${mount_point}" ${command}
306+
message "Running \"${commands[@]}\" in base install"
307+
for cmd in "${commands[@]}";do
308+
as_root arch-chroot "${mount_point}" "${cmd}"
309+
done
308310
fi
309311

310312
# Cleanup

0 commit comments

Comments
 (0)