Improved run script
Signed-off-by: Brendan Golden <git_laptop@brendan.ie>
This commit is contained in:
parent
051f3ce32b
commit
1714228fa5
1 changed files with 11 additions and 5 deletions
16
run.sh
16
run.sh
|
@ -1,4 +1,6 @@
|
||||||
# nix-shell -p lxc debootstrap distrobuilder
|
# could add handling to call teh cleanup on
|
||||||
|
|
||||||
|
tmp_files=()
|
||||||
|
|
||||||
function setup(){
|
function setup(){
|
||||||
cp /etc/resolv.conf /etc/resolv.conf.bak
|
cp /etc/resolv.conf /etc/resolv.conf.bak
|
||||||
|
@ -10,8 +12,12 @@ function cleanup(){
|
||||||
# reset permissions of output folder to the owner
|
# reset permissions of output folder to the owner
|
||||||
local owner=$(ls -ld $PWD | awk '{print $3}')
|
local owner=$(ls -ld $PWD | awk '{print $3}')
|
||||||
local group=$(ls -ld $PWD | awk '{print $4}')
|
local group=$(ls -ld $PWD | awk '{print $4}')
|
||||||
|
|
||||||
chown -R "$owner:$group" ./images
|
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 normally uses / but that conflcts with file paths so use @ instead
|
||||||
sed -i "s@SKYNET_ROOT_DIR@$PWD@g" "$config.tmp"
|
sed -i "s@SKYNET_ROOT_DIR@$PWD@g" "$config.tmp"
|
||||||
|
|
||||||
|
# add to tmp tmp_files
|
||||||
|
tmp_files+=("$config.tmp")
|
||||||
|
|
||||||
# normal command
|
# normal command
|
||||||
distrobuilder build-lxc "$config.tmp" $location
|
distrobuilder build-lxc "$config.tmp" $location
|
||||||
|
|
||||||
# cleanup
|
|
||||||
rm "$config.tmp"
|
|
||||||
else
|
else
|
||||||
distrobuilder build-lxc $config $location
|
distrobuilder build-lxc $config $location
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue