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