diff --git a/package/gluon-config-mode-autoupdater-freifunk/Makefile b/package/gluon-config-mode-autoupdater-freifunk/Makefile new file mode 100644 index 00000000..7ac6bedd --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/Makefile @@ -0,0 +1,14 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-config-mode-autoupdater-freifunk +PKG_VERSION:=1 + +include ../gluon.mk + +define Package/gluon-config-mode-autoupdater-freifunk + TITLE:=Config Mode: Ask the user for consent regarding automatic updates based on Freifunk's Memorandum of Understanding. This includes a view for the wizzard and for the admin section + DEPENDS:=+gluon-config-mode-core +gluon-autoupdater + CONFLICTS:=gluon-config-mode-autoupdater gluon-web-autoupdater +endef + +$(eval $(call BuildPackageGluon,gluon-config-mode-autoupdater-freifunk)) diff --git a/package/gluon-config-mode-autoupdater-freifunk/Readme.md b/package/gluon-config-mode-autoupdater-freifunk/Readme.md new file mode 100644 index 00000000..5aefbb26 --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/Readme.md @@ -0,0 +1,35 @@ +# gluon-config-mode-autoupdater-freifunk + +The package gluon-config-mode-autoupdater-freifunk provides an + alternative to both gluon-config-mode-autoupdater and gluon-web-autoupdater. +By replacing both packages, gluon-config-mode-autoupdater-freifunk it cannot be installed in combination: Both +have to be missing from site.mk. + +Users are asked for consent before enabling automatic updates. This follows (Freifunk's +Memorandum of understanding)[https://github.com/freifunk/MoU]. The question is asked using radio-buttons without any defaults. It is neither opt-in nor opt-out. + +To maintain compatibility with existing setups and keep defaults, enabling updates and giving consent is handled differently. + +* By giving or revoking consent, users can enable or disable automatic updates +* If automatic-updates are enabled, but consent is not given, +a message is shown telling, that consent was given out of band. By that, defaults from gluon-config-mode-autoupdater +and gluon-web-autoupdater are implemented. +* If consent is given, but updates are disabled (e.g. manually using the shell), the form is inactive. + + +By default, the dialog uses (slightly modified) texts from the Freifunk MoU. The texts can be adjusted using site-specific +i18n-files. + +These texts are used: + +| Key (e.g. in `site/i18n/de.po` ) | English | German | +|---|---|---| +| autoupdater-freifunk:description | Node operators have the choice to allow remote maintenance. Interventions on the nodes via automatic firmware upgrades are done with explicit agreement of the respective operators. You can configure automatic updates in the Advanced settings section. | Die Knotenbetreiber*innen haben die Wahl, sich für Fernwartung zu entscheiden. Eingriffe in die Knoten, z.B. Firmwareupdates oder andere Fernwartungsarbeiten geschehen immer mit dem ausdrücklichen Einverständnis der jeweiligen Betreibenden. Weitere Einstellungen findest Du im Bereich Erweiterte Einstellungen. | +| autoupdater-freifunk:constent_assumed |

You have already agreed to remote maintenance via automatic upgrades by downloading and using this software. |

Du hast Dich schon mit dem Download und der Benutzung dieser Firmware für eine Fernwartung mittels automatischer Updates entschieden. | +| autoupdater-freifunk:disabled_on_shell |

You have disabled automatic updates after giving consent. |

Du hast zugestimmt, aber die Updates ausgeschaltet. | +| autoupdater-freifunk:option_dissent | Disable - I do not agree | Deaktivieren - ich stimme nicht zu | +| autoupdater-freifunk:option_consent | Enable - I agree | Aktivieren - ich stimme zu | +| autoupdater-freifunk:option_name | Remote Maintenance via Automatic Updates | Fernwartung mittels automatischer Updates | +| autoupdater-freifunk:description_admin | Node operators have the choice to allow remote maintenance. Interventions on the nodes via automatic firmware upgrades are done with explicit agreement of the respective operators. | Die Knotenbetreiber*innen haben die Wahl, sich für Fernwartung zu entscheiden. Eingriffe in die Knoten, z.B. Firmwareupdates oder andere Fernwartungsarbeiten geschehen immer mit dem ausdrücklichen Einverständnis der jeweiligen Betreibenden. | +| autoupdater-freifunk:constent_assumed_admin |

You have already agreed to remote maintenance via automatic upgrades by downloading and using this software.
You can disable automatic updates by selecting no branch.
|

Du hast Dich schon mit dem Download und der Benutzung dieser Firmware für eine Fernwartung mittels automatischer Updates entschieden.
Du kannst den Auto-Updater deaktivieren, indem Du keinen Branch auswählst.
| +| autoupdater-freifunk:disabled_on_shell_admin |

You have manually disabled automatic updates after giving consent. |

Du hast zugestimmt, aber die Updates manuell ausgeschaltet (z.B. per shell) | diff --git a/package/gluon-config-mode-autoupdater-freifunk/files/etc/config/autoupdater-freifunk b/package/gluon-config-mode-autoupdater-freifunk/files/etc/config/autoupdater-freifunk new file mode 100644 index 00000000..58416bfc --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/files/etc/config/autoupdater-freifunk @@ -0,0 +1,2 @@ +config consent 'consent' +# option given '0' diff --git a/package/gluon-config-mode-autoupdater-freifunk/files/lib/gluon/web/view/model/gluon-config-mode-autoupdater-freifunk.html b/package/gluon-config-mode-autoupdater-freifunk/files/lib/gluon/web/view/model/gluon-config-mode-autoupdater-freifunk.html new file mode 100644 index 00000000..67c6c27b --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/files/lib/gluon/web/view/model/gluon-config-mode-autoupdater-freifunk.html @@ -0,0 +1,46 @@ +<% +local br = self.orientation == "horizontal" and '   ' or '
' +local entries = self:entries() +%> + +<% if self.widget == "select" then %> + +<% elseif self.widget == "radio" then %> +

+ <% for i, entry in pairs(entries) do %> + > + /> + > + <%|entry.value%> + + <% if i ~= #entries then write(br) end %> + <% end %> +
+<% end %> diff --git a/package/gluon-config-mode-autoupdater-freifunk/i18n/de.po b/package/gluon-config-mode-autoupdater-freifunk/i18n/de.po new file mode 100644 index 00000000..06235f39 --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/i18n/de.po @@ -0,0 +1,122 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: \n" +"PO-Revision-Date: 2019-05-04 16:49+0200\n" +"Last-Translator: jan \n" +"Language-Team: German\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"POT-Creation-Date: \n" +"X-Generator: Poedit 1.8.11\n" + +msgid "" +"

You have already agreed to remote maintenance " +"via automatic upgrades by downloading and using this software.
You " +"can disable automatic updates by selecting no branch.
" +msgstr "" +"

Du hast Dich schon mit dem Download und der " +"Benutzung dieser Firmware für eine Fernwartung mittels automatischer Updates " +"entschieden.
Du kannst den Auto-Updater deaktivieren, indem Du keinen " +"Branch auswählst.
" + +msgid "" +"

You have already agreed to remote maintenance " +"via automatic upgrades by downloading and using this software." +msgstr "" +"

Du hast Dich schon mit dem Download und der " +"Benutzung dieser Firmware für eine Fernwartung mittels automatischer Updates " +"entschieden. " + +msgid "

You have disabled automatic updates after giving consent." +msgstr "

Du hast zugestimmt, aber die Updates ausgeschaltet." + +msgid "

You have manually disabled automatic updates after giving consent." +msgstr "" +"

Du hast zugestimmt, aber die Updates manuell ausgeschaltet (z.B. per " +"shell)" + +msgid "Automatic updates" +msgstr "Automatische Updates" + +msgid "Branch" +msgstr "Branch" + +msgid "Disable - I do not agree" +msgstr "Deaktivieren - ich stimme nicht zu" + +msgid "Enable - I agree" +msgstr "Aktivieren - ich stimme zu" + +msgid "" +"Node operators have the choice to allow remote maintenance. Interventions on " +"the nodes via automatic firmware upgrades are done with explicit agreement " +"of the respective operators." +msgstr "" +"Die Knotenbetreiber*innen haben die Wahl, sich für Fernwartung zu " +"entscheiden. Eingriffe in die Knoten, z.B. Firmwareupdates oder andere " +"Fernwartungsarbeiten geschehen immer mit dem ausdrücklichen Einverständnis " +"der jeweiligen Betreibenden." + +msgid "" +"Node operators have the choice to allow remote maintenance. Interventions on " +"the nodes via automatic firmware upgrades are done with explicit agreement " +"of the respective operators. You can configure automatic updates in the Advanced settings section." +msgstr "" +"Die Knotenbetreiber*innen haben die Wahl, sich für Fernwartung zu " +"entscheiden. Eingriffe in die Knoten, z.B. Firmwareupdates oder andere " +"Fernwartungsarbeiten geschehen immer mit dem ausdrücklichen Einverständnis " +"der jeweiligen Betreibenden. Weitere Einstellungen findest Du im Bereich Erweiterte Einstellungen." + +msgid "" +"Pick a branch to receive updates from. If you disable automatic updates, " +"this branch is used when executing autoupdater using the command shell. " +"Selecting no branch disables automatic updates." +msgstr "" +"Wähle einen Branch aus, von dem Du automatisches Updates erhalten willst. " +"Falls automatische Updates deaktiviert sind, so wird der Branch als default " +"verwendet, wenn Du den autoupdater von der Shell aus aufrufst. Ist der " +"Branch leer, so werden keine automatischen Updates installiert." + +msgid "Remote Maintenance via Automatic Updates" +msgstr "Fernwartung mittels automatischer Updates" + +msgid "autoupdater-freifunk:constent_assumed" +msgstr "" + +msgid "autoupdater-freifunk:description" +msgstr "" + +msgid "autoupdater-freifunk:disabled_on_shell" +msgstr "" + +msgid "autoupdater-freifunk:option_consent" +msgstr "" + +msgid "autoupdater-freifunk:option_dissent" +msgstr "" + +msgid "autoupdater-freifunk:option_name" +msgstr "" + +msgid "gluon-autoupdater-freifunk:constent_assumed_admin" +msgstr "" + +msgid "gluon-autoupdater-freifunk:description_admin" +msgstr "" + +msgid "gluon-autoupdater-freifunk:disabled_on_shell_admin" +msgstr "" + +msgid "gluon-autoupdater-freifunk:option_consent" +msgstr "" + +msgid "gluon-autoupdater-freifunk:option_dissent" +msgstr "" + +msgid "gluon-autoupdater-freifunk:option_name" +msgstr "" diff --git a/package/gluon-config-mode-autoupdater-freifunk/i18n/gluon-config-mode-autoupdater-freifunk.pot b/package/gluon-config-mode-autoupdater-freifunk/i18n/gluon-config-mode-autoupdater-freifunk.pot new file mode 100644 index 00000000..dcc0fe96 --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/i18n/gluon-config-mode-autoupdater-freifunk.pot @@ -0,0 +1,89 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "" +"

You have already agreed to remote maintenance " +"via automatic upgrades by downloading and using this software.
You " +"can disable automatic updates by selecting no branch.
" +msgstr "" + +msgid "" +"

You have already agreed to remote maintenance " +"via automatic upgrades by downloading and using this software." +msgstr "" + +msgid "

You have disabled automatic updates after giving consent." +msgstr "" + +msgid "

You have manually disabled automatic updates after giving consent." +msgstr "" + +msgid "Automatic updates" +msgstr "" + +msgid "Branch" +msgstr "" + +msgid "Disable - I do not agree" +msgstr "" + +msgid "Enable - I agree" +msgstr "" + +msgid "" +"Node operators have the choice to allow remote maintenance. Interventions on " +"the nodes via automatic firmware upgrades are done with explicit agreement " +"of the respective operators." +msgstr "" + +msgid "" +"Node operators have the choice to allow remote maintenance. Interventions on " +"the nodes via automatic firmware upgrades are done with explicit agreement " +"of the respective operators. You can configure automatic updates in the Advanced settings section." +msgstr "" + +msgid "" +"Pick a branch to receive updates from. If you disable automatic updates, " +"this branch is used when executing autoupdater using the command shell. " +"Selecting no branch disables automatic updates." +msgstr "" + +msgid "Remote Maintenance via Automatic Updates" +msgstr "" + +msgid "autoupdater-freifunk:constent_assumed" +msgstr "" + +msgid "autoupdater-freifunk:description" +msgstr "" + +msgid "autoupdater-freifunk:disabled_on_shell" +msgstr "" + +msgid "autoupdater-freifunk:option_consent" +msgstr "" + +msgid "autoupdater-freifunk:option_dissent" +msgstr "" + +msgid "autoupdater-freifunk:option_name" +msgstr "" + +msgid "gluon-autoupdater-freifunk:constent_assumed_admin" +msgstr "" + +msgid "gluon-autoupdater-freifunk:description_admin" +msgstr "" + +msgid "gluon-autoupdater-freifunk:disabled_on_shell_admin" +msgstr "" + +msgid "gluon-autoupdater-freifunk:option_consent" +msgstr "" + +msgid "gluon-autoupdater-freifunk:option_dissent" +msgstr "" + +msgid "gluon-autoupdater-freifunk:option_name" +msgstr "" diff --git a/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/controller/admin/autoupdater.lua b/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/controller/admin/autoupdater.lua new file mode 100644 index 00000000..e2623561 --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/controller/admin/autoupdater.lua @@ -0,0 +1,3 @@ +package 'gluon-config-mode-autoupdater-freifunk' + +entry({"admin", "autoupdater"}, model("admin/autoupdater"), _("Automatic updates"), 80) diff --git a/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/model/admin/autoupdater.lua b/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/model/admin/autoupdater.lua new file mode 100644 index 00000000..5ec0fa33 --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/model/admin/autoupdater.lua @@ -0,0 +1,106 @@ +local pkg_i18n = i18n 'gluon-config-mode-autoupdater-freifunk' +local site_i18n = i18n 'gluon-site' + +local uci = require("simple-uci").cursor() +local autoupdater = uci:get_first("autoupdater", "autoupdater") + + +local consent = uci:get_bool("autoupdater-freifunk", "consent", "given") +local enabled = uci:get_bool("autoupdater", "settings", "enabled") + +-- Usually, the form is active and users can make a choice regarding constent +-- One exception: Automatic Updates are enabled by default without given consent + +-- This exception is based in the idea expressed in the discussion for bug #1618: To be compatible +-- with existing installation, Automatic updates can be enabled network-wide without asking users for consent +-- This is relevant, for networks using automatic updates, only. +local formActive = true + +-- Usually, giving consent to automatic updates enables automatic updates. (as expected by users) +-- Again, there's one exception: If automatic updates are disabled, but consent is given, then we don't +-- enable automatic updates (since the question is already answered) - a message is shown instead +local changeAutomaticUpdates = true + +local storedValue = uci:get("autoupdater-freifunk", "consent", "given") + +-- By default, it is assmed, that out of band consent is not given. +local warningMsg = '' +if enabled and not consent then + warningMsg = site_i18n._translate('autoupdater-freifunk:constent_assumed_admin') or pkg_i18n.translate('

' + .. ' You have already agreed to remote maintenance via automatic' + .. ' upgrades by downloading and using this software.
You can disable automatic updates by selecting no branch.
') + formActive = false +end + +if not enabled and consent then + warningMsg = site_i18n._translate('autoupdater-freifunk:disabled_on_shell_admin') or + pkg_i18n.translate('

You have manually disabled automatic updates after giving consent.') + formActive = false +end + +local f = Form(pkg_i18n.translate("Automatic updates")) +local s = f:section(Section,nil, site_i18n._translate('autoupdater-freifunk:description_admin') + or pkg_i18n.translate('Node operators have the choice to allow remote maintenance. '.. + 'Interventions on the nodes via automatic firmware upgrades are done with explicit agreement of the ' .. + 'respective operators.') .. ' ' .. warningMsg) +local o + +local option_name = site_i18n._translate('autoupdater-freifunk:option_name') or + pkg_i18n.translate("Remote Maintenance via Automatic Updates") + +local dissent_option = site_i18n._translate('autoupdater-freifunk:option_dissent') or + pkg_i18n.translate("Disable - I do not agree") +local consent_option = site_i18n._translate('autoupdater-freifunk:option_consent') or + pkg_i18n.translate("Enable - I agree") + +configValue = s:option(ListValue, 'given', option_name) +configValue.default = storedValue +configValue.subtemplate = "model/gluon-config-mode-autoupdater-freifunk" +-- Override entries to remove empty default option from optional field +function configValue:entries() + return {unpack(self.entry_list)} +end +configValue.widget = "radio" +configValue:value("0" , dissent_option) +configValue:value("1" , consent_option) + +-- Inactive form => No choice possible +if not formActive then + configValue.disabled = true + configValue.optional = true + configValue.default = uci:get("autoupdater", "settings", "enabled") +end + +function configValue:write(data) + if(formActive) then + uci:set("autoupdater-freifunk", "consent", "given", data) + if(formActive and changeAutomaticUpdates) then + uci:set("autoupdater", "settings", "enabled", data) + end + end + +end + + +local s = f:section(Section,pkg_i18n.translate('Branch'), site_i18n._translate('autoupdater-freifunk:description_admin') or pkg_i18n.translate('Pick a branch to receive updates from. If you disable automatic' + ..' updates, this branch is used when executing autoupdater using the command shell.' + .. ' Selecting no branch disables automatic updates.')) + +o = s:option(ListValue, "branch", pkg_i18n.translate("Branch")) +o.optional = true +uci:foreach("autoupdater", "branch", + function (section) + o:value(section[".name"]) + end +) +o.default = uci:get("autoupdater", autoupdater, "branch") +function o:write(data) + uci:set("autoupdater", autoupdater, "branch", data) +end + +function f:write() + uci:commit("autoupdater") + uci:commit("autoupdater-freifunk") +end + +return f diff --git a/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/wizard/0450-autoupdater-freifunk.lua b/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/wizard/0450-autoupdater-freifunk.lua new file mode 100644 index 00000000..65706aed --- /dev/null +++ b/package/gluon-config-mode-autoupdater-freifunk/luasrc/lib/gluon/config-mode/wizard/0450-autoupdater-freifunk.lua @@ -0,0 +1,91 @@ +return function(form, uci) + local pkg_i18n = i18n 'gluon-config-mode-autoupdater-freifunk' + local site_i18n = i18n 'gluon-site' + + + local consent = uci:get_bool("autoupdater-freifunk", "consent", "given") + local enabled = uci:get_bool("autoupdater", "settings", "enabled") + + -- Usually, the form is active and users can make a choice regarding constent + -- One exception: Automatic Updates are enabled by default without given consent + + -- This exception is based in the idea expressed in the discussion for bug #1618: To be compatible + -- with existing installation, Automatic updates can be enabled network-wide without asking users for consent + -- This is relevant, for networks using automatic updates, only. + local formActive = true + + -- Usually, giving consent to automatic updates enables automatic updates. (as expected by users) + -- Again, there's one exception: If automatic updates are disabled, but consent is given, then we don't + -- enable automatic updates (since the question is already answered) - a message is shown instead + local changeAutomaticUpdates = true + + local storedValue = uci:get("autoupdater-freifunk", "consent", "given") + + -- By default, it is assmed, that out of band consent is not given. + local warningMsg = '' + if enabled and not consent then + warningMsg = site_i18n._translate('autoupdater-freifunk:constent_assumed') + or pkg_i18n.translate('

You have already agreed to remote maintenance via automatic' + ..' upgrades by downloading and using this software.') + formActive = false + end + + if not enabled and consent then + warningMsg = site_i18n._translate('autoupdater-freifunk:disabled_on_shell') + or pkg_i18n.translate('

You have disabled automatic updates after giving consent.') + formActive = false + end + + local section_desc = site_i18n._translate('autoupdater-freifunk:description') + or pkg_i18n.translate('Node operators have the choice to allow remote maintenance. '.. + 'Interventions on the nodes via automatic firmware upgrades are done with explicit agreement of the ' .. + 'respective operators. You can configure automatic updates in the'.. + ' Advanced settings section.') + + section = form:section(Section, '', section_desc..' '..warningMsg) + + + local option_name = site_i18n._translate('autoupdater-freifunk:option_name') or + pkg_i18n.translate("Remote Maintenance via Automatic Updates") + + local dissent_option = site_i18n._translate('autoupdater-freifunk:option_dissent') or + pkg_i18n.translate("Disable - I do not agree") + local consent_option = site_i18n._translate('autoupdater-freifunk:option_consent') or + pkg_i18n.translate("Enable - I agree") + + configValue = section:option(ListValue, 'given', option_name) + configValue.subtemplate = "model/gluon-config-mode-autoupdater-freifunk" + configValue.default = storedValue + configValue.widget = "radio" + configValue:value("0" , dissent_option) + configValue:value("1" , consent_option) + + -- Override entries to remove empty default option from optional field + function configValue:entries() + return {unpack(self.entry_list)} + end + + + -- Inactive form => No choice possible + if not formActive then + configValue.disabled = true + configValue.optional = true + configValue.default = uci:get("autoupdater", "settings", "enabled") + end + + function configValue:write(data) + if(formActive) then + uci:set("autoupdater-freifunk", "consent", "given", data) + if(formActive and changeAutomaticUpdates) then + uci:set("autoupdater", "settings", "enabled", data) + end + end + + end + if (formActive) then + return {'autoupdater-freifunk', 'autoupdater' } + else + return {} + end + +end