From 1714228fa507a5ddd65700b566c0537079cbd0fa Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Wed, 24 Jan 2024 20:30:04 +0000 Subject: [PATCH] Improved run script Signed-off-by: Brendan Golden --- run.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/run.sh b/run.sh index 8961c78..aa7bcc3 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,6 @@ -# nix-shell -p lxc debootstrap distrobuilder +# could add handling to call teh cleanup on + +tmp_files=() function setup(){ cp /etc/resolv.conf /etc/resolv.conf.bak @@ -10,8 +12,12 @@ function cleanup(){ # reset permissions of output folder to the owner local owner=$(ls -ld $PWD | awk '{print $3}') local group=$(ls -ld $PWD | awk '{print $4}') - chown -R "$owner:$group" ./images + + # remove all the tmp tmp_files + for tmp_file in ${tmp_files[@]}; do + rm $tmp_file + done } @@ -27,11 +33,11 @@ function build () { # sed normally uses / but that conflcts with file paths so use @ instead sed -i "s@SKYNET_ROOT_DIR@$PWD@g" "$config.tmp" + # add to tmp tmp_files + tmp_files+=("$config.tmp") + # normal command distrobuilder build-lxc "$config.tmp" $location - - # cleanup - rm "$config.tmp" else distrobuilder build-lxc $config $location fi