gluon/package/gluon-authorized-keys/luasrc/lib/gluon/upgrade/100-authorized-keys
2019-06-16 22:51:53 +02:00

23 lines
369 B
Lua
Executable File

#!/usr/bin/lua
local site = require 'gluon.site'
local file = '/etc/dropbear/authorized_keys'
local keys = {}
local function load_keys()
for line in io.lines(file) do
keys[line] = true
end
end
pcall(load_keys)
local f = io.open(file, 'a')
for _, key in ipairs(site.authorized_keys()) do
if not keys[key] then
f:write(key .. '\n')
end
end
f:close()