setserial: merge r29212
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 4 Feb 2012 21:03:52 +0000 (21:03 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 4 Feb 2012 21:03:52 +0000 (21:03 +0000)
SVN-Revision: 30155

utils/setserial/Makefile
utils/setserial/files/serial.init [deleted file]
utils/setserial/files/setserial.config [new file with mode: 0644]
utils/setserial/files/setserial.init [new file with mode: 0644]

index c529f1fc5299a2ec90662d5691d5cc422a891f43..a15449956769ac1171d14c94c4f7ec99eb1557da 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2008 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=setserial
 PKG_VERSION:=2.17
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=@SF/setserial
@@ -43,8 +43,14 @@ endef
 define Package/setserial/install
        $(INSTALL_DIR) $(1)/usr/sbin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/setserial $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/setserial.config $(1)/etc/config/setserial
        $(INSTALL_DIR) $(1)/etc/init.d
-       $(INSTALL_BIN) ./files/serial.init $(1)/etc/init.d/setserial
+       $(INSTALL_BIN) ./files/setserial.init $(1)/etc/init.d/setserial
+endef
+
+define Package/setserial/conffiles
+/etc/config/setserial
 endef
 
 $(eval $(call BuildPackage,setserial))
diff --git a/utils/setserial/files/serial.init b/utils/setserial/files/serial.init
deleted file mode 100644 (file)
index f9cd0e8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-START=15
-boot() {
-       /usr/sbin/setserial /dev/tts/1 irq 3
-}
diff --git a/utils/setserial/files/setserial.config b/utils/setserial/files/setserial.config
new file mode 100644 (file)
index 0000000..ba2957f
--- /dev/null
@@ -0,0 +1,6 @@
+package 'setserial'
+
+config 'setserial'
+       option enabled 0
+       option device '/dev/ttyS1'
+       option parameters 'irq 3'
diff --git a/utils/setserial/files/setserial.init b/utils/setserial/files/setserial.init
new file mode 100644 (file)
index 0000000..db38ce2
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=15
+
+section_enabled() {
+       local enabled
+       config_get_bool enabled "$1" 'enabled' 0
+       [ $enabled -gt 0 ] || return 1
+}
+
+start_instance() {
+       local section="$1"
+       local device
+       local parameters
+       local args=""
+
+       section_enabled "$section" || return 1
+
+       config_get device "$section" 'device'
+       [ -n "$device" ] || return 1
+       append args "$device"
+
+       config_get parameters "$section" 'parameters'
+       [ -n "$parameters" ] || return 1
+       append args "$parameters"
+
+       /usr/sbin/setserial $device $parameters
+}
+
+boot() {
+       config_load 'setserial'
+       config_foreach start_instance 'setserial'
+}