From 5912b88021dcf89b76710aed85f9467f6dc1ed2d Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 3 Oct 2008 12:24:57 +0000 Subject: [PATCH] * luci-0.8: backport hd-idle application --- applications/luci-hd_idle/Makefile | 2 + applications/luci-hd_idle/ipkg/postinst | 4 ++ .../luasrc/controller/hd_idle.lua | 28 +++++++++++++ .../luci-hd_idle/luasrc/i18n/hd_idle.de.lua | 7 ++++ .../luci-hd_idle/luasrc/i18n/hd_idle.de.xml | 13 ++++++ .../luci-hd_idle/luasrc/i18n/hd_idle.en.lua | 7 ++++ .../luci-hd_idle/luasrc/i18n/hd_idle.en.xml | 13 ++++++ .../luci-hd_idle/luasrc/model/cbi/hd_idle.lua | 42 +++++++++++++++++++ .../root/etc/uci-defaults/luci-hd_idle | 7 ++++ contrib/package/luci/Makefile | 14 +++++++ 10 files changed, 137 insertions(+) create mode 100644 applications/luci-hd_idle/Makefile create mode 100644 applications/luci-hd_idle/ipkg/postinst create mode 100644 applications/luci-hd_idle/luasrc/controller/hd_idle.lua create mode 100644 applications/luci-hd_idle/luasrc/i18n/hd_idle.de.lua create mode 100644 applications/luci-hd_idle/luasrc/i18n/hd_idle.de.xml create mode 100644 applications/luci-hd_idle/luasrc/i18n/hd_idle.en.lua create mode 100644 applications/luci-hd_idle/luasrc/i18n/hd_idle.en.xml create mode 100644 applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua create mode 100644 applications/luci-hd_idle/root/etc/uci-defaults/luci-hd_idle diff --git a/applications/luci-hd_idle/Makefile b/applications/luci-hd_idle/Makefile new file mode 100644 index 0000000000..81a96f6a83 --- /dev/null +++ b/applications/luci-hd_idle/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk \ No newline at end of file diff --git a/applications/luci-hd_idle/ipkg/postinst b/applications/luci-hd_idle/ipkg/postinst new file mode 100644 index 0000000000..4c3b4dca8d --- /dev/null +++ b/applications/luci-hd_idle/ipkg/postinst @@ -0,0 +1,4 @@ +#!/bin/sh +[ -n "${IPKG_INSTROOT}" ] || { + ( . /etc/uci-defaults/luci-hd_idle ) && rm -f /etc/uci-defaults/luci-hd_idle +} diff --git a/applications/luci-hd_idle/luasrc/controller/hd_idle.lua b/applications/luci-hd_idle/luasrc/controller/hd_idle.lua new file mode 100644 index 0000000000..45d102cc1e --- /dev/null +++ b/applications/luci-hd_idle/luasrc/controller/hd_idle.lua @@ -0,0 +1,28 @@ +--[[ + +LuCI hd-idle +(c) 2008 Yanira + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +]]-- + +module("luci.controller.hd_idle", package.seeall) + +function index() + require("luci.i18n") + luci.i18n.loadc("hd_idle") + if not luci.fs.isfile("/etc/config/hd-idle") then + return + end + + local page = entry({"admin", "services", "hd_idle"}, cbi("hd_idle"), luci.i18n.translate("hd_idle", "hd-idle"), 60) + page.i18n = "hd_idle" + page.dependent = true +end diff --git a/applications/luci-hd_idle/luasrc/i18n/hd_idle.de.lua b/applications/luci-hd_idle/luasrc/i18n/hd_idle.de.lua new file mode 100644 index 0000000000..ca276ab4f0 --- /dev/null +++ b/applications/luci-hd_idle/luasrc/i18n/hd_idle.de.lua @@ -0,0 +1,7 @@ +disk = 'Festplatte' +enable_debug = 'Debug-Ausgaben aktivieren' +hd_idle = 'hd-idle' +hd_idle_desc = 'hd-idle ist ein Hilfsprogramm um externe Festplatten nach einer festgelegten Leerlaufzeit herunter zu fahren.' +idle_time_interval = 'Leerlaufzeit' +idle_time_unit = 'Leerlaufzeiteinheit' +settings = 'Einstellungen' diff --git a/applications/luci-hd_idle/luasrc/i18n/hd_idle.de.xml b/applications/luci-hd_idle/luasrc/i18n/hd_idle.de.xml new file mode 100644 index 0000000000..398df00742 --- /dev/null +++ b/applications/luci-hd_idle/luasrc/i18n/hd_idle.de.xml @@ -0,0 +1,13 @@ + + + + +Festplatte +Debug-Ausgaben aktivieren +hd-idle +hd-idle ist ein Hilfsprogramm um externe Festplatten nach einer festgelegten Leerlaufzeit herunter zu fahren. +Leerlaufzeit +Leerlaufzeiteinheit +Einstellungen + + diff --git a/applications/luci-hd_idle/luasrc/i18n/hd_idle.en.lua b/applications/luci-hd_idle/luasrc/i18n/hd_idle.en.lua new file mode 100644 index 0000000000..2ec778002d --- /dev/null +++ b/applications/luci-hd_idle/luasrc/i18n/hd_idle.en.lua @@ -0,0 +1,7 @@ +disk = 'Disk' +enable_debug = 'Enable debug' +hd_idle = 'hd-idle' +hd_idle_desc = 'hd-idle is a utility program for spinning-down external disks after a period of idle time.' +idle_time_interval = 'Idle-Time' +idle_time_unit = 'Idle-Time unit' +settings = 'Settings' diff --git a/applications/luci-hd_idle/luasrc/i18n/hd_idle.en.xml b/applications/luci-hd_idle/luasrc/i18n/hd_idle.en.xml new file mode 100644 index 0000000000..7802a78260 --- /dev/null +++ b/applications/luci-hd_idle/luasrc/i18n/hd_idle.en.xml @@ -0,0 +1,13 @@ + + + + +Disk +Enable debug +hd-idle +hd-idle is a utility program for spinning-down external disks after a period of idle time. +Idle-Time +Idle-Time unit +Settings + + diff --git a/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua b/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua new file mode 100644 index 0000000000..e880aaf639 --- /dev/null +++ b/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua @@ -0,0 +1,42 @@ +--[[ + +LuCI hd-idle +(c) 2008 Yanira + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +]]-- + +require("luci.fs") + +m = Map("hd-idle", translate("hd_idle"), translate("hd_idle_desc")) + +s = m:section(TypedSection, "hd-idle", translate("settings")) +s.addremove = true +s.anonymous = true + +s:option(Flag, "enabled", translate("enabled", "Enable")) + +disk = s:option(Value, "disk", translate("disk")) +disk.rmempty = true +for _, dev in ipairs(luci.fs.glob("/dev/[sh]d[a-z]")) do + disk:value(luci.fs.basename(dev)) +end + +s:option(Value, "idle_time_interval", translate("idle_time_interval")).default = 10 +s.rmempty = true +unit = s:option(ListValue, "idle_time_unit", translate("idle_time_unit")) +unit.default = "minutes" +unit:value("minutes", "min") +unit:value("hours", "h") +unit.rmempty = true + +s:option(Flag, "enable_debug", translate("enable_debug")) + +return m diff --git a/applications/luci-hd_idle/root/etc/uci-defaults/luci-hd_idle b/applications/luci-hd_idle/root/etc/uci-defaults/luci-hd_idle new file mode 100644 index 0000000000..6a37176a35 --- /dev/null +++ b/applications/luci-hd_idle/root/etc/uci-defaults/luci-hd_idle @@ -0,0 +1,7 @@ +#!/bin/sh + +uci batch <<-EOF + add ucitrack hd-idle + set ucitrack.@hd-idle[-1].init=hd-idle + commit ucitrack +EOF diff --git a/contrib/package/luci/Makefile b/contrib/package/luci/Makefile index c93120471f..6655a05bb8 100644 --- a/contrib/package/luci/Makefile +++ b/contrib/package/luci/Makefile @@ -398,6 +398,16 @@ define Package/luci-app-ushare/install $(call Package/luci/install/template,$(1),applications/luci-ushare) endef +define Package/luci-app-hd_idle + $(call Package/luci/webtemplate) + DEPENDS+=+luci-admin-full +hd-idle + TITLE:=hd-idle +endef + +define Package/luci-app-hd_idle/install + $(call Package/luci/install/template,$(1),applications/luci-hd_idle) +endef + ### Server Gateway Interfaces ### @@ -551,6 +561,9 @@ endif ifneq ($(CONFIG_PACKAGE_luci-app-ushare),) PKG_SELECTED_MODULES+=applications/luci-ushare endif +ifneq ($(CONFIG_PACKAGE_luci-app-hd_idle),) + PKG_SELECTED_MODULES+=applications/luci-hd_idle +endif ifneq ($(CONFIG_PACKAGE_luci-sgi-cgi),) @@ -614,6 +627,7 @@ $(eval $(call BuildPackage,luci-app-samba)) $(eval $(call BuildPackage,luci-app-uvc_streamer)) $(eval $(call BuildPackage,luci-app-p910nd)) $(eval $(call BuildPackage,luci-app-ushare)) +$(eval $(call BuildPackage,luci-app-hd_idle)) $(eval $(call BuildPackage,luci-sgi-cgi)) -- 2.30.2