Skip to content
Snippets Groups Projects
Commit 53e56b08 authored by Nils Schneider's avatar Nils Schneider
Browse files

Merge pull request #74 from freifunk-gluon/authorized-keys

gluon-authorized-keys: add keys from site.conf
parents f21678dc a753fa79
No related branches found
No related tags found
No related merge requests found
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-authorized-keys
PKG_VERSION:=2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(GLUONDIR)/include/package.mk
define Package/gluon-authorized-keys
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Fill /etc/dropbear/authorized_keys from site.conf
DEPENDS:=+gluon-core
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/gluon-authorized-keys/install
$(CP) ./files/* $(1)/
endef
define Package/gluon-authorized-keys/postinst
#!/bin/sh
$(call GluonCheckSite,check_site.lua)
endef
$(eval $(call BuildPackage,gluon-authorized-keys))
need_string_array 'authorized_keys'
#!/usr/bin/lua
local site = require 'gluon.site_config'
local file = '/etc/dropbear/authorized_keys'
local keys = {}
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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment