Mudi auto shutoff

super thank you @46775456788

it works perfectly. I've been waiting for this since I purchase Mudi, 3 years ago.

if you don't mind, is it possible to add the button as a menu category? instead of being under the "MCU Control > Power Off" for it to be just aside Logout

I'll mention you as the resolution of this as well:

Its really good one thanks

1 Like

Hello,

does someone know how to set the router to standby?

Here is my idea for auto shutdown.

with help from AI I found a way to add the proper Power Off to main menu of Luci, and as well add it to the ADMIN PANEL from GL-Inet E750 main Control Panel, here it goes:

:pushpin: 1) Adding “Power Off” to the main LuCI menu

  1. SSH into your GL-E750
ssh [email protected]
  1. Create the LuCI controller
    Paste everything at once:
cat > /usr/lib/lua/luci/controller/poweroff.lua << 'EOF'
module("luci.controller.poweroff", package.seeall)

function index()
  -- Replace the old “MCU Control” with a direct “Power Off” at admin/mcu
  entry({"admin","mcu"}, call("action_poweroff"), _("Power Off"), 60).leaf = true
end

function action_poweroff()
  -- Trigger MCU shutdown over UBus, then redirect to Status
  os.execute("ubus call mcu cmd_json '{\"poweroff\":\"1\"}'")
  luci.http.redirect(luci.dispatcher.build_url("admin","status"))
end
EOF

  1. Fix permissions and reload LuCI
chmod 644 /usr/lib/lua/luci/controller/poweroff.lua
/etc/init.d/uhttpd reload

  • Now in LuCI you’ll see Power Off alongside the main menus, and clicking it immediately shuts down the modem.
  1. Make it persist across firmware upgrades
    a. Create an installer script:
cat > /usr/bin/install_poweroff << 'EOF'
#!/bin/sh
CONTROLLER="/usr/lib/lua/luci/controller/poweroff.lua"

# (Re)write the controller idempotently
cat << 'EOC' > "$CONTROLLER"
module("luci.controller.poweroff", package.seeall)

function index()
  entry({"admin","mcu"}, call("action_poweroff"), _("Power Off"), 60).leaf = true
end

function action_poweroff()
  os.execute("ubus call mcu cmd_json '{\"poweroff\":\"1\"}'")
  luci.http.redirect(luci.dispatcher.build_url("admin","status"))
end
EOC

chmod 644 "$CONTROLLER"
EOF
chmod +x /usr/bin/install_poweroff

b. Edit /etc/rc.local:

vi /etc/rc.local

Before the final exit 0, add:

# reinstall Power Off button in LuCI
/usr/bin/install_poweroff
/etc/init.d/uhttpd reload

Save and exit (Esc → :wq → Enter).From now on, on every boot (including after a sysupgrade with “Keep config”), your LuCI Power Off button will be recreated automatically.

:pushpin: 2) Injecting “Power Off” after Advanced Settings in the GL-iNet Admin Panel

  1. Locate the SPA HTML
    On the GL-E750 it’s served from:
/www/gl_home.html

  1. Create the injection snippet
cat > /tmp/poweroff_snippet.js << 'EOF'
<script>
window.addEventListener('DOMContentLoaded', function(){
  var obs = new MutationObserver(function(muts, ob){
    // Seleciona todos os tĂ­tulos de item de menu
    var titles = document.querySelectorAll('.el-menu-item > .menu-title');
    titles.forEach(function(title){
      if (title.textContent.trim() === 'Advanced Settings') {
        var parentLi = title.closest('li.el-menu-item');
        // cria novo <li> com a mesma classe e estilo
        var newLi = document.createElement('li');
        newLi.setAttribute('role','menuitem');
        newLi.setAttribute('tabindex','-1');
        newLi.className = 'el-menu-item';
        newLi.style.paddingLeft = parentLi.style.paddingLeft;
        // cria o <span><a>Power Off</a></span>
        var span = document.createElement('span');
        span.className = 'menu-title';
        var a = document.createElement('a');
        a.href = '/cgi-bin/luci/admin/mcu';
        a.textContent = 'Power Off';
        span.appendChild(a);
        newLi.appendChild(span);
        // insere logo apĂłs o Advanced Settings
        parentLi.parentNode.insertBefore(newLi, parentLi.nextSibling);
        ob.disconnect();
      }
    });
  });
  obs.observe(document.body, { childList: true, subtree: true });
});
</script>
EOF
  1. Inject it into the Admin Panel
cp /www/gl_home.html /www/gl_home.html.bak
sed -i '/<\/body>/r /tmp/poweroff_snippet.js' /www/gl_home.html
/etc/init.d/uhttpd reload

  • Open the Admin Panel in incognito mode—you’ll see Power Off immediately below Advanced Settings in the System menu.
  1. Persist via rc.local
    Edit /etc/rc.local again (with vi /etc/rc.local) and before exit 0 paste:
# recreate Admin Panel Power Off snippet
cat > /tmp/poweroff_snippet.js << 'EOF'
<script>
window.addEventListener('DOMContentLoaded', function(){
  var obs = new MutationObserver(function(muts, ob){
    // Seleciona todos os tĂ­tulos de item de menu
    var titles = document.querySelectorAll('.el-menu-item > .menu-title');
    titles.forEach(function(title){
      if (title.textContent.trim() === 'Advanced Settings') {
        var parentLi = title.closest('li.el-menu-item');
        // cria novo <li> com a mesma classe e estilo
        var newLi = document.createElement('li');
        newLi.setAttribute('role','menuitem');
        newLi.setAttribute('tabindex','-1');
        newLi.className = 'el-menu-item';
        newLi.style.paddingLeft = parentLi.style.paddingLeft;
        // cria o <span><a>Power Off</a></span>
        var span = document.createElement('span');
        span.className = 'menu-title';
        var a = document.createElement('a');
        a.href = '/cgi-bin/luci/admin/mcu';
        a.textContent = 'Power Off';
        span.appendChild(a);
        newLi.appendChild(span);
        // insere logo apĂłs o Advanced Settings
        parentLi.parentNode.insertBefore(newLi, parentLi.nextSibling);
        ob.disconnect();
      }
    });
  });
  obs.observe(document.body, { childList: true, subtree: true });
});
</script>
EOF

cp /www/gl_home.html /www/gl_home.html.bak 2>/dev/null
sed -i '/<\/body>/r /tmp/poweroff_snippet.js' /www/gl_home.html
/etc/init.d/uhttpd reload

Save & exit. Now every boot (and after any firmware upgrade that preserves /etc/rc.local), your Admin Panel will automatically get the Power Off link re-injected.

In Summary

  1. LuCI:
  • Create /usr/lib/lua/luci/controller/poweroff.lua
  • Installer at /usr/bin/install_poweroff
  • Call it from /etc/rc.local
  1. GL-iNet Admin Panel:
  • Inject a JS snippet into /www/gl_home.html
  • Automate via /etc/rc.local

I hope it helps as it helped me. =)