Browse Source

Adds ffho-config-mode-site-select

Modified Version of gluon-config-mode-site-select
i18n Support added
Karsten Böddeker 8 years ago
parent
commit
95d1c8eef6

+ 39 - 0
ffpb/ffho-config-mode-site-select/Makefile

@@ -0,0 +1,39 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ffho-config-mode-site-select
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
+
+define Package/ffho-config-mode-site-select
+  SECTION:=gluon
+  CATEGORY:=Gluon
+  TITLE:=UI for changing the node-config
+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)
+endef
+
+define Package/ffho-config-mode-site-select/install
+	mkdir -p $(1)/etc/config/
+	mkdir -p $(1)/lib/gluon/site-select/
+	$(CP) ./files/* $(1)/
+	$(CP) $(GLUON_SITEDIR)/extra/* $(1)/lib/gluon/site-select/
+	DIR=$(1) sh create-config.sh
+	$(call GluonInstallI18N,ffho-config-mode-site-select,$(1))
+endef
+
+$(eval $(call BuildPackage,ffho-config-mode-site-select))

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

@@ -0,0 +1,16 @@
+ffho-config-mode-site-select
+======================
+
+This Repository contains a Gluon package to choose between different site.conf files after flashing the image. <br>
+This does not apply to the site.mk!
+
+This is a modified Version of gluon-config-mode-site-select
+
+Usage
+-----
+* Rename your site-files to site_code.conf (E.g. ffki.conf, ffhh.conf)
+* copy your renamed site-files to $gluondir/site/extra/
+
+<br>
+Das ganze sieht dann so aus: <br>
+![](http://labor19.net/Hendrik/preview1.png)

+ 21 - 0
ffpb/ffho-config-mode-site-select/create-config.sh

@@ -0,0 +1,21 @@
+#!/bin/sh
+
+echo "" > "$DIR"/etc/config/siteselect
+
+dir -1 "$GLUON_SITEDIR"/extra/ | while read FILE
+do
+site_name="$(cat "$GLUON_SITEDIR"/extra/"$FILE" | grep "site_name" | sed "s/site_name =//; s/,//")"
+site_code="$(cat "$GLUON_SITEDIR"/extra/"$FILE" | grep "site_code" | sed "s/site_code =//; s/,//")"
+
+echo "config site"$site_code"" >> "$DIR"/etc/config/siteselect
+echo "    option path '/lib/gluon/site-select/"$FILE"'" >> "$DIR"/etc/config/siteselect
+echo "    option sitename"$site_name"" >> "$DIR"/etc/config/siteselect
+echo "" >> "$DIR"/etc/config/siteselect
+
+done
+
+current_site="$(cat "$GLUON_SITEDIR"/site.conf | grep "site_code" | sed "s/site_code =//; s/,//")"
+
+echo "config site 'current'" >> "$DIR"/etc/config/currentsite
+echo "    option name"$current_site"" >> "$DIR"/etc/config/currentsite
+echo "" >> "$DIR"/etc/config/currentsite

+ 51 - 0
ffpb/ffho-config-mode-site-select/files/lib/gluon/config-mode/wizard/0200-site-select.lua

@@ -0,0 +1,51 @@
+local cbi = require "luci.cbi"
+local i18n = require "luci.i18n"
+local uci = luci.model.uci.cursor()
+local site = require 'gluon.site_config'
+local fs = require "nixio.fs"
+
+local sites = {}
+local M = {}
+
+function M.section(form)
+	
+	local msg = i18n.translate('Here you have the possibility of selecting the region in which ' ..
+                               'your node is placed. Please keep in mind that your router ' ..
+                               'connects only with the mesh of the selected region')
+	local s = form:section(cbi.SimpleSection, nil, msg)
+	
+	uci:foreach('siteselect', 'site',
+	function(s)
+		table.insert(sites, s['.name'])
+	end
+	)
+	
+	local o = s:option(cbi.ListValue, "community", i18n.translate("Region"))
+	o.rmempty = false
+	o.optional = false
+
+	if uci:get_first("gluon-setup-mode", "setup_mode", "configured") == "0" then
+		o:value("")
+	else
+		o:value(site.site_code, site.site_name)
+	end
+
+	for index, site in ipairs(sites) do
+		o:value(site, uci:get('siteselect', site, 'sitename'))
+	end
+
+end
+
+function M.handle(data)
+
+	if data.community ~= site.site_code then
+		
+		fs.copy(uci:get('siteselect', data.community , 'path'), '/lib/gluon/site.conf')
+		uci:set('currentsite', 'current', 'name', data.community)
+		uci:save('currentsite')
+		uci:commit('currentsite')		
+		os.execute('sh "/lib/gluon/site-upgrade"')
+	end
+end
+
+return M

+ 6 - 0
ffpb/ffho-config-mode-site-select/files/lib/gluon/site-upgrade

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

+ 27 - 0
ffpb/ffho-config-mode-site-select/files/lib/gluon/upgrade/002-set-site-config

@@ -0,0 +1,27 @@
+#!/usr/bin/lua
+
+local uci = require 'luci.model.uci'
+local site = require 'gluon.site_config'
+local fs = require "nixio.fs"
+local c = uci.cursor()
+
+local currentsite = c:get("currentsite", "current", "name")
+
+local file = "/etc/sysupgrade.conf"
+local configured = false
+
+for line in io.lines(file) do
+  if line == "/etc/config/currentsite" then
+    configured = true
+  end
+end
+
+if configured == false then
+  f = io.open(file,"a")
+  f:write("/etc/config/currentsite\n")
+  f:close()
+end
+
+if site.site_name ~= c:get('siteselect', currentsite, 'sitename') then
+  fs.copy(c:get('siteselect', currentsite , 'path'), '/lib/gluon/site.conf')
+end

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

@@ -0,0 +1,24 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: 2015-10-30 20:44+0100\n"
+"Last-Translator: Karsten Böddeker <freifunk@kb-light.de>\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 ""
+"Here you have the possibility of selecting the region in which "
+"your node is placed. Please keep in mind that your router "
+"connects only with the mesh of the selected region"
+msgstr ""
+"Hier hast du die Möglichkeit die Region, in der sich dein "
+"Knoten befindet, auszuwählen. Bitte denke daran, dass dein Router "
+"sich nur mit dem Netz der ausgewählten Region verbindet."
+
+msgid "Region"
+msgstr "Region"
+

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

@@ -0,0 +1,11 @@
+msgid ""
+msgstr "Content-Type: text/plain; charset=UTF-8"
+
+msgid ""
+"Here you have the possibility of selecting the region in which "
+"your node is placed. Please keep in mind that your router "
+"connects only with the mesh of the selected region"
+msgstr ""
+
+msgid "Region"
+msgstr ""