* Added configuration pages for Dropbear, HTTPd, Mount Points
authorSteven Barth <steven@midlink.org>
Mon, 7 Apr 2008 21:01:39 +0000 (21:01 +0000)
committerSteven Barth <steven@midlink.org>
Mon, 7 Apr 2008 21:01:39 +0000 (21:01 +0000)
* Reorganized menu structure
* Prepare firmware upgrade mechanism

17 files changed:
contrib/ffluci-flash [new file with mode: 0644]
contrib/package/ffluci/Makefile
contrib/uci/luci
src/ffluci/controller/admin/mesh.lua [deleted file]
src/ffluci/controller/admin/services.lua [new file with mode: 0644]
src/ffluci/controller/admin/system.lua
src/ffluci/menu.lua
src/ffluci/model/cbi/admin_index/luci.lua
src/ffluci/model/cbi/admin_mesh/olsrd.lua [deleted file]
src/ffluci/model/cbi/admin_services/dropbear.lua [new file with mode: 0644]
src/ffluci/model/cbi/admin_services/httpd.lua [new file with mode: 0644]
src/ffluci/model/cbi/admin_services/olsrd.lua [new file with mode: 0644]
src/ffluci/model/cbi/admin_system/fstab.lua [new file with mode: 0644]
src/ffluci/model/menu/00main.lua
src/ffluci/view/admin_services/index.htm [new file with mode: 0644]
src/ffluci/view/admin_system/packages.htm
src/ffluci/view/admin_system/upgrade.htm [new file with mode: 0644]

diff --git a/contrib/ffluci-flash b/contrib/ffluci-flash
new file mode 100644 (file)
index 0000000..3ff478f
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+. /etc/functions.sh
+
+# initialize defaults
+RAMFS_COPY_BIN=""       # extra programs for temporary ramfs root
+RAMFS_COPY_DATA=""      # extra data files
+export KEEP_PATTERN=""
+export VERBOSE=1
+
+# parse options
+while [ -n "$1" ]; do
+        case "$1" in
+                -k)
+                               shift
+                               export KEEP_PATTERN="$1"
+                ;;
+                -*)
+                        echo "Invalid option: $1"
+                        exit 1
+                ;;
+                *) break;;
+        esac
+        shift;
+done
+
+export CONFFILES=/tmp/sysupgrade.conffiles
+export CONF_TAR=/tmp/sysupgrade.tgz
+
+[ -f $CONFFILES ] && rm $CONFFILES
+[ -f $CONF_TAR ]  && rm $CONF_TAR
+
+export ARGV="$*"
+export ARGC="$#"
+
+[ -z "$ARGV" ] && {
+        cat <<EOF
+Usage: $0 [options] <image file or URL>
+
+Options:
+        -k     <"file 1, file 2, ..."> Files to be kept
+EOF
+        exit 1
+}
+
+add_pattern_conffiles() {
+       local file="$1"
+       find $KEEP_PATTERN >> "$file" 2>/dev/null
+       return 0
+}
+
+# hooks
+sysupgrade_image_check="platform_check_image"
+sysupgrade_init_conffiles=""
+
+[ -n "$KEEP_PATTERN" ] && append sysupgrade_init_conffiles "add_pattern_conffiles"
+
+include /lib/upgrade
+
+do_save_conffiles() {
+        [ -z "$(rootfs_type)" ] && {
+                echo "Cannot save config while running from ramdisk."
+                exit 3
+                return 0
+        }
+        run_hooks "$CONFFILES" $sysupgrade_init_conffiles
+
+        v "Saving config files..."
+        [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
+        tar c${TAR_V}zf "$CONF_TAR" -T "$CONFFILES" 2>/dev/null
+}
+
+type platform_check_image >/dev/null 2>/dev/null || {
+        echo "Firmware upgrade is not implemented for this platform."
+        exit 1
+}
+
+for check in $sysupgrade_image_check; do
+        ( eval "$check \"\$ARGV\"" ) || {
+                echo "Image check '$check' failed."
+                exit 2
+        }
+done
+
+[ -n "$sysupgrade_init_conffiles" ] && do_save_conffiles
+run_hooks "" $sysupgrade_pre_upgrade
+
+v "Switching to ramdisk..."
+run_ramfs '. /etc/functions.sh; include /lib/upgrade; do_upgrade'
\ No newline at end of file
index f10476e..ba11dea 100644 (file)
@@ -40,6 +40,7 @@ define Package/ffluci/install
        $(INSTALL_DIR) $(1)/www/ffluci
        $(INSTALL_DIR) $(1)/etc/config
        $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_DIR) $(1)/sbin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/contrib/init.d/luci_fw $(1)/etc/init.d/luci_fw
        $(CP) $(PKG_BUILD_DIR)/dist/* $(1)/usr/lib/lua/ -R
        $(CP) $(PKG_BUILD_DIR)/contrib/media $(1)/www/ffluci/ -R
@@ -47,6 +48,7 @@ define Package/ffluci/install
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/contrib/ffluci-upload $(1)/www/cgi-bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/contrib/index.cgi $(1)/www/cgi-bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/contrib/index.html $(1)/www
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/contrib/ffluci-flash $(1)/sbin
        $(CP) $(PKG_BUILD_DIR)/contrib/uci/luci $(1)/etc/config/luci
        $(CP) $(PKG_BUILD_DIR)/contrib/uci/luci_fw $(1)/etc/config/luci_fw
        $(CP) -a ./ipkg/ffluci.postinst $(1)/CONTROL/postinst
index ba9ad47..46795cb 100644 (file)
@@ -4,6 +4,9 @@ config core main
         
 config core category_privileges
                option public nobody:nogroup
+               
+config extern flash
+               option keep "/etc/config /etc/dropbear /etc/openvpn /etc/passwd /etc/ipkg.conf /etc/httpd.conf /etc/firewall.user"
 
 config public contact
                option nickname
@@ -20,4 +23,7 @@ config event uci_oncommit
         option wireless        "/etc/init.d/network restart"
         option olsrd   "/etc/init.d/olsrd restart"
         option dhcp            "/etc/init.d/dhcp restart"
-        option luci_fw  "/etc/init.d/luci_fw restart"
\ No newline at end of file
+        option luci_fw  "/etc/init.d/luci_fw restart"
+        option dropbear "/etc/init.d/dropbear restart"
+        option httpd   "/etc/init.d/httpd restart"
+        option fstab   "/etc/init.d/fstab restart"
\ No newline at end of file
diff --git a/src/ffluci/controller/admin/mesh.lua b/src/ffluci/controller/admin/mesh.lua
deleted file mode 100644 (file)
index 3dbe98c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-module("ffluci.controller.admin.mesh", package.seeall)
\ No newline at end of file
diff --git a/src/ffluci/controller/admin/services.lua b/src/ffluci/controller/admin/services.lua
new file mode 100644 (file)
index 0000000..4218121
--- /dev/null
@@ -0,0 +1 @@
+module("ffluci.controller.admin.services", package.seeall)
\ No newline at end of file
index fc31ea2..102ce99 100644 (file)
@@ -173,4 +173,8 @@ function action_sshkeys()
        end
        
        ffluci.template.render("admin_system/sshkeys", {cnt=cnt, msg=err})      
+end
+
+function action_upgrade()
+       -- To be implemented
 end
\ No newline at end of file
index 5a5f421..0a1aad5 100644 (file)
@@ -47,7 +47,7 @@ local menuc = {}
 
 -- Adds a menu category to the current menu and selects it
 function add(cat, controller, title, order)
-       order = order or 50
+       order = order or 100
        if not menu[cat] then
                menu[cat] = {}
        end
index ec6c222..eed626c 100644 (file)
@@ -5,6 +5,9 @@ c = m:section(NamedSection, "main", "core", "Allgemein")
 c:option(Value, "lang", "Sprache")
 c:option(Value, "mediaurlbase", "Mediaverzeichnis")
 
+f = m:section(NamedSection, "flash", "extern", "Firmwareupgrade")
+f:option(Value, "keep", "Übernehme Dateien").size = 64
+
 p = m:section(NamedSection, "category_privileges", "core", "Kategorieprivilegien")
 p.dynamic = true
 
diff --git a/src/ffluci/model/cbi/admin_mesh/olsrd.lua b/src/ffluci/model/cbi/admin_mesh/olsrd.lua
deleted file mode 100644 (file)
index 430b786..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
--- ToDo: Autodetect things, Translate, Add descriptions
-require("ffluci.fs")
-
-m = Map("olsr", "OLSR")
-
-s = m:section(NamedSection, "general", "olsr", "Allgemeine Einstellungen")
-
-debug = s:option(ListValue, "DebugLevel", "Debugmodus")
-for i=0, 9 do
-       debug:value(i)
-end
-
-ipv = s:option(ListValue, "IpVersion", "Internet Protokoll")
-ipv:value("4", "IPv4")
-ipv:value("6", "IPv6")
-
-noint = s:option(Flag, "AllowNoInt", "Start ohne Netzwerk")
-noint.enabled = "yes"
-noint.disabled = "no"
-
-s:option(Value, "Pollrate", "Abfragerate (Pollrate)", "s").isnumber = true
-
-tcr = s:option(ListValue, "TcRedundancy", "TC-Redundanz")
-tcr:value("0", "MPR-Selektoren")
-tcr:value("1", "MPR-Selektoren und MPR")
-tcr:value("2", "Alle Nachbarn")
-
-s:option(Value, "MprCoverage", "MPR-Erfassung").isinteger = true
-
-lql = s:option(ListValue, "LinkQualityLevel", "VQ-Level")
-lql:value("0", "deaktiviert")
-lql:value("1", "MPR-Auswahl")
-lql:value("2", "MPR-Auswahl und Routing")
-
-lqfish = s:option(Flag, "LinkQualityFishEye", "VQ-Fisheye")
-
-s:option(Value, "LinkQualityWinSize", "VQ-Fenstergröße").isinteger = true
-
-s:option(Value, "LinkQualityDijkstraLimit", "VQ-Dijkstralimit")
-
-hyst = s:option(Flag, "UseHysteresis", "Hysterese aktivieren")
-hyst.enabled = "yes"
-hyst.disabled = "no"
-
-
-i = m:section(TypedSection, "Interface", "Schnittstellen")
-i.anonymous = true
-i.addremove = true
-i.dynamic = true
-
-i:option(Value, "Interface", "Netzwerkschnittstellen")
-
-i:option(Value, "HelloInterval", "Hello-Intervall").isnumber = true
-
-i:option(Value, "HelloValidityTime", "Hello-Gültigkeit").isnumber = true
-
-i:option(Value, "TcInterval", "TC-Intervall").isnumber = true
-
-i:option(Value, "TcValidityTime", "TC-Gültigkeit").isnumber = true
-
-i:option(Value, "MidInterval", "MID-Intervall").isnumber = true
-
-i:option(Value, "MidValidityTime", "MID-Gültigkeit").isnumber = true
-
-i:option(Value, "HnaInterval", "HNA-Intervall").isnumber = true
-
-i:option(Value, "HnaValidityTime", "HNA-Gültigkeit").isnumber = true
-
-
-p = m:section(TypedSection, "LoadPlugin", "Plugins")
-p.addremove = true
-p.dynamic = true
-
-lib = p:option(ListValue, "Library", "Bibliothek")
-lib:value("")
-for k, v in pairs(ffluci.fs.dir("/usr/lib")) do
-       if v:sub(1, 6) == "olsrd_" then
-               lib:value(v)
-       end
-end
-
-return m
\ No newline at end of file
diff --git a/src/ffluci/model/cbi/admin_services/dropbear.lua b/src/ffluci/model/cbi/admin_services/dropbear.lua
new file mode 100644 (file)
index 0000000..b8fcb9e
--- /dev/null
@@ -0,0 +1,14 @@
+-- ToDo: Translate, Add descriptions
+m = Map("dropbear", "SSH-Server")
+
+s = m:section(TypedSection, "dropbear")
+s.anonymous = true
+
+port = s:option(Value, "Port", "Port")
+port.isinteger = true
+
+pwauth = s:option(Flag, "PasswordAuth", "Passwortanmeldung")
+pwauth.enabled = 'on'
+pwauth.disabled = 'off'
+
+return m
\ No newline at end of file
diff --git a/src/ffluci/model/cbi/admin_services/httpd.lua b/src/ffluci/model/cbi/admin_services/httpd.lua
new file mode 100644 (file)
index 0000000..f89dbb7
--- /dev/null
@@ -0,0 +1,18 @@
+-- ToDo: Translate, Add descriptions
+m = Map("httpd", "HTTP-Server")
+
+s = m:section(TypedSection, "httpd")
+s.anonymous = true
+
+port = s:option(Value, "port", "Port")
+port.isinteger = true
+
+s:option(Value, "home", "Wurzelverzeichnis")
+
+config = s:option(Value, "c_file", "Konfigurationsdatei", "/etc/httpd.conf wenn leer")
+config.rmempty = true
+
+realm = s:option(Value, "realm", "Anmeldeaufforderung")
+realm.rmempty = true
+
+return m
\ No newline at end of file
diff --git a/src/ffluci/model/cbi/admin_services/olsrd.lua b/src/ffluci/model/cbi/admin_services/olsrd.lua
new file mode 100644 (file)
index 0000000..430b786
--- /dev/null
@@ -0,0 +1,82 @@
+-- ToDo: Autodetect things, Translate, Add descriptions
+require("ffluci.fs")
+
+m = Map("olsr", "OLSR")
+
+s = m:section(NamedSection, "general", "olsr", "Allgemeine Einstellungen")
+
+debug = s:option(ListValue, "DebugLevel", "Debugmodus")
+for i=0, 9 do
+       debug:value(i)
+end
+
+ipv = s:option(ListValue, "IpVersion", "Internet Protokoll")
+ipv:value("4", "IPv4")
+ipv:value("6", "IPv6")
+
+noint = s:option(Flag, "AllowNoInt", "Start ohne Netzwerk")
+noint.enabled = "yes"
+noint.disabled = "no"
+
+s:option(Value, "Pollrate", "Abfragerate (Pollrate)", "s").isnumber = true
+
+tcr = s:option(ListValue, "TcRedundancy", "TC-Redundanz")
+tcr:value("0", "MPR-Selektoren")
+tcr:value("1", "MPR-Selektoren und MPR")
+tcr:value("2", "Alle Nachbarn")
+
+s:option(Value, "MprCoverage", "MPR-Erfassung").isinteger = true
+
+lql = s:option(ListValue, "LinkQualityLevel", "VQ-Level")
+lql:value("0", "deaktiviert")
+lql:value("1", "MPR-Auswahl")
+lql:value("2", "MPR-Auswahl und Routing")
+
+lqfish = s:option(Flag, "LinkQualityFishEye", "VQ-Fisheye")
+
+s:option(Value, "LinkQualityWinSize", "VQ-Fenstergröße").isinteger = true
+
+s:option(Value, "LinkQualityDijkstraLimit", "VQ-Dijkstralimit")
+
+hyst = s:option(Flag, "UseHysteresis", "Hysterese aktivieren")
+hyst.enabled = "yes"
+hyst.disabled = "no"
+
+
+i = m:section(TypedSection, "Interface", "Schnittstellen")
+i.anonymous = true
+i.addremove = true
+i.dynamic = true
+
+i:option(Value, "Interface", "Netzwerkschnittstellen")
+
+i:option(Value, "HelloInterval", "Hello-Intervall").isnumber = true
+
+i:option(Value, "HelloValidityTime", "Hello-Gültigkeit").isnumber = true
+
+i:option(Value, "TcInterval", "TC-Intervall").isnumber = true
+
+i:option(Value, "TcValidityTime", "TC-Gültigkeit").isnumber = true
+
+i:option(Value, "MidInterval", "MID-Intervall").isnumber = true
+
+i:option(Value, "MidValidityTime", "MID-Gültigkeit").isnumber = true
+
+i:option(Value, "HnaInterval", "HNA-Intervall").isnumber = true
+
+i:option(Value, "HnaValidityTime", "HNA-Gültigkeit").isnumber = true
+
+
+p = m:section(TypedSection, "LoadPlugin", "Plugins")
+p.addremove = true
+p.dynamic = true
+
+lib = p:option(ListValue, "Library", "Bibliothek")
+lib:value("")
+for k, v in pairs(ffluci.fs.dir("/usr/lib")) do
+       if v:sub(1, 6) == "olsrd_" then
+               lib:value(v)
+       end
+end
+
+return m
\ No newline at end of file
diff --git a/src/ffluci/model/cbi/admin_system/fstab.lua b/src/ffluci/model/cbi/admin_system/fstab.lua
new file mode 100644 (file)
index 0000000..cf9a483
--- /dev/null
@@ -0,0 +1,21 @@
+m = Map("fstab", "Einhängepunkte")
+
+mount = m:section(TypedSection, "mount", "Einhängepunkte")
+mount.anonymous = true
+mount.addremove = true
+
+mount:option(Flag, "enabled", "aktivieren")
+mount:option(Value, "device", "Gerät")
+mount:option(Value, "target", "Einhängepunkt")
+mount:option(Value, "fstype", "Dateisystem")
+mount:option(Value, "options", "Optionen")
+
+
+swap = m:section(TypedSection, "swap", "SWAP")
+swap.anonymous = true
+swap.addremove = true
+
+swap:option(Flag, "enabled", "aktivieren")
+swap:option(Value, "device", "Gerät")
+
+return m
index e0bd403..d1c535f 100644 (file)
@@ -4,17 +4,22 @@ act("contact", "Kontakt")
 
 
 add("admin", "index", "Übersicht", 10)
-act("luci", "FFLuCI")
 act("contact", "Kontakt")
+act("luci", "FFLuCI")
 
 add("admin", "system", "System", 20)
 act("packages", "Paketverwaltung")
 act("passwd", "Passwort ändern")
 act("sshkeys", "SSH-Schlüssel")
-act("ipkg", "IPKG-Konfiguration")
+act("fstab", "Einhängepunkte")
 act("reboot", "Neu starten")
 
-add("admin", "network", "Netzwerk", 30)
+add("admin", "services", "Dienste", 30)
+act("olsrd", "OLSR")
+act("httpd", "HTTP-Server")
+act("dropbear", "SSH-Server")
+
+add("admin", "network", "Netzwerk", 40)
 act("vlan", "Switch")
 act("ifaces", "Schnittstellen")
 act("ptp", "PPPoE / PPTP")
@@ -22,9 +27,6 @@ act("routes", "Statische Routen")
 act("portfw", "Portweiterleitung")
 act("firewall", "Firewall")
 
-add("admin", "wifi", "Drahtlos", 40)
+add("admin", "wifi", "Drahtlos", 50)
 act("devices", "Geräte")
-act("networks", "Netze")
-
-add("admin", "mesh", "Mesh", 50)
-act("olsrd", "OLSR")
\ No newline at end of file
+act("networks", "Netze")
\ No newline at end of file
diff --git a/src/ffluci/view/admin_services/index.htm b/src/ffluci/view/admin_services/index.htm
new file mode 100644 (file)
index 0000000..75aa026
--- /dev/null
@@ -0,0 +1,2 @@
+<%+header%>
+<%+footer%>
\ No newline at end of file
index ef27f36..d9cdb4d 100644 (file)
@@ -23,6 +23,7 @@
 <% end %>
 
 <div>
+<a href="<%=controller%>/admin/system/ipkg"><%:packages_ipkg Paketlisten und Installationsziele bearbeiten%></a><br />
 <a href="<%=controller%>/admin/system/packages?update=1"><%:packages_updatelist Paketlisten aktualisieren%></a><br />
 <a href="<%=controller%>/admin/system/packages?upgrade=1"><%:packages_upgrade Installierte Pakete aktualisieren%></a>
 </div>
diff --git a/src/ffluci/view/admin_system/upgrade.htm b/src/ffluci/view/admin_system/upgrade.htm
new file mode 100644 (file)
index 0000000..e7a8f2f
--- /dev/null
@@ -0,0 +1,26 @@
+<%+header%>
+<h1><%:system System%></h1>
+<h2><%:upgrade Upgrade%></h2>
+<br />
+<% if sysupgrade then %>
+<form method="post" action="<%=controller%>-upload/admin/system/upgrade" enctype="multipart/form-data">
+       <fieldset class="cbi-section-node">
+               <div class="cbi-value clear">
+                       <div class="cbi-value-title left"><%:fwimage Firmwareimage%></div>
+                       <div class="cbi-value-field"><input type="file" size="30" name="image" /></div>
+               </div>
+               <br />
+               <div class="cbi-value clear">
+                       <input type="checkbox" name="keepcfg" value="1" checked="checked" />
+                       <span class="bold"><%:keepcfg Konfigurationsdateien übernehmen%></span>
+               </div>
+               <br />
+               <div>
+                       <input type="submit" value="<%:fwupgrade Firmware aktualisieren%>" />
+               </div>
+       </fieldset>
+</form>
+<% else %>
+<div class="error"><%:notimplemented Diese Funktion ist leider (noch) nicht eingebaut.%></div>
+<% end %>
+<%+footer%>
\ No newline at end of file