diff options
-rwxr-xr-x | gen-data/generate | 18 | ||||
-rw-r--r-- | gen-data/tasks/locale-cz/run.sh | 18 |
2 files changed, 31 insertions, 5 deletions
diff --git a/gen-data/generate b/gen-data/generate index bf9cce3..d8ead6b 100755 --- a/gen-data/generate +++ b/gen-data/generate @@ -2,6 +2,7 @@ GEN_DATADIR=/var/lib/pgsql/data CACHEDIR=/var/cache/dbt +OUTPUTDIR="$(pwd)/results" SRCDIR="$(pwd)" DEBUG=1 CHECK_LOCALE=1 @@ -48,10 +49,10 @@ run_if_defined() locale_prereq() { - local default_locale="en_US.UTF-8" + local default_locale="LANG=en_US.UTF-8" local current_locale="$(cat /etc/locale.conf)" test "$current_locale" = "$default_locale" \ - || die "bad locale $current_locale, should be $default_locale" + || die "bad locale '$current_locale', should be '$default_locale'" } single_task() @@ -59,9 +60,9 @@ single_task() local task="$1" info "running task $task" - INDENT=" " ( + INDENT=" " . "$SRCDIR/databases/pagila.sh" || die "pagila incl fail" . "$SRCDIR/$task" || die "include fail" @@ -87,25 +88,32 @@ single_task() debug "stopping server" service postgresql stop &>/dev/null || die "can't stop postgresql" - tarball="$(pwd)/$task_name.tar.gz" + tarball="$OUTPUTDIR/$task_name.tar.gz" tar -czf "$tarball" -C /var/lib/pgsql/ data info "result tarball $tarball" rm -rf "$tmpdir" + debug "data removal" rm -rf "$GEN_DATADIR" + + run_if_defined "hook_end" ) } generate_tasks() { - single_task tasks/basic/run.sh + find ./tasks -name run.sh | while read line; do + single_task "$line" + done } main() { test "$UID" -ne 0 && die "run under 'root' user" + test -d "$OUTPUTDIR" || die "$OUTPUTDIR does not seem to be directory" + service postgresql status &>/dev/null test $? -ne 3 && die "stop the postgresql server" diff --git a/gen-data/tasks/locale-cz/run.sh b/gen-data/tasks/locale-cz/run.sh new file mode 100644 index 0000000..12f0a48 --- /dev/null +++ b/gen-data/tasks/locale-cz/run.sh @@ -0,0 +1,18 @@ +export task_name="cz-locale" + +hook_start() +{ + export CHECK_LOCALE=0 + ___old_locale="$(cat /etc/locale.conf)" + echo "LANG=cs_CZ.UTF-8" > /etc/locale.conf +} + +hook_end() +{ + echo "$___old_locale" > /etc/locale.conf +} + +run() +{ + create_pagila +} |