# Mudi auto shutoff

**URL:** <https://forum.gl-inet.com/t/mudi-auto-shutoff/13258>\
**Category:** Router\
**Created:** [December 11, 2020, 10:21pm UTC](https://forum.gl-inet.com/t/mudi-auto-shutoff/13258 "2020-12-11T22:21:21Z")\
**Posts on this page:** 1\
**Showing post:** 41

<div class="post-metadata">

**Author:** ![46775456788](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/4/e0b2c6/32.png) [@46775456788](https://forum.gl-inet.com/u/46775456788)\
**Post date:** [October 23, 2024, 7:26pm UTC](https://forum.gl-inet.com/t/mudi-auto-shutoff/13258/41 "2024-10-23T19:26:17Z")

</div>

> [@mudi-npc](#):
>
> Is there anyway to create a shortcut for this, let’s say, an HTML link to send the command instead of opening terminal and loving in from SSH?

```auto
#!/bin/sh
CONTROLLER_PATH="/usr/lib/lua/luci/controller/mcu.lua"
VIEW_PATH="/usr/lib/lua/luci/view/mcu/index.htm"

mkdir -p /usr/lib/lua/luci/controller
mkdir -p /usr/lib/lua/luci/view/mcu

cat << 'EOF' > "$CONTROLLER_PATH"
module("luci.controller.mcu", package.seeall)

function index()
    entry({"admin", "mcu"}, template("mcu/index"), _("MCU Control"), 60).dependent = true
    entry({"admin", "mcu", "poweroff"}, call("action_poweroff"), _("Power Off"), 61)
end

function action_poweroff()
    local result = os.execute("ubus call mcu cmd_json '{\"poweroff\":\"1\"}'")
    luci.http.redirect(luci.dispatcher.build_url("admin/mcu"))
end
EOF

cat << 'EOF' > "$VIEW_PATH"
<h2>MCU Control</h2>
<form action="{{url('admin/mcu/poweroff')}}" method="post">
    <input type="submit" value="Power Off" />
</form>
EOF

echo "Button installed successfully."

```

Try this script. Run it from /tmp folder. It will create button in LuCi. To login to LuCi [https://your-routers-ip/cgi-bin/luci](https://your-routers-ip/cgi-bin/luci)

---

_[View the full topic](https://forum.gl-inet.com/t/mudi-auto-shutoff/13258)._
