From 8f68cf2f02d3d897087d2d71b425c4042f5ac7f6 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 5 Nov 2018 11:04:01 +0800 Subject: [PATCH] add luci app ttyd --- package/lean/luci-app-ttyd/Makefile | 17 ++++++++++++ .../luasrc/controller/terminal.lua | 9 +++++++ .../luci-app-ttyd/luasrc/view/terminal.htm | 9 +++++++ .../lean/luci-app-ttyd/po/zh-cn/terminal.po | 5 ++++ .../lean/luci-app-ttyd/root/etc/init.d/ttyd | 26 +++++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 package/lean/luci-app-ttyd/Makefile create mode 100644 package/lean/luci-app-ttyd/luasrc/controller/terminal.lua create mode 100644 package/lean/luci-app-ttyd/luasrc/view/terminal.htm create mode 100644 package/lean/luci-app-ttyd/po/zh-cn/terminal.po create mode 100755 package/lean/luci-app-ttyd/root/etc/init.d/ttyd diff --git a/package/lean/luci-app-ttyd/Makefile b/package/lean/luci-app-ttyd/Makefile new file mode 100644 index 000000000..3667783ca --- /dev/null +++ b/package/lean/luci-app-ttyd/Makefile @@ -0,0 +1,17 @@ +# Copyright (C) 2016 Openwrt.org +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support for ttyd +LUCI_DEPENDS:=+ttyd +LUCI_PKGARCH:=all +PKG_VERSION:=1.0 +PKG_RELEASE:=1 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/package/lean/luci-app-ttyd/luasrc/controller/terminal.lua b/package/lean/luci-app-ttyd/luasrc/controller/terminal.lua new file mode 100644 index 000000000..f4618f2da --- /dev/null +++ b/package/lean/luci-app-ttyd/luasrc/controller/terminal.lua @@ -0,0 +1,9 @@ +module("luci.controller.terminal", package.seeall) + +function index() + if not (luci.sys.call("pidof ttyd > /dev/null") == 0) then + return + end + + entry({"admin", "system", "terminal"}, template("terminal"), _("TTYD Terminal"), 10).leaf = true +end diff --git a/package/lean/luci-app-ttyd/luasrc/view/terminal.htm b/package/lean/luci-app-ttyd/luasrc/view/terminal.htm new file mode 100644 index 000000000..db9b46c84 --- /dev/null +++ b/package/lean/luci-app-ttyd/luasrc/view/terminal.htm @@ -0,0 +1,9 @@ +<%+header%> +
+

<%=translate("Terminal")%>

+ +
+ +<%+footer%> \ No newline at end of file diff --git a/package/lean/luci-app-ttyd/po/zh-cn/terminal.po b/package/lean/luci-app-ttyd/po/zh-cn/terminal.po new file mode 100644 index 000000000..ed7b7523b --- /dev/null +++ b/package/lean/luci-app-ttyd/po/zh-cn/terminal.po @@ -0,0 +1,5 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "TTYD Terminal" +msgstr "TTYD 终端" diff --git a/package/lean/luci-app-ttyd/root/etc/init.d/ttyd b/package/lean/luci-app-ttyd/root/etc/init.d/ttyd new file mode 100755 index 000000000..87216650b --- /dev/null +++ b/package/lean/luci-app-ttyd/root/etc/init.d/ttyd @@ -0,0 +1,26 @@ +#!/bin/sh /etc/rc.common + +START=99 +SERVICE_WRITE_PID=1 +SERVICE_DAEMONIZE=1 + +start() { + logger -t TTYD 'Starting ttyd service' + service_start /usr/bin/ttyd -i br-lan /bin/login + return 0 +} + +stop() { + if [ -n "`pidof ttyd`" ]; then + logger -t TTYD 'Shutting down ttyd service' + service_stop /usr/bin/ttyd + fi + return 0 +} + +restart() { + logger -t TTYD 'Restarting ttyd service' + stop + sleep 2 + start +}