#!/bin/sh DAEMON=ser2net DAEMON_LONG_NAME="Serial to Network Proxy" PID_FILE=/var/run/$DAEMON.pid . /etc/init.d/modlibrc CFGFILE="/tmp/flash/ser2net.conf" [ -e /etc/ser2net.conf ] && CFGFILE="/etc/ser2net.conf" config() { if [ ! -e "$CFGFILE" ]; then echo -n "Creating $CFGFILE ... " cat <<"EOF" > $CFGFILE # 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 $CFGFILE -P $PID_FILE } case $1 in ""|load) [ "$CFGFILE" != "/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