#!/bin/sh DAEMON=ser2net DAEMON_CONFIG=/tmp/flash/ser2net.conf DAEMON_LONG_NAME="Serial to Network Proxy" . /etc/init.d/modlibrc [ -e /etc/ser2net.conf ] && DAEMON_CONFIG=/etc/ser2net.conf config() { if [ ! -e "$DAEMON_CONFIG" ]; then echo -n "Creating $DAEMON_CONFIG ... " cat <<"EOF" > $DAEMON_CONFIG # This is the configuration file for ser2net. It has the following format: # :::: # example entries for a USB serial adapter 10232:raw:60:/dev/ttyUSB0:19200 NONE 1STOPBIT 8DATABITS 23232:telnet:60:/dev/ttyUSB0:19200 NONE 1STOPBIT 8DATABITS EOF echo "done." /usr/bin/modsave flash fi } start() { modlib_startdaemon $DAEMON -c $DAEMON_CONFIG -P $PID_FILE } case $1 in ""|load) [ "$DAEMON_CONFIG" != "/etc/ser2net.conf" ] && modreg file ser2net conf 'ser2net.conf' 0 "ser2net_conf" modreg cgi 'ser2net' 'ser2net' modreg daemon $DAEMON modlib_start $SER2NET_ENABLED ;; unload) modunreg daemon $DAEMON modunreg cgi ser2net modunreg file ser2net modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0