hd-idle: Update init script
This replaces the use of uci_validate_section() with uci_load_validate(), which removes the need to declare local variables for every config option. This also adds a service_triggers() function. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
parent
1d4081dd4c
commit
024644cef3
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=hd-idle
|
PKG_NAME:=hd-idle
|
||||||
PKG_VERSION:=1.05
|
PKG_VERSION:=1.05
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_MAINTAINER:=Lim Guo Wei <limguowei@gmail.com>
|
PKG_MAINTAINER:=Lim Guo Wei <limguowei@gmail.com>
|
||||||
PKG_LICENSE:=GPL-2.0
|
PKG_LICENSE:=GPL-2.0
|
||||||
|
|
|
@ -8,7 +8,7 @@ USE_PROCD=1
|
||||||
|
|
||||||
validate_section_hdidle()
|
validate_section_hdidle()
|
||||||
{
|
{
|
||||||
uci_validate_section hd-idle hd-idle "${1}" \
|
uci_load_validate hd-idle hd-idle "$1" "$2" \
|
||||||
'disk:string' \
|
'disk:string' \
|
||||||
'enabled:bool' \
|
'enabled:bool' \
|
||||||
'idle_time_interval:uinteger:10' \
|
'idle_time_interval:uinteger:10' \
|
||||||
|
@ -43,9 +43,7 @@ compute_seconds() {
|
||||||
}
|
}
|
||||||
|
|
||||||
hdidle_append() {
|
hdidle_append() {
|
||||||
local disk enabled idle_time_interval idle_time_unit
|
[ "$2" = 0 ] || return
|
||||||
|
|
||||||
validate_section_hdidle "${1}" || return
|
|
||||||
|
|
||||||
[ "$enabled" -gt 0 ] || return
|
[ "$enabled" -gt 0 ] || return
|
||||||
|
|
||||||
|
@ -63,10 +61,15 @@ start_service() {
|
||||||
config_load "hd-idle"
|
config_load "hd-idle"
|
||||||
|
|
||||||
numdisks="0"
|
numdisks="0"
|
||||||
config_foreach hdidle_append "hd-idle"
|
config_foreach validate_section_hdidle "hd-idle" hdidle_append
|
||||||
|
|
||||||
if [ "$numdisks" -gt 0 ]; then
|
if [ "$numdisks" -gt 0 ]; then
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "hd-idle"
|
||||||
|
procd_add_validation validate_section_hdidle
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue