Browse Source

Remove ffho-config-mode-site-selct and ffho-site-generate

Please use upstream multidomain support and gluon-config-mode-domain-select instead.
Karsten Böddeker 6 years ago
parent
commit
e737d048cc

+ 0 - 37
ffho/ffho-config-mode-site-select/Makefile

@@ -1,37 +0,0 @@
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=ffho-config-mode-site-select
-PKG_VERSION:=0.1
-
-PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
-
-include $(TOPDIR)/../package/gluon.mk
-
-PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
-
-define Package/ffho-config-mode-site-select
-  SECTION:=ffho
-  CATEGORY:=Site-select
-  TITLE:=UI for changing the node-config
-  DEPENDS:=+gluon-config-mode-core +ffho-site-generate
-  MAINTAINER:=Freifunk Hochstift <kontakt@hochstift.freifunk.net>
-endef
-
-define Build/Prepare
-	mkdir -p $(PKG_BUILD_DIR)
-endef
-
-define Build/Configure
-endef
-
-define Build/Compile
-	$(call GluonBuildI18N,ffho-config-mode-site-select,i18n)
-	$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
-endef
-
-define Package/ffho-config-mode-site-select/install
-	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
-	$(call GluonInstallI18N,ffho-config-mode-site-select,$(1))
-endef
-
-$(eval $(call BuildPackage,ffho-config-mode-site-select))

+ 0 - 26
ffho/ffho-config-mode-site-select/README.md

@@ -1,26 +0,0 @@
-ffho-config-mode-site-select
-============================
-
-This Package provides a drop-down list for the config mode, to select the site/region
-the node will be placed in. If the selection has changed the upgrade scripts in
-`/lib/gluon/upgrade/` are triggered.
-
-site/extra/sites.conf
----------------------
-
-**site_select.hidden: optional**
-- `0`, show this site in drop-down list (default)
-- `1`, hide this site within config mode
-
-### example
-```lua
-{
-  {
-    site_select: = {
-      hidden = 1,
-    },
-    ...
-  },
-  ...
-},
-```

+ 0 - 14
ffho/ffho-config-mode-site-select/i18n/de.po

@@ -1,14 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"PO-Revision-Date: 2015-11-02 13:15+0100\n"
-"Last-Translator: Freifunk Hochstift <kontakt@hochstift.freifunk.net>\n"
-"Language-Team: German\n"
-"Language: de\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-msgid "Region"
-msgstr "Region"

+ 0 - 5
ffho/ffho-config-mode-site-select/i18n/ffho-config-mode-site-select.pot

@@ -1,5 +0,0 @@
-msgid ""
-msgstr "Content-Type: text/plain; charset=UTF-8"
-
-msgid "Region"
-msgstr ""

+ 0 - 35
ffho/ffho-config-mode-site-select/luasrc/lib/gluon/config-mode/wizard/0200-site-select.lua

@@ -1,35 +0,0 @@
-return function(form, uci)
-	local default = require 'gluon.site'
-	local tools = require 'gluon.site_generate'
-
-	local sites = tools.get_config('/lib/gluon/site-select/sites.json')
-	
-	local s = form:section(Section, nil, translate('gluon-config-mode:site-select'))
-
-	local o = s:option(ListValue, 'community', translate('Region'))
-	o.optional = false
-
-	if uci:get_bool('gluon-setup-mode', uci:get_first('gluon-setup-mode','setup_mode'), 'configured')  then
-		o:value(default.site_code(), default.site_name())
-	else
-		o:value('')
-	end
-
-	for _, site in pairs(sites) do
-		if (site.site_select or {}).hidden ~= 1 then
-			o:value(site.site_code, site.site_name)
-		end
-	end
-
-	function o:write(data)
-		if data ~= uci:get('currentsite', 'current', 'name') then
-			tools.set_site_code(data, false)
-		end
-
-		if data ~= default.site_code() then
-			os.execute('sh "/lib/gluon/site-select/site-upgrade"')
-		end
-	end
-
-	return {'currentsite'}
-end

+ 0 - 45
ffho/ffho-site-generate/Makefile

@@ -1,45 +0,0 @@
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=ffho-site-generate
-PKG_VERSION:=2
-
-PFG_BUILD_DEPENDS := lua-cjson/host
-
-PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
-
-include $(TOPDIR)/../package/gluon.mk
-
-define Package/ffho-site-generate
-  SECTION:=ffho
-  CATEGORY:=Site-select
-  TITLE:=Scripts for generating a new site.json
-  DEPENDS:=+gluon-core
-  MAINTAINER:=Freifunk Hochstift <kontakt@hochstift.freifunk.net>
-endef
-
-define Package/ffho-site-generate/description
-endef
-
-define Build/Prepare
-	mkdir -p $(PKG_BUILD_DIR)/site-select
-endef
-
-define Build/Configure
-endef
-
-define Build/Compile
-	GLUON_SITEDIR='$(call qstrip,$(CONFIG_GLUON_SITEDIR))' lua -e 'print(require("cjson").encode(assert(dofile("./scripts/sites.lua"))))' > $(PKG_BUILD_DIR)/site-select/sites.json
-	GLUON_SITEDIR='$(call qstrip,$(CONFIG_GLUON_SITEDIR))' lua -e 'print(require("cjson").encode(assert(dofile("./scripts/template.lua"))))' > $(PKG_BUILD_DIR)/site-select/template.json
-	if [ -e $(call qstrip,$(CONFIG_GLUON_SITEDIR))/extra/groups.conf  ]; then GLUON_SITEDIR='$(call qstrip,$(CONFIG_GLUON_SITEDIR))' lua -e 'print(require("cjson").encode(assert(dofile("./scripts/groups.lua"))))' >  $(PKG_BUILD_DIR)/site-select/groups.json; fi
-	$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
-endef
-
-define Package/ffho-site-generate/install
-	$(CP) ./files/* $(1)/
-	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
-
-	$(INSTALL_DIR) $(1)/lib/gluon/site-select
-	$(INSTALL_DATA) $(PKG_BUILD_DIR)/site-select/* $(1)/lib/gluon/site-select/
-endef
-
-$(eval $(call BuildPackage,ffho-site-generate))

+ 0 - 87
ffho/ffho-site-generate/ReadMe.md

@@ -1,87 +0,0 @@
-ffho-site-generate
-==================
-
-This package generates the needed `site.json` directly on the node after firmware
-upgrade has been performed. This can be used, to support different sites/regions
-within one firmware image. The default `site.json` will be replaced by
-`site/extra/template.conf` which is partially replaced by values defined in
-`site/extra/sites.conf` and `site/extra/groups.conf`.
-
-One can generate the `site.conf` before build with: `GLUON_SITEDIR=$PATH ./scripts/gen-site-conf.lua`
-
-This does not belong to the `site.mk`.
-
-/etc/config/currentsite
------------------------
-
-**currentsite.current.name:**
-- Site, the node belogs to
-
-### example
-```
-config site 'current'
-	option name 'ffho_abn'
-```
-
-site/extra/sites.conf
----------------------
-
-Array of possible sites, containing site specific configuration different to the
-original site.conf and group specific config. Same configuration as in the site.conf
-can be done here.
-
-**site_select.group: optional**
-- specify a group out of `site/extra/groups.conf` the site belongs to
-
-### example
-```
-{
-  {
-    site_name = 'Freifunk Hochstift - Altenbeken',
-    site_code = 'ffho_abn',
-    subst = {
-      ['%%ID'] = 1,
-      ['%%CD'] = 'abn',
-    },
-    site_select = {
-      group = 'ffho_ost',
-    },
-  },
-  ...
-}
-```
-
-site/extra/groups.conf
-----------------------
-
-Array of groups, containing group specific configuration different to the original
-site.conf. Same configuration as in the site.conf can be done here.
-
-### example
-```
-{
-  ffho_ost = {
-    subst = {
-      ['%%V4'] = '10.132.xxx.0/21',
-      ['%%V6'] = '2a03:2260:2342:2303::/64',
-      ...
-    },
-  },
-  ...
-}
-```
-
-site/extra/default.conf
------------------------
-
-An array, containing the default configuration, to create site.conf out of template.conf before build.
-
-### example
-```
-subst = {
-  ['%%SN'] = 'Bitte wählen',
-  ['%%SC'] = 'ffho',
-  ['%%SS'] = 'paderborn.freifunk.net',
-  ...
-}
-```

+ 0 - 2
ffho/ffho-site-generate/files/etc/config/currentsite

@@ -1,2 +0,0 @@
-config site 'current'
-	option name 'default'

+ 0 - 6
ffho/ffho-site-generate/files/lib/gluon/site-select/site-upgrade

@@ -1,6 +0,0 @@
-#!/bin/sh
-#this script is the same as zzz-gluon-upgrade
-
-for script in /lib/gluon/upgrade/*; do
-	"$script"
-done

+ 0 - 47
ffho/ffho-site-generate/luasrc/lib/gluon/upgrade/005-set-site-config

@@ -1,47 +0,0 @@
-#!/usr/bin/lua
-
-local uci = require('simple-uci').cursor()
-local site_code = require('gluon.site').site_code()
-local tools = require 'gluon.site_generate'
-
-local groups = tools.get_config('/lib/gluon/site-select/groups.json')
-local sites = tools.get_config('/lib/gluon/site-select/sites.json')
-local currentsite = uci:get('currentsite', 'current', 'name')
-
-if site_code ~= currentsite then
-  local configured = false
-  for _, site in pairs(sites) do
-    if site.site_code == currentsite then
-      local config = io.open('/lib/gluon/site-select/template.json'):read('*a')
-      local subst = {}
-      subst['%%SN'] = site.site_name
-      subst['%%SC'] = site.site_code
-
-      if site.subst then
-        config = tools.replace_patterns(config, site.subst)
-      end
-
-      if (site.site_select or {}).group and groups and groups[site.site_select.group] then
-        group = groups[site.site_select.group]
-        subst['%%GN'] = site.site_select.group
-        if group.subst then
-          config = tools.replace_patterns(config, group.subst)
-        end
-      end
-
-      config = tools.replace_patterns(config, subst)
-
-      local file = '/lib/gluon/site.json'
-      local f = io.open(file, 'w')
-      f:write(config)
-      f:close()
-
-      configured = true
-      break
-    end
-  end
-
-  if configured == false then
-    tools.set_site_code(site_code, true)
-  end
-end

+ 0 - 56
ffho/ffho-site-generate/luasrc/usr/lib/lua/gluon/site_generate.lua

@@ -1,56 +0,0 @@
-#!/usr/bin/lua
-
-local uci = require('simple-uci').cursor()
-local json =  require 'luci.jsonc'
-local sites_json = '/lib/gluon/site-select/sites.json'
-
-module('gluon.site_generate', package.seeall)
-
-function get_config(file)
-  local decoder = json.new()
-  local sink = decoder:sink()
-
-  local f = assert(io.open(file))
-
-  while true do
-    local chunk = f:read(2048)
-    if not chunk or chunk:len() == 0 then break end
-    sink(chunk)
-  end
-
-  f:close()
-
-  return assert(decoder:get())
-end
-
-function get_list()
-  local list = {}
-  local sites = get_config(sites_json)
-  for index, site in pairs(sites) do
-    list[site.site_code]=index
-  end
-  return list
-end
-
-local site_list=get_list()
-
-function validate_site(site_code)
-  return site_list[site_code]
-end
-
-function set_site_code(site_code, force)
-  if site_code and (force or validate_site(site_code)) then
-    uci:set('currentsite', 'current', 'name', site_code)
-    uci:save('currentsite')
-    uci:commit('currentsite')
-    return true
-  end
-  return false
-end
-
-function replace_patterns(value, subst)
-  for k, v in pairs(subst) do
-    value = value:gsub(k, v)
-  end
-  return value
-end

+ 0 - 17
ffho/ffho-site-generate/scripts/gen-site-conf.lua

@@ -1,17 +0,0 @@
-#!/usr/bin/lua
-
-function replace_patterns(value, subst)
-  for k, v in pairs(subst) do
-    value = value:gsub(k, v)
-  end
-  return value
-end
-
-dofile(os.getenv('GLUON_SITEDIR') ..'/extra/default.conf')
-local template = os.getenv('GLUON_SITEDIR') ..'/extra/template.conf'
-local site = os.getenv('GLUON_SITEDIR') ..'/site.conf'
-
-local config = io.open(template):read('*a')
-config = replace_patterns(config, subst)
-
-io.open(site, 'w'):write(config)

+ 0 - 9
ffho/ffho-site-generate/scripts/groups.lua

@@ -1,9 +0,0 @@
-local config = os.getenv('GLUON_SITEDIR') .. '/extra/groups.conf'
-
-local function loader()
-   coroutine.yield('return ')
-   coroutine.yield(io.open(config):read('*a'))
-end
-
--- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
-return setfenv(assert(load(coroutine.wrap(loader), 'groups.conf')), {})()

+ 0 - 9
ffho/ffho-site-generate/scripts/sites.lua

@@ -1,9 +0,0 @@
-local config = os.getenv('GLUON_SITEDIR') .. '/extra/sites.conf'
-
-local function loader()
-   coroutine.yield('return ')
-   coroutine.yield(io.open(config):read('*a'))
-end
-
--- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
-return setfenv(assert(load(coroutine.wrap(loader), 'sites.conf')), {})()

+ 0 - 9
ffho/ffho-site-generate/scripts/template.lua

@@ -1,9 +0,0 @@
-local config = os.getenv('GLUON_SITEDIR') .. '/extra/template.conf'
-
-local function loader()
-   coroutine.yield('return ')
-   coroutine.yield(io.open(config):read('*a'))
-end
-
--- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
-return setfenv(assert(load(coroutine.wrap(loader), 'template.conf')), {})()