aboutsummaryrefslogtreecommitdiff
path: root/net/socat/files
diff options
context:
space:
mode:
authorHenning Schild <henning@hennsch.de>2014-08-12 22:17:57 +0200
committerHenning Schild <henning@hennsch.de>2014-08-12 23:35:56 +0200
commit8b67d48c475ad1e0e7c07ddeda944ee1ba6f2e5f (patch)
tree7c67a53fc859a8e456dfa5dc41930eb3aa055e6d /net/socat/files
parentea2970aa727b930d3258209a321f420112808317 (diff)
packages/socat: add init script
Init script to start instances of socat for port-forwarding etc. Signed-off-by: Henning Schild <henning@hennsch.de>
Diffstat (limited to 'net/socat/files')
-rw-r--r--net/socat/files/socat.config5
-rw-r--r--net/socat/files/socat.init39
2 files changed, 44 insertions, 0 deletions
diff --git a/net/socat/files/socat.config b/net/socat/files/socat.config
new file mode 100644
index 000000000..7df6358be
--- /dev/null
+++ b/net/socat/files/socat.config
@@ -0,0 +1,5 @@
+# forward port 8000 on IPv6 to IPv4 host port 80
+# change enable to '1' to use this example
+config socat 'http'
+ option enable '0'
+ option SocatOptions '-d -d TCP6-LISTEN:8000,fork TCP4:192.168.1.20:80'
diff --git a/net/socat/files/socat.init b/net/socat/files/socat.init
new file mode 100644
index 000000000..379dc070f
--- /dev/null
+++ b/net/socat/files/socat.init
@@ -0,0 +1,39 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2014 OpenWrt.org
+
+START=99
+STOP=99
+
+USE_PROCD=1
+PROG=/usr/bin/socat
+NAME=socat
+
+validate_section_socat()
+{
+ uci_validate_section socat socat "${1}" \
+ 'enable:bool:1' \
+ 'SocatOptions:string'
+ return $?
+}
+
+socat_instance()
+{
+ local SocatOptions enable
+
+ validate_section_socat "${1}" || {
+ echo "validation failed"
+ return 1
+ }
+
+ [ "${enable}" = "0" ] && return 1
+
+ procd_open_instance
+ procd_set_param command "$PROG"
+ procd_append_param command ${SocatOptions}
+ procd_close_instance
+}
+
+start_service () {
+ config_load "${NAME}"
+ config_foreach socat_instance socat
+}