Improved run script

Signed-off-by: Brendan Golden <git_laptop@brendan.ie>
This commit is contained in:
silver 2024-01-24 20:30:04 +00:00
parent 051f3ce32b
commit 1714228fa5

16
run.sh
View file

@ -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