Browse Source

Merge pull request #197 from henning-schild/henning/staging

packages/socat: add init script
Ted Hess 10 years ago
parent
commit
6d50cbb349
3 changed files with 53 additions and 1 deletions
  1. 9
    1
      net/socat/Makefile
  2. 5
    0
      net/socat/files/socat.config
  3. 39
    0
      net/socat/files/socat.init

+ 9
- 1
net/socat/Makefile View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=socat
11 11
 PKG_VERSION:=1.7.2.4
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 
14 14
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 15
 PKG_SOURCE_URL:=http://www.dest-unreach.org/socat/download
@@ -50,6 +50,10 @@ config SOCAT_SSL
50 50
           Implements SSL support in socat (using libopenssl).
51 51
 endef
52 52
 
53
+define Package/socat/conffiles
54
+/etc/config/socat
55
+endef
56
+
53 57
 CONFIGURE_ARGS += \
54 58
 	--disable-libwrap \
55 59
 	--disable-readline \
@@ -68,6 +72,10 @@ CONFIGURE_VARS += \
68 72
 define Package/socat/install
69 73
 	$(INSTALL_DIR) $(1)/usr/bin
70 74
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/socat $(1)/usr/bin/
75
+	$(INSTALL_DIR) $(1)/etc/config
76
+	$(INSTALL_CONF) ./files/socat.config $(1)/etc/config/socat
77
+	$(INSTALL_DIR) $(1)/etc/init.d
78
+	$(INSTALL_BIN) ./files/socat.init $(1)/etc/init.d/socat
71 79
 endef
72 80
 
73 81
 $(eval $(call BuildPackage,socat))

+ 5
- 0
net/socat/files/socat.config View File

@@ -0,0 +1,5 @@
1
+# forward port 8000 on IPv6 to IPv4 host port 80
2
+# change enable to '1' to use this example
3
+config socat 'http'
4
+	option enable '0'
5
+	option SocatOptions '-d -d TCP6-LISTEN:8000,fork TCP4:192.168.1.20:80'

+ 39
- 0
net/socat/files/socat.init View File

@@ -0,0 +1,39 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2008-2014 OpenWrt.org
3
+
4
+START=99
5
+STOP=99
6
+
7
+USE_PROCD=1
8
+PROG=/usr/bin/socat
9
+NAME=socat
10
+
11
+validate_section_socat()
12
+{
13
+	uci_validate_section socat socat "${1}" \
14
+		'enable:bool:1' \
15
+		'SocatOptions:string'
16
+	return $?
17
+}
18
+
19
+socat_instance()
20
+{
21
+	local SocatOptions enable
22
+
23
+	validate_section_socat "${1}" || {
24
+		echo "validation failed"
25
+		return 1
26
+	}
27
+
28
+	[ "${enable}" = "0" ] && return 1
29
+
30
+	procd_open_instance
31
+	procd_set_param command "$PROG"
32
+	procd_append_param command ${SocatOptions}
33
+	procd_close_instance
34
+}
35
+
36
+start_service () {
37
+	config_load "${NAME}"
38
+	config_foreach socat_instance socat
39
+}