feat: improvements to simplify script

This commit is contained in:
silver 2024-01-24 22:01:39 +00:00
parent c4de9f43aa
commit beffe4d39c

19
run.sh
View file

@ -23,31 +23,32 @@ function cleanup(){
function build () {
local config="$1"
local location="$2"
local configs="./configs"
local images="./images"
# file:// cannot have relative paths, so use a bit of subsitution to fix
if grep -q SKYNET_ROOT_DIR "$config"; then
if grep -q SKYNET_ROOT_DIR "$configs/$config.yaml"; then
# create a copy with the file
cp "$config" "$config.tmp"
cp "$configs/$config.yaml" "$configs/$config.tmp"
# 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" "$configs/$config.tmp"
# add to tmp tmp_files
tmp_files+=("$config.tmp")
tmp_files+=("$configs/$config.tmp")
# normal command
distrobuilder build-lxc "$config.tmp" $location
distrobuilder build-lxc "$configs/$config.tmp" "$images/$config"
else
distrobuilder build-lxc $config $location
distrobuilder build-lxc "$configs/$config.yaml" "$images/$config"
fi
}
function main(){
setup
build ./configs/base.yaml ./images/base
build ./configs/base_trainee.yaml ./images/base_trainee
build base
build base_trainee
cleanup
}