diff options
Diffstat (limited to 'testing/aaudit/aaudit-repo-create')
-rwxr-xr-x | testing/aaudit/aaudit-repo-create | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/aaudit/aaudit-repo-create b/testing/aaudit/aaudit-repo-create new file mode 100755 index 0000000000..7b3ce91220 --- /dev/null +++ b/testing/aaudit/aaudit-repo-create @@ -0,0 +1,51 @@ +#!/usr/bin/lua5.2 + +local posix = require 'posix' +local aaudit = require 'aaudit' + +local function usage() + print("usage: aaudit-repo-create [-a ADDRESS] -d DESCRIPTION [-i COMMIT_IDENTITY] [-m COMMIT_MESSAGE] [-g GROUPS]") + os.exit(1) +end + +local C = { initial=true } +local groups = {} +local address, description + +for ret, optval in posix.getopt(arg, 'a:d:g:i:m:') do + if ret == 'a' then + address = optval + elseif ret == 'd' then + description = optval + elseif ret == 'g' then + groups['"'..optval..'"'] = true + elseif ret == 'i' then + C.identity = optval + elseif ret == 'm' then + C.message = optval + else + usage() + end +end + +if not address or not description then usage() end + +-- For now default to use address as the repository name +local repo, repohome = address, aaudit.repohome(address) + +-- Create repository + write config +os.execute(([[ +mkdir -p %s; cd %s +git init --quiet --bare +]]):format(repohome, repohome)) + +aaudit.write_file(("%s/aaudit.conf"):format(repohome), ([[ +address = "%s"; +description = "%s"; +groups = { %s }; +]]):format(address, description, table.concat(groups, ', '))) + +aaudit.write_file(("%s/description"):format(repohome), ("%s (%s)"):format(description, address)) + +-- Initial import of configuration +aaudit.import_commit(repohome, C) |