luci-mod-failsafe: kill old failsafe mod
authorDaniel Golle <daniel@makrotopia.org>
Wed, 24 Feb 2021 14:38:30 +0000 (14:38 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 24 Feb 2021 14:40:10 +0000 (14:40 +0000)
It's been unmaintained for ages and became useless.
Better just limit regular luci-mod-admin to only show basic
functionality in case `ubus call system board` indicates we are running
off initramfs.

Singed-off-by: Daniel Golle <daniel@makrotopia.org>
modules/luci-mod-failsafe/Makefile [deleted file]
modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua [deleted file]
modules/luci-mod-failsafe/luasrc/view/failsafe/applyreboot.htm [deleted file]
modules/luci-mod-failsafe/luasrc/view/failsafe/flashops.htm [deleted file]
modules/luci-mod-failsafe/luasrc/view/failsafe/reboot.htm [deleted file]
modules/luci-mod-failsafe/luasrc/view/failsafe/upgrade.htm [deleted file]
themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/header.htm
themes/luci-theme-openwrt/luasrc/view/themes/openwrt.org/header.htm

diff --git a/modules/luci-mod-failsafe/Makefile b/modules/luci-mod-failsafe/Makefile
deleted file mode 100644 (file)
index 8afc614..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
-#
-# This is free software, licensed under the Apache License, Version 2.0 .
-#
-
-include $(TOPDIR)/rules.mk
-
-LUCI_TITLE:=LuCI Fail-Safe - Fail-Safe sysupgrade module
-LUCI_DEPENDS:=+luci-base
-
-include ../../luci.mk
-
-# call BuildPackage - OpenWrt buildroot signature
-
diff --git a/modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua b/modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua
deleted file mode 100644 (file)
index 60caadb..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
--- Copyright 2012 Daniel Golle <dgolle@allnet.de>
--- Licensed to the public under the Apache License 2.0.
-
-module("luci.controller.failsafe.failsafe", package.seeall)
-
-function index()
-       local root = node()
-       if not root.target then
-               root.target = alias("failsafe")
-               root.index = true
-       end
-
-       page          = node()
-       page.lock     = true
-       page.target   = alias("failsafe")
-       page.subindex = true
-       page.index    = false
-
-       page          = node("failsafe")
-       page.title    = _("Fail-safe")
-       page.target   = alias("failsafe", "flashops")
-       page.order    = 5
-       page.setuser  = "root"
-       page.setgroup = "root"
-       page.index    = true
-
-       entry({"failsafe", "flashops"}, call("action_flashops"), _("Flash Firmware"), 70).index = true
-       entry({"failsafe", "reboot"}, call("action_reboot"), _("Reboot"), 90)
-end
-
-function action_flashops()
-       local sys = require "luci.sys"
-       local fs  = require "nixio.fs"
-
-       local upgrade_avail = fs.access("/lib/upgrade/platform.sh")
-       local reset_avail   = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
-
-       local image_tmp   = "/tmp/firmware.img"
-
-       local function image_supported()
-               -- XXX: yay...
-               return ( 0 == os.execute(
-                       ". /lib/functions.sh; " ..
-                       "include /lib/upgrade; " ..
-                       "platform_check_image %q >/dev/null"
-                               % image_tmp
-               ) )
-       end
-
-       local function image_checksum()
-               return (luci.sys.exec("md5sum %q" % image_tmp):match("^([^%s]+)"))
-       end
-
-       local function storage_size()
-               local size = 0
-               if fs.access("/proc/mtd") then
-                       for l in io.lines("/proc/mtd") do
-                               local d, s, e, n = l:match('^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+"([^%s]+)"')
-                               if n == "linux" or n == "firmware" then
-                                       size = tonumber(s, 16)
-                                       break
-                               end
-                       end
-               elseif fs.access("/proc/partitions") then
-                       for l in io.lines("/proc/partitions") do
-                               local x, y, b, n = l:match('^%s*(%d+)%s+(%d+)%s+([^%s]+)%s+([^%s]+)')
-                               if b and n and not n:match('[0-9]') then
-                                       size = tonumber(b) * 1024
-                                       break
-                               end
-                       end
-               end
-               return size
-       end
-
-
-       local fp
-       luci.http.setfilehandler(
-               function(meta, chunk, eof)
-                       if not fp then
-                               if meta and meta.name == "image" then
-                                       fp = io.open(image_tmp, "w")
-                               end
-                       end
-                       if fp then
-                               if chunk then
-                                       fp:write(chunk)
-                               end
-                               if eof then
-                                       fp:close()
-                               end
-                       end
-               end
-       )
-
-       if luci.http.formvalue("image") or luci.http.formvalue("step") then
-               --
-               -- Initiate firmware flash
-               --
-               local step = tonumber(luci.http.formvalue("step") or 1)
-               if step == 1 then
-                       if image_supported() then
-                               luci.template.render("failsafe/upgrade", {
-                                       checksum = image_checksum(),
-                                       storage  = storage_size(),
-                                       size     = (fs.stat(image_tmp, "size") or 0),
-                                       keep     = false
-                               })
-                       else
-                               fs.unlink(image_tmp)
-                               luci.template.render("failsafe/flashops", {
-                                       reset_avail   = reset_avail,
-                                       upgrade_avail = upgrade_avail,
-                                       image_invalid = true
-                               })
-                       end
-               --
-               -- Start sysupgrade flash
-               --
-               elseif step == 2 then
-                       local keep = (luci.http.formvalue("keep") == "1") and "" or "-n"
-                       luci.template.render("failsafe/applyreboot", {
-                               title = luci.i18n.translate("Flashing..."),
-                               msg   = luci.i18n.translate("The system is flashing now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a few minutes before you try to reconnect. It might be necessary to renew the address of your computer to reach the device again, depending on your settings."),
-                               addr  = (#keep > 0) and "192.168.1.1" or nil
-                       })
-                       fork_exec("killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %q" %{ keep, image_tmp })
-               end
-       else
-               --
-               -- Overview
-               --
-               luci.template.render("failsafe/flashops", {
-                       reset_avail   = reset_avail,
-                       upgrade_avail = upgrade_avail
-               })
-       end
-end
-
-function action_reboot()
-       local reboot = luci.http.formvalue("reboot")
-       luci.template.render("failsafe/reboot", {reboot=reboot})
-       if reboot then
-               luci.sys.reboot()
-       end
-end
-
-function fork_exec(command)
-       local pid = nixio.fork()
-       if pid > 0 then
-               return
-       elseif pid == 0 then
-               -- change to root dir
-               nixio.chdir("/")
-
-               -- patch stdin, out, err to /dev/null
-               local null = nixio.open("/dev/null", "w+")
-               if null then
-                       nixio.dup(null, nixio.stderr)
-                       nixio.dup(null, nixio.stdout)
-                       nixio.dup(null, nixio.stdin)
-                       if null:fileno() > 2 then
-                               null:close()
-                       end
-               end
-
-               -- replace with target command
-               nixio.exec("/bin/sh", "-c", command)
-       end
-end
-
-function ltn12_popen(command)
-
-       local fdi, fdo = nixio.pipe()
-       local pid = nixio.fork()
-
-       if pid > 0 then
-               fdo:close()
-               local close
-               return function()
-                       local buffer = fdi:read(2048)
-                       local wpid, stat = nixio.waitpid(pid, "nohang")
-                       if not close and wpid and stat == "exited" then
-                               close = true
-                       end
-
-                       if buffer and #buffer > 0 then
-                               return buffer
-                       elseif close then
-                               fdi:close()
-                               return nil
-                       end
-               end
-       elseif pid == 0 then
-               nixio.dup(fdo, nixio.stdout)
-               fdi:close()
-               fdo:close()
-               nixio.exec("/bin/sh", "-c", command)
-       end
-end
diff --git a/modules/luci-mod-failsafe/luasrc/view/failsafe/applyreboot.htm b/modules/luci-mod-failsafe/luasrc/view/failsafe/applyreboot.htm
deleted file mode 100644 (file)
index 12c138c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<html>
-       <head>
-               <title><%=luci.sys.hostname()%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %></title>
-               <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
-               <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
-               <script type="text/javascript">//<![CDATA[
-                       var interval = window.setInterval(function() {
-                               var img = new Image();
-
-                               img.onload = function() {
-                                       window.clearInterval(interval);
-                                       location.href = 'http://<%=addr or luci.http.getenv("SERVER_NAME")%>/';
-                               };
-
-                               img.src = 'http://<%=addr or luci.http.getenv("SERVER_NAME")%><%=resource%>/icons/loading.gif?' + Math.random();
-                       }, 5000);
-               //]]></script>
-       </head>
-       <body>
-               <div id="maincontainer">
-                       <div id="maincontent">
-                               <h2 name="content"><%:System%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %></h2>
-                               <fieldset class="cbi-section">
-                                       <p>
-                                               <% if msg then %><%=msg%><% else %><%:Changes applied.%><% end %>
-                                       </p>
-                                       <p>
-                                               <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
-                                               <%:Waiting for changes to be applied...%>
-                                       </p>
-                               </fieldset>
-                       </div>
-               </div>
-       </body>
-</html>
diff --git a/modules/luci-mod-failsafe/luasrc/view/failsafe/flashops.htm b/modules/luci-mod-failsafe/luasrc/view/failsafe/flashops.htm
deleted file mode 100644 (file)
index d6e9ad7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
- Copyright 2012 Daniel Golle <dgolle@allnet.de>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-
-<h2 name="content"><%:Flash operations%></h2>
-<fieldset class="cbi-section">
-       <legend><%:Flash new firmware image%></legend>
-       <% if upgrade_avail then %>
-               <form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
-                       <div class="cbi-section-descr"><%:Upload a sysupgrade-compatible image. %></div>
-                       <div class="cbi-section-node">
-                               <div class="cbi-value cbi-value-last<% if image_invalid then %> cbi-value-error<% end %>">
-                                       <label class="cbi-value-title" for="image"><%:Image%>:</label>
-                                       <div class="cbi-value-field">
-                                               <input type="file" name="image" id="image" />
-                                               <input type="submit" class="cbi-button cbi-input-apply" value="<%:Flash image...%>" />
-                                       </div>
-                               </div>
-                       </div>
-                       <% if image_invalid then %>
-                               <div class="cbi-section-error"><%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %></div>
-                       <% end %>
-               </form>
-       <% else %>
-               <div class="cbi-section-descr"><%:Sorry, there is no sysupgrade support present; a new firmware image must be flashed manually. Please refer to the wiki for device specific install instructions.%></div>
-       <% end %>
-</fieldset>
-
-<%+footer%>
diff --git a/modules/luci-mod-failsafe/luasrc/view/failsafe/reboot.htm b/modules/luci-mod-failsafe/luasrc/view/failsafe/reboot.htm
deleted file mode 100644 (file)
index cbbe13b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
- Copyright 2012 Daniel Golle <dgolle@allnet.de>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-<h2 name="content"><%:System%></h2>
-<h3><%:Reboot%></h3>
-<p><%:Reboots the operating system of your device%></p>
-<%- if not reboot then -%>
-<p><a href="<%=controller%>/failsafe/reboot?reboot=1"><%:Perform reboot%></a></p>
-<%- else -%>
-<p><%:Please wait: Device rebooting...%></p>
-<script type="text/javascript">setTimeout("location='<%=controller%>'", 60000)</script>
-<%- end -%>
-<%+footer%>
diff --git a/modules/luci-mod-failsafe/luasrc/view/failsafe/upgrade.htm b/modules/luci-mod-failsafe/luasrc/view/failsafe/upgrade.htm
deleted file mode 100644 (file)
index 3be9ae1..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008-2009 Jo-Philipp Wich <jow@openwrt.org>
- Copyright 2012 Daniel Golle <dgolle@allnet.de>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-
-<h2 name="content"><%:Flash Firmware%> - <%:Verify%></h2>
-<p>
-       <%_ The flash image was uploaded.
-               Below is the checksum and file size listed,
-               compare them with the original file to ensure data integrity.<br />
-               Click "Proceed" below to start the flash procedure. %>
-
-       <% if storage > 0 and size > storage then %>
-               <br /><br />
-               <div class="error"><%:It appears that you are trying to
-                       flash an image that does not fit into the flash memory, please verify
-                       the image file! %></div>
-       <% end %>
-
-</p>
-
-<fieldset class="cbi-section">
-       <ul>
-               <li><%:Checksum%>: <code><%=checksum%></code></li>
-               <li><%:Size%>: <%
-                       local w = require "luci.tools.webadmin"
-                       write(w.byte_format(size))
-
-                       if storage > 0 then
-                               write(luci.i18n.translatef(
-                                       " (%s available)",
-                                       w.byte_format(storage)
-                               ))
-                       end
-               %></li>
-       </ul>
-</fieldset>
-
-<div class="cbi-page-actions right">
-       <form style="display:inline" action="<%=REQUEST_URI%>" method="post">
-               <input class="cbi-button cbi-button-reset" type="submit" value="<%:Cancel%>" />
-       </form>
-       <form style="display:inline" action="<%=REQUEST_URI%>" method="post">
-               <input type="hidden" name="step" value="2" />
-               <input class="cbi-button cbi-button-apply" type="submit" value="<%:Proceed%>" />
-       </form>
-</div>
-
-<%+footer%>
index fb0842df0422f576287933438e769c1c6d8c63e9..f6ae02c212abf585e29795ef3f93c1be4d398bad 100644 (file)
@@ -50,7 +50,7 @@
        <div id="mainmenu"></div>
 
        <div id="maincontent">
-               <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") and category ~= "failsafe" and path ~= "admin-system-admin-password" then -%>
+               <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") and path ~= "admin-system-admin-password" then -%>
                <div class="alert-message warning">
                        <h4><%:No password set!%></h4>
                        <p><%:There is no password set on this router. Please configure a root password to protect the web interface.%></p>
index fafd86f35e483b8f5faae6f49d99e26bba90afef..5f79b386b203022223e9f99a8da6f422347f853f 100644 (file)
@@ -74,7 +74,7 @@
                        </div>
                </noscript>
 
-               <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") and category ~= "failsafe" then -%>
+               <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
                <div class="alert-message warning">
                        <h4><%:No password set!%></h4>
                        <p><%:There is no password set on this router. Please configure a root password to protect the web interface.%></p>