#! /bin/sh #---------------------------------------------------------------------------- # /etc/init.d/imond - start/stop imond # # Creation: 2002-11-24 fm # Last Update: $Id$ # # Copyright (c) 2002-2004 Frank Meyer, frank(at)eisfair(dot)org # Copyright (c) 2010-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- name=imond DAEMON=/usr/bin/${name} PIDFILE=/run/${name}.pid # include function . /etc/init.d/functions # read configuration dsl=false if [ -f /etc/config.d/dsl ] then dsl=true . /etc/config.d/dsl fi . /etc/config.d/imond stop_msg=true # --------------------------------------------------------------------------- # usage # --------------------------------------------------------------------------- usage () { cat </etc/imond.conf if ${dsl} then times="${DSL_PPPOE_TIMES:-Mo-Su:00-24:0.0:Y}" usepeerdns="${DSL_PPPOE_USEPEERDNS:-no}" set ${times} all=$(echo ${*}) dev='pppoe' for j in ${all} do set $(echo ${j} | /usr/bin/sed 's/:/ /g') days=${1} hours=${2} charge=${3} is_lcr=${4} lcr='no' if [ "${is_lcr}" = "Y" -o "${is_lcr}" = "y" ] then lcr='yes' # imond handles route fi phone='-' # no phone number droute='yes' # only default route makes sense name="${DSL_PPPOE_NAME:-DSL}" chargeint="${DSL_PPPOE_CHARGEINT:-60}" hup_timeout="${DSL_PPPOE_HUP_TIMEOUT:-600}" bandwidth=-1:-1 echo ${days} ${hours} ${dev} ${bandwidth} \ ${hup_timeout} ${lcr} ${droute} ${phone} \ ${name} ${charge} ${chargeint} done >>/etc/imond.conf evaluate_retval echo ${dev} >/run/circuit-pppoe echo ${usepeerdns} >/run/pppoe.usepeerdns fi boot_mesg " * Starting IMonD ..." if [ -n "${IMOND_LED}" ] then opt="-port ${IMOND_PORT} -led /dev/${IMOND_LED}" else opt="-port ${IMOND_PORT}" fi if [ "${IMOND_BEEP}" = "yes" ] then opt="${opt} -beep" fi echo ${IMOND_PORT} >/run/imond.port syslog_opt='-log-to-syslog' telmond_logdir='' mgetty_logdir='' if [ "${IMOND_LOG}" = "yes" ] then loadproc ${DAEMON} ${syslog_opt} ${opt} "${IMOND_LOGDIR}" \ "${telmond_logdir}" "${mgetty_logdir}" else loadproc ${DAEMON} ${syslog_opt} ${opt} "" \ "${telmond_logdir}" "${mgetty_logdir}" fi } # --------------------------------------------------------------------------- # stop imond # --------------------------------------------------------------------------- imond_stop() { pidofproc -p ${PIDFILE} -s ${DAEMON} if [ "${?}" -eq "3" -a "$(tty)" = "/dev/console" ] then _mesg=false fi if ${_mesg:-true} then boot_mesg " * Stopping IMonD ..." fi /usr/bin/fli4lctrl hangup pppoe sleep 1 killproc ${DAEMON} rm -f ${PIDFILE} } # --------------------------------------------------------------------------- # restart imond # --------------------------------------------------------------------------- imond_restart() { imond_stop sleep 4 imond_start } # --------------------------------------------------------------------------- # status imond # --------------------------------------------------------------------------- imond_status() { statusproc ${DAEMON} } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- while [ ${#} -gt 0 ] do case "${1}" in -q|--quiet) _quiet=true shift ;; *) _action=${1} shift ;; esac done case "${_action}" in start) imond_start ;; stop) imond_stop ;; status) imond_status ;; restart) imond_restart ;; *) usage exit 1 ;; esac exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------