diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2024-04-12 11:35:06 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2024-04-15 09:39:37 +0000 |
commit | 4fac2024c43fd887ad9cb081674ed9fd9049f475 (patch) | |
tree | 2356175cfecb449d1669ec36dbe6995a2dd1fcc5 | |
parent | 8e851c548eb78e89e407908cd3b6ce96f3e94533 (diff) |
tcwg-lnt/create-server.sh: Remove database on schema change
Change-Id: I7453e2c59153d349e44889b5fc9dfcce3d19c071
-rwxr-xr-x | tcwg-lnt/create-server.sh | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/tcwg-lnt/create-server.sh b/tcwg-lnt/create-server.sh index ec70564e..ea58bf27 100755 --- a/tcwg-lnt/create-server.sh +++ b/tcwg-lnt/create-server.sh @@ -95,30 +95,41 @@ generate_schema() { local template=${1?} local tsname=${2?} + local outdir="$3" cat "${lnt_schemas_dir?}/$template.yaml.in" \ - | sed "s/TSNAME/$tsname/g" \ - > "${lnt_db_dir?}/schemas/$tsname.yaml" + | sed "s/TSNAME/$tsname/g" > "$outdir/$tsname.yaml" } -if [ ! -d "$lnt_db_dir" ]; then +tmp_schemas=$(mktemp -d) + +for config in "${bmk_configs[@]}"; do + generate_schema tcwg_bmk "$config" "$tmp_schemas" +done + +for config in "${check_configs[@]}"; do + generate_schema tcwg_check "$config" "$tmp_schemas" +done + +if [ -d "$lnt_db_dir" ]; then + if ! diff -rq "$lnt_db_dir/schemas" "$tmp_schemas"; then + # Schemas have changed, so start from a fresh database. + rm -rf "$lnt_db_dir" + fi +fi +if [ ! -d "$lnt_db_dir" ]; then lnt create "$lnt_db_dir" --name "$lnt_server_name" --stable-urls lnt_secret_token="$(echo $RANDOM | md5sum | cut -d' ' -f1)" sed -i "s/# \(api_auth_token =\).*/\1 '$lnt_secret_token'/" "$lnt_db_dir"/lnt.cfg - for config in "${bmk_configs[@]}"; do - generate_schema tcwg_bmk "$config" - done - - for config in "${check_configs[@]}"; do - generate_schema tcwg_check "$config" - done - + rsync -a --del "$tmp_schemas/" "$lnt_db_dir/schemas/" fi +rm -rf "$tmp_schemas" + # TODO schema update not yet supported # eventually delete everything # or just delete the updated testsuite (not supported yet in lnt) |