summaryrefslogtreecommitdiff
path: root/openwrt
diff options
context:
space:
mode:
Diffstat (limited to 'openwrt')
-rw-r--r--openwrt/rhctl/Makefile9
-rw-r--r--openwrt/rhctl/files/rhctl.config25
-rw-r--r--openwrt/rhctl/files/serialclient.init108
-rwxr-xr-xopenwrt/rhctl/files/switchctl.init60
4 files changed, 182 insertions, 20 deletions
diff --git a/openwrt/rhctl/Makefile b/openwrt/rhctl/Makefile
index c5e7fca..80430cf 100644
--- a/openwrt/rhctl/Makefile
+++ b/openwrt/rhctl/Makefile
@@ -18,7 +18,7 @@ PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://localhost/
-PKG_MD5SUM:=1336f063117440c040663025110bf612
+PKG_MD5SUM:=2e5fb8d8a6b075bcc8dde214a6d924e5
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
@@ -27,7 +27,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/rhctl
SECTION:=utils
CATEGORY:=Utilities
- TITLE:=radio helsinki control tools
+ TITLE:=Radio Helsinki control tools
URL:=http://www.helsinki.at
MAINTAINER:=Christian Pointner <equinox@helsinki.at>
DEPENDS:=+socat
@@ -58,16 +58,21 @@ define Build/Compile
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS) -ldl"
$(STRIP) $(PKG_BUILD_DIR)/switchctl
+ $(STRIP) $(PKG_BUILD_DIR)/serialclient
endef
define Package/rhctl/install
$(INSTALL_DIR) $(1)/etc/rhctl
$(INSTALL_DATA) ./files/switchctl.conf $(1)/etc/rhctl/
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/rhctl.config $(1)/etc/config/rhctl
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/switchctl $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/serialclient $(1)/usr/bin/
$(INSTALL_BIN) ./files/rhctlsh $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/switchctl.init $(1)/etc/init.d/switchctl
+ $(INSTALL_BIN) ./files/serialclient.init $(1)/etc/init.d/serialclient
endef
$(eval $(call BuildPackage,rhctl))
diff --git a/openwrt/rhctl/files/rhctl.config b/openwrt/rhctl/files/rhctl.config
new file mode 100644
index 0000000..79f5ce3
--- /dev/null
+++ b/openwrt/rhctl/files/rhctl.config
@@ -0,0 +1,25 @@
+config 'switchctl'
+ option command_sock '/var/run/rhctl/switchctl.sock'
+ option baudrate '19200'
+ option device '/dev/audioswatch'
+ option config '/etc/rhctl/switchctl.conf'
+ option mode 'master'
+ option channel 'main'
+
+config 'serialclient'
+# option disabled 1
+ option name 'master'
+ option log 'syslog:3,serialclient-master,daemon'
+ option command_sock '/var/run/rhctl/switchctl.sock'
+ option baudrate '38400'
+ option device '/dev/ttyUSB0'
+ option type 'master'
+
+config 'serialclient'
+# option disabled 1
+ option name 'standby'
+ option log 'syslog:3,serialclient-standby,daemon'
+ option command_sock '/var/run/rhctl/switchctl.sock'
+ option baudrate '38400'
+ option device '/dev/ttyUSB1'
+ option type 'standby'
diff --git a/openwrt/rhctl/files/serialclient.init b/openwrt/rhctl/files/serialclient.init
new file mode 100644
index 0000000..d869d25
--- /dev/null
+++ b/openwrt/rhctl/files/serialclient.init
@@ -0,0 +1,108 @@
+#!/bin/sh /etc/rc.common
+START=71
+
+BIN=serialclient
+DAEMON=/usr/bin/$BIN
+DESC=$BIN
+RUN_D=/var/run/rhctl
+
+
+option_cb() {
+ local varname="$1"
+ local value="$2"
+
+ if ! echo "$CONFIG_OPTIONS" | grep " $varname " > /dev/null; then
+ CONFIG_OPTIONS="$CONFIG_OPTIONS $varname "
+ fi
+}
+
+foreach_config_forced() {
+ foreach_config $1 "forced"
+}
+
+foreach_config() {
+ local cfg="$1"
+ local name
+ local option
+ local value
+ local args=""
+ local forced=0
+
+ if [ -n "$2" ] && [ "x$2" == "xforced" ]; then
+ forced=1
+ fi
+
+ config_get name "serialclient" "name"
+ for option in $CONFIG_OPTIONS
+ do
+ config_get value "serialclient" "$option"
+ if [ "x$option" == "xdisabled" ]; then
+ if [ $forced -eq 0 ] && [ $value -eq 1 ]; then
+ echo -n " $name(disabled)"
+ return
+ fi
+ continue
+ fi
+
+ if [ "x$option" == "xname" ]; then
+ continue
+ fi
+
+ option=`echo $option | tr '_' '-'`
+ if [ -n "$value" ]; then
+ args="$args --$option $value"
+ fi
+ done
+ echo -n " $name"
+ local status="OK"
+ $DAEMON --write-pid "$RUN_D/$BIN.$name.pid" $args || status="failed"
+ echo -n "($status)"
+}
+
+stop_client() {
+ local name=$1
+ local pidfile=$RUN_D/$BIN.$name.pid
+ echo -n " $name"
+ local status="OK"
+ if [ ! -f "$pidfile" ]; then
+ status="tunnel not active"
+ else
+ kill `cat $pidfile` > /dev/null 2>&1 || status="failed"
+ rm -f $pidfile
+ fi
+ echo -n "($status)"
+}
+
+start() {
+ echo -n "Starting $DESC:"
+ config_load "rhctl"
+ if [ $# -gt 0 ]; then
+ while [ $# -gt 0 ]; do
+ config_foreach foreach_config_forced "$1"
+ shift
+ done
+ else
+ config_foreach foreach_config ""
+ fi
+ echo "."
+}
+
+stop() {
+ echo -n "Stopping $DESC:"
+ local name
+ local pidfile
+
+ if [ $# -gt 0 ]; then
+ while [ $# -gt 0 ]; do
+ stop_client $1
+ shift
+ done
+ else
+ for pidfile in `ls $RUN_D/$BIN.*.pid 2> /dev/null`; do
+ name=${pidfile%%.pid}
+ name=${name##$RUN_D/$BIN.}
+ stop_client $name
+ done
+ fi
+ echo "."
+}
diff --git a/openwrt/rhctl/files/switchctl.init b/openwrt/rhctl/files/switchctl.init
index 8ebe46f..c947e40 100755
--- a/openwrt/rhctl/files/switchctl.init
+++ b/openwrt/rhctl/files/switchctl.init
@@ -7,26 +7,50 @@ DESC=$BIN
RUN_D=/var/run/rhctl
PIDFILE=$RUN_D/$BIN.pid
-start() {
- echo -n "Starting $DESC:"
- mkdir -p $RUN_D
- $DAEMON --write-pid $PIDFILE
- if [ $? -ne 0 ]; then
- echo -n " Error"
- else
- echo -n " Ok"
+
+option_cb() {
+ local varname="$1"
+ local value="$2"
+
+ if ! echo "$CONFIG_OPTIONS" | grep " $varname " > /dev/null; then
+ CONFIG_OPTIONS="$CONFIG_OPTIONS $varname "
+ fi
+}
+
+start_daemon() {
+ local option
+ local value
+ local args=""
+
+ for option in $CONFIG_OPTIONS
+ do
+ config_get value "switchctl" "$option"
+ option=`echo $option | tr '_' '-'`
+ if [ -n "$value" ]; then
+ args="$args --$option $value"
fi
- echo "."
+ done
+ local status="OK"
+ $DAEMON --write-pid $PIDFILE $args || status="failed"
+ echo -n "($status)"
+}
+
+start() {
+ echo -n "Starting $DESC:"
+ config_load "rhctl"
+ mkdir -p $RUN_D
+ config_foreach start_daemon "switchctl"
+ echo "."
}
stop() {
- echo -n "Stopping $DESC:"
- if [ -f $PIDFILE ]; then
- kill `cat $PIDFILE` > /dev/null 2>&1
- rm -f $PIDFILE > /dev/null 2>&1
- echo -n " Ok"
- else
- echo -n " not running"
- fi
- echo "."
+ echo -n "Stopping $DESC:"
+ if [ -f $PIDFILE ]; then
+ kill `cat $PIDFILE` > /dev/null 2>&1
+ rm -f $PIDFILE > /dev/null 2>&1
+ echo -n " Ok"
+ else
+ echo -n " not running"
+ fi
+ echo "."
}