summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2016-08-27 15:59:27 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2016-08-27 15:59:27 +0100
commit7210d1a2cfb33e870901629b2423a2f183c08954 (patch)
treef87b9b40139ea001dedab20a5ee132385c28c53b /bin
parente3e7951c1c1c6f465ffa8150ce395a98f4d3afd5 (diff)
downloadgitano-7210d1a2cfb33e870901629b2423a2f183c08954.tar.gz
Initial i18n/l10n of gitano-setup
Diffstat (limited to 'bin')
-rw-r--r--bin/gitano-setup.in118
1 files changed, 53 insertions, 65 deletions
diff --git a/bin/gitano-setup.in b/bin/gitano-setup.in
index 20ad343..e61012a 100644
--- a/bin/gitano-setup.in
+++ b/bin/gitano-setup.in
@@ -26,24 +26,9 @@ local possible_answers = {...}
if possible_answers[1] == "--help" or
possible_answers[1] == "-h" or
possible_answers[1] == "--usage" then
- sio.stderr:write([[
-usage: gitano-setup [<answers-file>...]
-
-This tool creates the basic repository setup for a Gitano instance.
-
-This is an interactive tool where if it has any questions for you, it will
-visit each answers file in turn until it finds the answer. This means
-that for automation purposes you can specify multiple answers files with
-the earlier ones overriding the later ones.
-
-In summary, the behaviour is as follows:
-
-The repository root is created if it does not exist, and a gitano-admin.git
-repository is created within it. Said repository is populated with the
-example administration repository rules and an admin user and group.
-]])
- return 1
-end
+ sio.stderr:write(gitano.i18n.expand("SETUP_USAGE"))
+ return 1
+end
local conf = clod.parse("")
@@ -51,51 +36,51 @@ gitano.log.set_prefix("gitano-setup")
gitano.log.bump_level(gitano.log.level.CHAT)
for i = #possible_answers, 1, -1 do
- gitano.log.debug("Parsing answers file:", possible_answers[1])
+ gitano.log.debug(gitano.i18n.expand("SETUP_DEBUG_PARSING_ANSWERS", { file=possible_answers[1] }))
local one_conf = assert(clod.parse(assert(io.open(possible_answers[1], "r")):read "*a",
"@" .. possible_answers[1]))
- gitano.log.debug("Combining answers into conf...")
+ gitano.log.debug(gitano.i18n.expand("SETUP_DEBUG_COMBINE_ANSWERS"))
for k,v in one_conf:each() do
gitano.log.ddebug(tostring(k) .. " = " .. tostring(v))
conf.settings[k] = v
end
end
-gitano.log.chat("Welcome to the Gitano setup process")
+gitano.log.chat(gitano.i18n.expand("SETUP_WELCOME"))
-gitano.log.chat("Performing system checks")
+gitano.log.chat(gitano.i18n.expand("SETUP_DO_CHECKS"))
-- Check that Supple functions properly
local ok, msg = pcall(function()
- gitano.log.chat("... Checking supple sandboxing")
+ gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE"))
local s = require 'supple'
local ok, a, b, c = s.host.run("return ...", "test", 12, 'hello', true)
if not ok then
- gitano.log.chat("... Supple unable to run trivial sandboxed code")
+ gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_UNABLE"))
os.exit(1)
end
if a ~= 12 or b ~= "hello" or c ~= true then
- gitano.log.chat("... Supple unable to pass trivial values in and out")
+ gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_VALUES"))
os.exit(1)
end
local ok, v = s.host.run("local a = ...\nreturn a.banana", "test", {banana=14})
if not ok then
- gitano.log.chat("... Supple unable to run trivial sandboxed code")
+ gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_UNABLE"))
os.exit(1)
end
if v ~= 14 then
- gitano.log.chat("... Supple unable to communicate bidirectionally")
+ gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_BIDIRECTIONAL"))
os.exit(1)
end
end)
if not ok then
- gitano.log.chat("... Unable to run supple test")
+ gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_FAILED"))
gitano.log.chat("... " .. tostring(msg))
os.exit(1)
end
-gitano.log.chat("System checks out")
+gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_OK"))
function get(key)
return conf.settings[key]
@@ -113,7 +98,8 @@ function ask_for(key, prompt, default)
cur_value = new_value
end
end
- gitano.log.info("Setting:", key, "is", tostring(cur_value))
+ gitano.log.info(gitano.i18n.expand("SETUP_SETTING_IS",
+ { key = key, value = tostring(cur_value)}))
conf.settings[key] = cur_value
return cur_value
end
@@ -124,7 +110,7 @@ function look_for_path(path)
return false, path .. ": " .. luxio.strerror(stat)
end
if luxio.S_ISDIR(stat.mode) == 0 then
- return false, path .. ": not a directory"
+ return false, gitano.i18n.expand("SETUP_NOT_A_DIR", { path=path })
end
return true
end
@@ -147,22 +133,22 @@ end
function validate_name(n)
if not n:match("^[a-z_][a-z0-9_%-]*$") then
- error("Invalid name: " .. n, 2)
+ error(gitano.i18n.expand("SETUP_ERROR_INVALID_NAME", { name=n }), 2)
end
end
if conf.settings["setup.batch"] then
- gitano.log.info("Batch mode engaged")
+ gitano.log.info(gitano.i18n.expand("SETUP_BATCH_MODE"))
else
- gitano.log.info("Interactive mode engaged")
+ gitano.log.info(gitano.i18n.expand("SETUP_INTERACTIVE_MODE"))
end
-gitano.log.chat("Step 1: Determine everything")
+gitano.log.chat(gitano.i18n.expand("SETUP_STEP_1"))
-validate_path(ask_for("paths.home", "Home directory for new Gitano user",
+validate_path(ask_for("paths.home", gitano.i18n.expand("SETUP_PATHS_HOME_INFO"),
os.getenv "HOME"))
-ask_for("paths.ssh", "SSH directory for new Gitano user",
+ask_for("paths.ssh", gitano.i18n.expand("SETUP_PATHS_SSH_INFO"),
get("paths.home") .. "/.ssh")
local pubkey_path
@@ -177,34 +163,34 @@ if look_for_path(get("paths.ssh")) then
end
end
-assert(file_exists(ask_for("paths.pubkey", "Public key file for admin user",
+assert(file_exists(ask_for("paths.pubkey", gitano.i18n.expand("SETUP_PATHS_PUBKEY_INFO"),
pubkey_path)),
- "Cannot find public key")
+ gitano.i18n.expand("SETUP_PATHS_PUBKEY_NOT_FOUND"))
-ask_for("paths.repos", "Repository path for new Gitano instance",
+ask_for("paths.repos", gitano.i18n.expand("SETUP_PATHS_REPOS_INFO"),
get("paths.home") .. "/repos")
-validate_name(ask_for("admin.username", "User name for admin user",
+validate_name(ask_for("admin.username", gitano.i18n.expand("SETUP_ADMIN_USERNAME_INFO"),
"admin"))
-ask_for("admin.realname", "Real name for admin user",
+ask_for("admin.realname", gitano.i18n.expand("SETUP_ADMIN_REALNAME_INFO"),
"Administrator")
-ask_for("admin.email", "Email address for admin user",
+ask_for("admin.email", gitano.i18n.expand("SETUP_ADMIN_EMAIL_INFO"),
"admin@administrator.local")
-validate_name(ask_for("admin.keyname", "Key name for administrator",
+validate_name(ask_for("admin.keyname", gitano.i18n.expand("SETUP_ADMIN_KEYNAME_INFO"),
"default"))
-ask_for("site.name", "Site name", "a random Gitano instance")
-ask_for("log.prefix", "Site log prefix", "gitano")
-ask_for("use.htpasswd", "Store passwords with htpasswd? (needed for http authentication)", "no")
+ask_for("site.name", gitano.i18n.expand("SETUP_SITE_NAME_INFO"), "a random Gitano instance")
+ask_for("log.prefix", gitano.i18n.expand("SETUP_LOG_PREFIX_INFO"), "gitano")
+ask_for("use.htpasswd", gitano.i18n.expand("SETUP_USE_HTPASSWD_INFO"), "no")
-ask_for("paths.skel", "Path to skeleton gitano-admin content",
+ask_for("paths.skel", gitano.i18n.expand("SETUP_PATHS_SKEL_INFO"),
gitano.config.share_path() .. "/skel/gitano-admin")
-gitano.log.chat("Step 2: Gather required content")
+gitano.log.chat(gitano.i18n.expand("SETUP_STEP_2"))
-gitano.log.info("=> Prepare site config")
+gitano.log.info(gitano.i18n.expand("SETUP_PREP_SITE_CONFIG"))
local completely_flat = {}
local site_conf = clod.parse("")
site_conf.settings["site_name"] = get "site.name"
@@ -213,7 +199,7 @@ site_conf.settings["use_htpasswd"] = get "use.htpasswd"
completely_flat["site.conf"] = site_conf:serialise()
-- Acquire the contents of the skeleton gitano-admin repository
-gitano.log.info("=> Acquire skeleton gitano-admin")
+gitano.log.info(gitano.i18n.expand("SETUP_ACQUIRE_SKEL"))
local skel_path = get "paths.skel"
local skel = assert(sio.opendir(skel_path))
local function acquire(dir, base, path)
@@ -238,7 +224,7 @@ acquire(skel, "", skel_path)
skel:close()
-- Now build the user files
-gitano.log.info("=> Preparing administration user (" .. get("admin.username") .. ")")
+gitano.log.info(gitano.i18n.expand("SETUP_PREP_ADMIN_USER", {user=get("admin.username")}))
local userpath = "users/" .. get("admin.username") .. "/user.conf"
local keypath = "users/" .. get("admin.username") .. "/" .. get("admin.keyname") .. ".key"
local userconf = clod.parse("")
@@ -248,32 +234,32 @@ completely_flat[userpath] = userconf:serialise()
completely_flat[keypath] = assert(sio.open(get("paths.pubkey"), "r")):read "*a"
-- And now the gitano-admin group
-gitano.log.info("=> Preparing gitano-admin group")
+gitano.log.info(gitano.i18n.expand("SETUP_PREP_GITANO_ADMIN"))
local groupconf = clod.parse("")
groupconf.settings.description = "Gitano Instance Administrators"
groupconf.settings["members.*"] = get("admin.username")
completely_flat["groups/gitano-admin.conf"] = groupconf:serialise()
-gitano.log.chat("Step 3: Write out paths and gitano-admin.git")
+gitano.log.chat(gitano.i18n.expand("SETUP_STEP_3"))
-gitano.log.info("=> Make paths")
+gitano.log.info(gitano.i18n.expand("SETUP_MAKE_PATHS"))
gitano.util.mkdir_p(get("paths.repos") .. "/.graveyard")
gitano.util.mkdir_p(get "paths.ssh")
assert(sio.chmod(get "paths.ssh", "0700"))
gitano.config.repo_path(get "paths.repos")
-gitano.log.info("=> Prepare repository")
+gitano.log.info(gitano.i18n.expand("SETUP_PREPARE_REPO"))
local raw_repo = assert(gall.repository.create(get("paths.repos") ..
"/gitano-admin.git"))
-gitano.log.info("=> Create a flattened tree")
+gitano.log.info(gitano.i18n.expand("SETUP_PREPARE_FLAT_TREE"))
for k, v in pairs(completely_flat) do
gitano.log.debug(" => Make object", k)
completely_flat[k] = gall.object.create(raw_repo, "blob", v)
end
-gitano.log.info("=> Commit that tree")
+gitano.log.info(gitano.i18n.expand("SETUP_PREPARE_COMMIT"))
local real_tree = assert(gall.tree.create(raw_repo, completely_flat))
local person = {
@@ -289,17 +275,17 @@ local commit_data = {
local commit_obj = assert(gall.commit.create(raw_repo, commit_data))
-gitano.log.info("=> Attach that commit to master")
+gitano.log.info(gitano.i18n.expand("SETUP_PREPARE_MASTER"))
assert(raw_repo:update_ref("refs/heads/master", commit_obj.sha,
"Create initial master ref"))
-gitano.log.info("=> Ensure we can parse our resultant admin repository")
+gitano.log.info(gitano.i18n.expand("SETUP_CHECK_ADMIN_REPO"))
local admin_head = raw_repo:get(raw_repo.HEAD)
if not admin_head then
- gitano.log.fatal("Unable to find the HEAD of the administration repository. Cannot continue");
+ gitano.log.fatal(gitano.i18n.expand("ERROR_BAD_ADMIN_REPO"));
end
local config = assert(gitano.config.parse(admin_head))
@@ -307,15 +293,17 @@ local config = assert(gitano.config.parse(admin_head))
gitano.log.set_prefix("gitano-setup")
-- Verify that our user exists
-assert(config.users[get "admin.username"], "Could not find user")
+assert(config.users[get "admin.username"], gitano.i18n.expand("SETUP_ERROR_NO_USER"))
assert(config.groups["gitano-admin"].filtered_members[get "admin.username"],
- "User was not a gitano-admin")
+ gitano.i18n.expand("SETUP_ERROR_NOT_ADMIN"))
-gitano.log.info("=> Change the admin ref for gitano-admin.git")
+gitano.log.info(gitano.i18n.expand("SETUP_ADMIN_CONFIG"))
config.repo:set_description("Instance administration repository")
config.repo:set_owner(get "admin.username")
-gitano.log.info("=> Write the SSH authorized_keys file out")
+gitano.log.info(gitano.i18n.expand("SETUP_WRITE_SSHKEYS"))
gitano.config.writessh(config, get("paths.ssh") .. "/authorized_keys")
assert(sio.chmod(get("paths.ssh") .. "/authorized_keys", "0600"))
+
+gitano.log.info(gitano.i18n.expand("SETUP_COMPLETED"))