summaryrefslogtreecommitdiff
path: root/bin/gitano-update-ssh.in
blob: 136d6dffc33fe51f2f2d760c369c7c3ed406699d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-- @@SHEBANG
-- -*- Lua -*-
-- gitano-auth
--
-- Git (with) Augmented network operations -- User authentication wrapper
--
-- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
--
--

-- @@GITANO_LUA_PATH

local gitano = require "gitano"
local gall = require "gall"
local luxio = require "luxio"
local sio = require "luxio.simple"
local sp = require "luxio.subprocess"

-- @@GITANO_BIN_PATH
-- @@GITANO_SHARE_PATH
-- @@GITANO_PLUGIN_PATH

local repo_root = ...

gitano.config.repo_path(repo_root)
gitano.log.bump_level(gitano.log.level.CHAT)
gitano.log.syslog.open()

-- Now load the administration data

local admin_repo = gall.repository.new((repo_root or "") .. "/gitano-admin.git")

if not admin_repo then
   gitano.log.error("Usage: gitano-update-ssh /path/to/repos")
   gitano.log.fatal("Unable to locate administration repository.  Cannot continue");
end

local admin_head = admin_repo:get(admin_repo.HEAD)

if not admin_head then
   gitano.log.fatal("Unable to find the HEAD of the administration repository.  Cannot continue");
end

local config, msg = gitano.config.parse(admin_head)

if not config then
   gitano.log.critical("Unable to parse administration repository.")
   gitano.log.critical("  * " .. (msg or "No error?"))
   gitano.log.fatal("Cannot continue")
end

gitano.config.writessh(config)

gitano.log.syslog.close()

return 0