From: Felix Fietkau Date: Wed, 4 Oct 2006 20:57:49 +0000 (+0000) Subject: port lots of init scripts over to rc.common (more to come) X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=commitdiff_plain;h=aeecf77c07e778604794427277d18685019d6ab2 port lots of init scripts over to rc.common (more to come) SVN-Revision: 4917 --- diff --git a/libs/avahi/files/avahi-daemon.init b/libs/avahi/files/avahi-daemon.init index 20f0a2e064..81ceb9b939 100644 --- a/libs/avahi/files/avahi-daemon.init +++ b/libs/avahi/files/avahi-daemon.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=avahi-daemon DEFAULT=/etc/default/$BIN @@ -6,20 +7,16 @@ OPTIONS="-D" RUN_D=/var/run/$BIN [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - mkdir -p $RUN_D - $BIN $OPTIONS - ;; - stop) +start() { + mkdir -p $RUN_D + $BIN $OPTIONS +} + +stop() { $BIN -k - ;; - reload) +} + +reload() { $BIN -r - ;; - *) - echo "usage: $0 (start|stop|reload)" - exit 1 -esac +} -exit $? diff --git a/libs/howl/files/autoipd.init b/libs/howl/files/autoipd.init index eed593603c..3de6e6e23a 100644 --- a/libs/howl/files/autoipd.init +++ b/libs/howl/files/autoipd.init @@ -1,20 +1,17 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/autopid RUN_D=/var/run PID_F=$RUN_D/autoipd.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - autoipd $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac -exit $? +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + autoipd $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} + diff --git a/libs/howl/files/mDNSResponder.init b/libs/howl/files/mDNSResponder.init index 292280f7c1..a3a575781e 100644 --- a/libs/howl/files/mDNSResponder.init +++ b/libs/howl/files/mDNSResponder.init @@ -5,16 +5,11 @@ RUN_D=/var/run PID_F=$RUN_D/mDNSResponder.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - mDNSResponder $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac -exit $? +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + mDNSResponder $OPTIONS +} +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} + diff --git a/libs/howl/files/nifd.init b/libs/howl/files/nifd.init index b67861eb26..0569e68a22 100644 --- a/libs/howl/files/nifd.init +++ b/libs/howl/files/nifd.init @@ -1,21 +1,16 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/nifd RUN_D=/var/run PID_F=$RUN_D/nifd.pid - [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - nifd $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac -exit $? +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + nifd $OPTIONS +} +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} + diff --git a/net/aiccu/files/aiccu.init b/net/aiccu/files/aiccu.init index dabafcf3f0..9f77e19d85 100644 --- a/net/aiccu/files/aiccu.init +++ b/net/aiccu/files/aiccu.init @@ -1,21 +1,10 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -case "$1" in - start) +start() { aiccu start - ;; +} - stop) +stop() { aiccu stop - aiccu stop - ;; - - restart) - $0 stop - $0 start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 - ;; -esac +} diff --git a/net/bind/files/named.init b/net/bind/files/named.init index 97860b3b25..6cbd96ac03 100755 --- a/net/bind/files/named.init +++ b/net/bind/files/named.init @@ -1,5 +1,12 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -if [ -f /etc/bind/named.conf ]; then - named -c /etc/bind/named.conf -fi +start() { + if [ -f /etc/bind/named.conf ]; then + named -c /etc/bind/named.conf + fi +} + +stop() { + killall named +} diff --git a/net/bitchx/files/S98bitchxrc b/net/bitchx/files/S98bitchxrc index 4578696ae2..eda8a03a63 100755 --- a/net/bitchx/files/S98bitchxrc +++ b/net/bitchx/files/S98bitchxrc @@ -1,7 +1,10 @@ -#!/bin/sh -# make /tmp/.bitchxrc as many servers ban root -if [ ! -e /tmp/.bitchxrc ] -then - echo "IRCUSER OpenWrt" >/tmp/.bitchxrc - echo "IRCNAME OpenWrt User!" >>/tmp/.bitchxrc -fi +#!/bin/sh /etc/rc.common + +start() { + # make /tmp/.bitchxrc as many servers ban root + if [ ! -e /tmp/.bitchxrc ] + then + echo "IRCUSER OpenWrt" >/tmp/.bitchxrc + echo "IRCNAME OpenWrt User!" >>/tmp/.bitchxrc + fi +} diff --git a/net/bitlbee/files/S55bitlbee b/net/bitlbee/files/S55bitlbee index d7f691d24b..95c5f59d35 100755 --- a/net/bitlbee/files/S55bitlbee +++ b/net/bitlbee/files/S55bitlbee @@ -1,3 +1,11 @@ -#!/bin/sh -mkdir -p /var/lib/bitlbee -bitlbee -D +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + mkdir -p /var/lib/bitlbee + bitlbee -D +} + +stop() { + killall bitlbee +} diff --git a/net/chillispot/files/chillispot.init b/net/chillispot/files/chillispot.init index 26aff70b24..5d92ffe0c5 100644 --- a/net/chillispot/files/chillispot.init +++ b/net/chillispot/files/chillispot.init @@ -1,24 +1,18 @@ -#!/bin/sh -. /etc/functions.sh -include /lib/network -scan_interfaces +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org RUN_D=/var/run PID_F=$RUN_D/chilli.pid -case $1 in - start) - /sbin/insmod tun >/dev/null 2>&1 - [ -d $RUN_D ] || mkdir -p $RUN_D - config_get ipaddr lan ipaddr - /usr/sbin/chilli --dns1="$ipaddr" - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) >/dev/null 2>&1 - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + include /lib/network + scan_interfaces + /sbin/insmod tun >/dev/null 2>&1 + [ -d $RUN_D ] || mkdir -p $RUN_D + config_get ipaddr lan ipaddr + /usr/sbin/chilli --dns1="$ipaddr" +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) >/dev/null 2>&1 +} diff --git a/net/click/files/S50roofnet b/net/click/files/S50roofnet index f434163755..256e2abbe9 100755 --- a/net/click/files/S50roofnet +++ b/net/click/files/S50roofnet @@ -1,7 +1,14 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -killall -q click -cp /usr/bin/srcr.click /tmp -sh /usr/bin/gen_config_roofnet.sh > /tmp/unaligned.click -click-align /tmp/unaligned.click > /tmp/roofnet.click -/usr/bin/click /tmp/roofnet.click > /tmp/roofnet.log 2>&1 & +start() { + killall -q click + cp /usr/bin/srcr.click /tmp + sh /usr/bin/gen_config_roofnet.sh > /tmp/unaligned.click + click-align /tmp/unaligned.click > /tmp/roofnet.click + /usr/bin/click /tmp/roofnet.click > /tmp/roofnet.log 2>&1 & +} + +stop() { + killall click +} diff --git a/net/cups/files/cupsd.init b/net/cups/files/cupsd.init index 8e5fd63c48..c53c16920a 100644 --- a/net/cups/files/cupsd.init +++ b/net/cups/files/cupsd.init @@ -1,4 +1,12 @@ -#!/bin/sh -mkdir -p /tmp/cups -mkdir -p /tmp/spool/cups/tmp -exec /usr/sbin/cupsd +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + mkdir -p /tmp/cups + mkdir -p /tmp/spool/cups/tmp + /usr/sbin/cupsd +} + +stop() { + killall cupsd +} diff --git a/net/dhcp-forwarder/files/dhcp-fwd.init b/net/dhcp-forwarder/files/dhcp-fwd.init index 6ad3858e89..db1cb3a7c4 100644 --- a/net/dhcp-forwarder/files/dhcp-fwd.init +++ b/net/dhcp-forwarder/files/dhcp-fwd.init @@ -1,21 +1,17 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org LOG_D=/var/log RUN_D=/var/run PID_F=$RUN_D/dhcpd-fwd.pid -case $1 in - start) - [ -d $LOG_D ] || mkdir -p $LOG_D - [ -d $RUN_D ] || mkdir -p $RUN_D - dhcp-fwd - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + [ -d $LOG_D ] || mkdir -p $LOG_D + [ -d $RUN_D ] || mkdir -p $RUN_D + dhcp-fwd +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} -exit $? diff --git a/net/ez-ipupdate/files/ez-ipupdate.init b/net/ez-ipupdate/files/ez-ipupdate.init index 1572175615..e0f43817b4 100644 --- a/net/ez-ipupdate/files/ez-ipupdate.init +++ b/net/ez-ipupdate/files/ez-ipupdate.init @@ -1,22 +1,17 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=ez-ipupdate CONF=/etc/$BIN.conf RUN_D=/var/run PID_F=$RUN_D/$BIN.pid -[ -f $CONF ] || exit -case $1 in - start) - mkdir -p $RUN_D - $BIN -c $CONF - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + [ -f $CONF ] || exit + mkdir -p $RUN_D + $BIN -c $CONF +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} diff --git a/net/freeradius/files/radiusd.init b/net/freeradius/files/radiusd.init index 3ec16896ac..cfb2ff8b11 100644 --- a/net/freeradius/files/radiusd.init +++ b/net/freeradius/files/radiusd.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/radiusd LOG_D=/var/log/radius @@ -6,18 +7,12 @@ RUN_D=/var/run PID_F=$RUN_D/radiusd.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $LOG_D ] || mkdir -p $LOG_D - [ -d $RUN_D ] || mkdir -p $RUN_D - radiusd $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + [ -d $LOG_D ] || mkdir -p $LOG_D + [ -d $RUN_D ] || mkdir -p $RUN_D + radiusd $OPTIONS +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} diff --git a/net/frickin/files/frickin.init b/net/frickin/files/frickin.init index e07a0945b6..73f183e6b4 100644 --- a/net/frickin/files/frickin.init +++ b/net/frickin/files/frickin.init @@ -1,16 +1,15 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=frickin DEFAULT=/etc/default/$BIN [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - $BIN $OPTIONS & - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + $BIN $OPTIONS & +} + +stop() { + killall $BIN +} -exit $? diff --git a/net/gmediaserver/files/gmediaserver.init b/net/gmediaserver/files/gmediaserver.init index 1582b37cc9..71ffa8d235 100644 --- a/net/gmediaserver/files/gmediaserver.init +++ b/net/gmediaserver/files/gmediaserver.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=gmediaserver DEFAULT=/etc/default/$BIN @@ -6,16 +7,11 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + $BIN $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} -exit $? diff --git a/net/htpdate/files/htpdate.init b/net/htpdate/files/htpdate.init index 97a413f774..97ec97d4f7 100644 --- a/net/htpdate/files/htpdate.init +++ b/net/htpdate/files/htpdate.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=htpdate DEFAULT=/etc/default/$BIN @@ -6,17 +7,12 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - mkdir -p $RUN_D - $BIN -l -s -t $OPTIONS && $BIN -D $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + mkdir -p $RUN_D + $BIN -l -s -t $OPTIONS && $BIN -D $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} -exit $? diff --git a/net/l2tpd/files/l2tpd.init b/net/l2tpd/files/l2tpd.init index f531757993..eeecae51d1 100644 --- a/net/l2tpd/files/l2tpd.init +++ b/net/l2tpd/files/l2tpd.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=l2tpd DEFAULT=/etc/default/$BIN @@ -6,16 +7,11 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + $BIN $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} -exit $? diff --git a/net/lighttpd/files/lighttpd.init b/net/lighttpd/files/lighttpd.init index ca7a3f97f5..3e46924e83 100644 --- a/net/lighttpd/files/lighttpd.init +++ b/net/lighttpd/files/lighttpd.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=lighttpd DEFAULT=/etc/default/$BIN @@ -7,18 +8,13 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - mkdir -p $LOG_D - mkdir -p $RUN_D - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + mkdir -p $LOG_D + mkdir -p $RUN_D + $BIN $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} -exit $? diff --git a/net/maradns/files/maradns.init b/net/maradns/files/maradns.init index 1b3df1f358..ef2be3f3eb 100644 --- a/net/maradns/files/maradns.init +++ b/net/maradns/files/maradns.init @@ -1,5 +1,13 @@ -#!/bin/sh -[ -d /etc/maradns ] || mkdir -p /etc/maradns -[ -d /etc/maradns/logger ] || mkdir -p /etc/maradns/logger -duende /usr/sbin/maradns -duende /usr/sbin/zoneserver +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + [ -d /etc/maradns ] || mkdir -p /etc/maradns + [ -d /etc/maradns/logger ] || mkdir -p /etc/maradns/logger + duende /usr/sbin/maradns + duende /usr/sbin/zoneserver +} + +stop() { + killall duende maradns zoneserver +} diff --git a/net/miau/files/S50miau b/net/miau/files/S50miau index beef3105dd..892c23c090 100755 --- a/net/miau/files/S50miau +++ b/net/miau/files/S50miau @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT="/etc/default/miau" OPTIONS="-d /etc/miau/" @@ -6,27 +7,24 @@ LOG_DIR="/var/log/miau" ERR_LOG="$LOG_DIR/error.log" OUT_LOG="$LOG_DIR/miau.log" -[ -f $DEFAULT ] && . $DEFAULT -[ "$ENABLE_MIAU" = "yes" ] || exit 0 +start() { + [ -f $DEFAULT ] && . $DEFAULT + [ "$ENABLE_MIAU" = "yes" ] || exit 0 + [ -f /var/run/miau.pid ] && { + echo "[ERROR] miau is running" + exit 0 + } + [ -d $LOG_DIR ] || mkdir -p $LOG_DIR + /usr/bin/miau -f $OPTIONS > $OUT_LOG 2> $ERR_LOG & + PID=$! + sleep 1 + if [ -d /proc/$PID ]; then + echo $PID > /var/run/miau.pid + else + echo "[ERROR] Unable to run miau as a daemon" + fi +} -case $1 in - start) - [ -f /var/run/miau.pid ] && echo "[ERROR] miau is running" - [ -f /var/run/miau.pid ] && exit 0 - [ -d /var/run ] || mkdir -p /var/run - [ -d $LOG_DIR ] || mkdir -p $LOG_DIR - /usr/bin/miau -f $OPTIONS > $OUT_LOG 2> $ERR_LOG & - PID=$! - sleep 1 - [ -d /proc/$PID ] && echo $PID > /var/run/miau.pid - [ -d /proc/$PID ] || echo "[ERROR] Unable to run miau as a daemon" - ;; - stop) - [ -f /var/run/miau.pid ] && kill $(cat /var/run/miau.pid) >/dev/null 2>&1 && rm /var/run/miau.pid - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac - -exit $? +stop() { + [ -f /var/run/miau.pid ] && kill $(cat /var/run/miau.pid) >/dev/null 2>&1 && rm /var/run/miau.pid +} diff --git a/net/mini_httpd/files/mini_httpd.init b/net/mini_httpd/files/mini_httpd.init index 77bd6fd3b7..430f21ee75 100644 --- a/net/mini_httpd/files/mini_httpd.init +++ b/net/mini_httpd/files/mini_httpd.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=mini_httpd DEFAULT=/etc/default/$BIN @@ -6,21 +7,11 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - $BIN $OPTIONS 2>/dev/null - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - restart) - $0 stop - $0 start - ;; - *) - echo "usage: $0 (start|stop|restart)" - exit 1 -esac +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + $BIN $OPTIONS 2>/dev/null +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} diff --git a/net/miredo/files/miredo-server.init b/net/miredo/files/miredo-server.init index b41a86668e..b050b5572b 100644 --- a/net/miredo/files/miredo-server.init +++ b/net/miredo/files/miredo-server.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=miredo-server DEFAULT=/etc/default/$BIN @@ -6,23 +7,13 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - insmod ipv6 - insmod tun - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - restart) - $0 stop - $0 start - ;; - *) - echo "usage: $0 (start|stop|restart)" - exit 1 -esac +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + insmod ipv6 + insmod tun + $BIN $OPTIONS +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} diff --git a/net/miredo/files/miredo.init b/net/miredo/files/miredo.init index e305472aca..7fe13d963f 100644 --- a/net/miredo/files/miredo.init +++ b/net/miredo/files/miredo.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=miredo DEFAULT=/etc/default/$BIN @@ -6,23 +7,13 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - insmod ipv6 - insmod tun - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - restart) - $0 stop - $0 start - ;; - *) - echo "usage: $0 (start|stop|restart)" - exit 1 -esac +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + insmod ipv6 + insmod tun + $BIN $OPTIONS +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} diff --git a/net/netperf/files/netserver.init b/net/netperf/files/netserver.init index 2900b570ae..ee2b8ad10b 100644 --- a/net/netperf/files/netserver.init +++ b/net/netperf/files/netserver.init @@ -1,3 +1,10 @@ -#!/bin/sh -test -n "$FAILSAFE" && exit -/usr/bin/netserver +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + /usr/bin/netserver +} + +stop() { + killall netserver +} diff --git a/net/nfs-kernel-server/files/nfsd.init b/net/nfs-kernel-server/files/nfsd.init index 354a991d87..21adf5b291 100644 --- a/net/nfs-kernel-server/files/nfsd.init +++ b/net/nfs-kernel-server/files/nfsd.init @@ -1,47 +1,28 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org NFS_D=/var/lib/nfs -_start() { - mkdir -p $NFS_D - touch $NFS_D/rmtab - - /usr/sbin/rpc.statd - /usr/sbin/rpc.lockd - /usr/sbin/exportfs -r - /usr/sbin/rpc.nfsd - /usr/sbin/rpc.mountd +start() { + mkdir -p $NFS_D + touch $NFS_D/rmtab + + /usr/sbin/rpc.statd + /usr/sbin/rpc.lockd + /usr/sbin/exportfs -r + /usr/sbin/rpc.nfsd + /usr/sbin/rpc.mountd } -_stop() { - killall rpc.mountd 2> /dev/null - killall -9 nfsd 2> /dev/null - /usr/sbin/exportfs -au - killall lockd 2> /dev/null - killall rpc.statd 2> /dev/null +stop() { + killall rpc.mountd 2> /dev/null + killall -9 nfsd 2> /dev/null + /usr/sbin/exportfs -au + killall lockd 2> /dev/null + killall rpc.statd 2> /dev/null } -_reload() { - /usr/sbin/exportfs -r +reload() { + /usr/sbin/exportfs -r } -case $1 in - start) - _start - ;; - stop) - _stop - ;; - reload) - _reload - ;; - restart) - _stop - sleep 1 - _start - ;; - *) - echo "usage: $0 (start|stop|reload|restart)" - exit 1 -esac -exit $? diff --git a/net/nfs-server/files/nfsd.init b/net/nfs-server/files/nfsd.init index 1b1e1bd3aa..7956e5e91c 100644 --- a/net/nfs-server/files/nfsd.init +++ b/net/nfs-server/files/nfsd.init @@ -1,4 +1,14 @@ -#!/bin/sh -/usr/sbin/portmap -/usr/sbin/rpc.mountd -r -/usr/sbin/rpc.nfsd +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + /usr/sbin/portmap + /usr/sbin/rpc.mountd -r + /usr/sbin/rpc.nfsd +} + +stop() { + killall rpc.nfsd + killall rpc.mountd + killall portmap +} diff --git a/net/ntpclient/files/ntpclient.init b/net/ntpclient/files/ntpclient.init index 3a21184202..f508c313c0 100644 --- a/net/ntpclient/files/ntpclient.init +++ b/net/ntpclient/files/ntpclient.init @@ -1,4 +1,6 @@ #!/bin/sh +# Copyright (C) 2006 OpenWrt.org + ntp_server=$(nvram get ntp_server) case "${ACTION:-ifup}" in ifup) diff --git a/net/oidentd/files/S85oidentd b/net/oidentd/files/S85oidentd index 6f3e05d2e1..a2c04b786c 100755 --- a/net/oidentd/files/S85oidentd +++ b/net/oidentd/files/S85oidentd @@ -1,3 +1,10 @@ -#!/bin/sh -/usr/sbin/oidentd -m -f 113 +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org +start() { + /usr/sbin/oidentd -m -f 113 +} + +stop() { + killall oidentd +} diff --git a/net/olsrd/files/olsrd.init b/net/olsrd/files/olsrd.init index 1f1fdb9519..f59ff7ef88 100644 --- a/net/olsrd/files/olsrd.init +++ b/net/olsrd/files/olsrd.init @@ -1,15 +1,13 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/olsrd [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - olsrd $OPTIONS - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + olsrd $OPTIONS +} -exit $? +stop() { + killall olsrd +} diff --git a/net/openntpd/files/ntpd.init b/net/openntpd/files/ntpd.init index 8bac705b4a..e680f62c35 100644 --- a/net/openntpd/files/ntpd.init +++ b/net/openntpd/files/ntpd.init @@ -1,3 +1,11 @@ -#!/bin/sh -mkdir -p `awk -F: '/^ntp:/{print $6}' /etc/passwd` -/usr/sbin/ntpd -s +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + mkdir -p `awk -F: '/^ntp:/{print $6}' /etc/passwd` + /usr/sbin/ntpd -s +} + +stop() { + killall ntpd +} diff --git a/net/openssh/files/S50sshd b/net/openssh/files/S50sshd index 2ea168394c..c2e535d311 100755 --- a/net/openssh/files/S50sshd +++ b/net/openssh/files/S50sshd @@ -1,15 +1,22 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -for type in rsa dsa; do { - # check for keys - key=/etc/ssh/ssh_host_${type}_key - [ ! -f $key ] && { - # generate missing keys - [ -x /usr/bin/ssh-keygen ] && { - /usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&- && exec $0 $* - } & - exit 0 - } -}; done -mkdir -p /var/empty -/usr/sbin/sshd +start() { + for type in rsa dsa; do { + # check for keys + key=/etc/ssh/ssh_host_${type}_key + [ ! -f $key ] && { + # generate missing keys + [ -x /usr/bin/ssh-keygen ] && { + /usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&- && exec $0 $* + } & + exit 0 + } + }; done + mkdir -p /var/empty + /usr/sbin/sshd +} + +stop() { + killall sshd +} diff --git a/net/p910nd/files/p910nd.init b/net/p910nd/files/p910nd.init index 1a6c4f4a13..05c675a523 100644 --- a/net/p910nd/files/p910nd.init +++ b/net/p910nd/files/p910nd.init @@ -1,47 +1,33 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/p910nd RUN_D=/var/run -_start() { - mkdir -p $RUN_D - [ -f $DEFAULT ] && ( - while read port options; do - case "$port" in - ""|\#*) - continue; - esac - p910nd $options $port - if [ $? -ne 0 ]; then - exit 1 - fi - done - ) < $DEFAULT - exit 0 +start() { + mkdir -p $RUN_D + [ -f $DEFAULT ] && ( + while read port options; do + case "$port" in + ""|\#*) continue;; + esac + p910nd $options $port + if [ $? -ne 0 ]; then + exit 1 + fi + done + ) < $DEFAULT } -_stop() { - [ -f $DEFAULT ] && ( - while read port options; do - case "$port" in - ""|\#*) - continue; - esac - PID_F=$RUN_D/p910${port}d.pid - [ -f $PID_F ] && kill $(cat $PID_F) - done - ) < $DEFAULT +stop() { + [ -f $DEFAULT ] && ( + while read port options; do + case "$port" in + ""|\#*) continue;l + esac + PID_F=$RUN_D/p910${port}d.pid + [ -f $PID_F ] && kill $(cat $PID_F) + done + ) < $DEFAULT } -case $1 in - start) - _start - ;; - stop) - _stop - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac -exit $? diff --git a/net/parprouted/files/parprouted.init b/net/parprouted/files/parprouted.init index 2422657ee8..aae46fc68c 100755 --- a/net/parprouted/files/parprouted.init +++ b/net/parprouted/files/parprouted.init @@ -1,16 +1,14 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=parprouted DEFAULT=/etc/default/$BIN [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - $BIN $OPTIONS - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + $BIN $OPTIONS +} -exit $? +stop() { + killall $BIN +} diff --git a/net/peerguardian/files/peerguardian.init b/net/peerguardian/files/peerguardian.init index 5807314c87..cd786b89e9 100644 --- a/net/peerguardian/files/peerguardian.init +++ b/net/peerguardian/files/peerguardian.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=pgtext DEFAULT=/etc/default/$BIN @@ -6,16 +7,10 @@ DEFAULT=/etc/default/$BIN RUN_D=/var/run PID_F=$RUN_D/$BIN_${IF}_${ID}.pid -case $1 in - start) - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) >/dev/null 2>&1 - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + $BIN $OPTIONS +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) >/dev/null 2>&1 +} diff --git a/net/portmap/files/portmap.init b/net/portmap/files/portmap.init index 31a3399e93..fd4be73535 100644 --- a/net/portmap/files/portmap.init +++ b/net/portmap/files/portmap.init @@ -1,16 +1,15 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=portmap DEFAULT=/etc/default/$BIN [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - $BIN $OPTIONS - ;; - *) - echo "usage: $0 start" - exit 1 -esac +start() { + $BIN $OPTIONS +} + +stop() { + killall $BIN +} -exit $? diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init index d4944c7677..40e4d7e65a 100644 --- a/net/pptpd/files/pptpd.init +++ b/net/pptpd/files/pptpd.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=pptpd DEFAULT=/etc/default/$BIN @@ -6,20 +7,14 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - mkdir -p $RUN_D - for m in arc4 sha1 slhc crc-ccitt ppp_generic ppp_async ppp_mppe_mppc; do - insmod $m >/dev/null 2>&1 - done - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + mkdir -p $RUN_D + for m in arc4 sha1 slhc crc-ccitt ppp_generic ppp_async ppp_mppe_mppc; do + insmod $m >/dev/null 2>&1 + done + $BIN $OPTIONS +} -exit $? +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} diff --git a/net/radvd/files/radvd.init b/net/radvd/files/radvd.init index 2d9e500090..99e2ab2e18 100644 --- a/net/radvd/files/radvd.init +++ b/net/radvd/files/radvd.init @@ -1,24 +1,14 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -case "$1" in - start) +start() { echo 1 > /proc/sys/net/ipv6/conf/all/forwarding mkdir -p /var/log mkdir -p /var/run /usr/sbin/radvd - ;; +} - stop) +stop() { killall radvd echo 0 > /proc/sys/net/ipv6/conf/all/forwarding - ;; - - restart) - $0 stop - $0 start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 - ;; -esac +} diff --git a/net/rarpd/files/rarpd.init b/net/rarpd/files/rarpd.init index 04ca0b4f38..353a96acb2 100644 --- a/net/rarpd/files/rarpd.init +++ b/net/rarpd/files/rarpd.init @@ -1,7 +1,13 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org RARPD=/usr/sbin/rarpd DEFAULT=/etc/default/rarpd [ -f $DEFAULT ] && . $DEFAULT -$RARPD $OPTIONS +start() { + $RARPD $OPTIONS +} +stop() { + killall rarpd +} diff --git a/net/reaim/files/reaim.init b/net/reaim/files/reaim.init index 93ceea3d42..8fe8c50f33 100644 --- a/net/reaim/files/reaim.init +++ b/net/reaim/files/reaim.init @@ -1,62 +1,47 @@ -#! /bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org PATH=/sbin:/bin:/usr/sbin:/usr/bin NAME=reaim DESC="Transparent proxy for IM behind NAT" -. /etc/functions.sh -WAN=$(nvram get wan_ifname) IPT=/usr/sbin/iptables -case "$1" in - start) - if [ -e /var/run/$NAME.pid ]; then - echo "$DESC: $NAME already started." - exit 0 - fi - echo -n "Starting $DESC: $NAME" - $IPT -A input_rule -i $WAN -p tcp --dport 1863:1864 -j ACCEPT - $IPT -A input_rule -i $WAN -p tcp --dport 4443 -j ACCEPT - $IPT -A input_rule -i $WAN -p tcp --dport 5566 -j ACCEPT - $IPT -A input_rule -i $WAN -p tcp --dport 40000:40099 -j ACCEPT - test -e /var/run/$NAME.pid || touch /var/run/$NAME.pid - /usr/sbin/$NAME - echo "." - ;; - - stop) - if [ ! -e /var/run/$NAME.pid ]; then - echo "$DESC: $NAME is not running." - exit 0 - fi - echo -n "Stopping $DESC: $NAME" - killall $NAME - rm -f /var/run/$NAME.pid - - echo "." - ;; - - restart|force-reload) - if [ ! -e /var/run/$NAME.pid ]; then - $0 start - exit 0 - fi - echo -n "Restarting $DESC: $NAME" - $IPT -A input_rule -i $WAN -p tcp --dport 1863:1864 -j ACCEPT - $IPT -A input_rule -i $WAN -p tcp --dport 4443 -j ACCEPT - $IPT -A input_rule -i $WAN -p tcp --dport 5566 -j ACCEPT - $IPT -A input_rule -i $WAN -p tcp --dport 40000:40099 -j ACCEPT - killall $NAME - sleep 1 - /usr/sbin/$NAME - echo "." - ;; - - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload}" >&2 - exit 1 - ;; - -esac - -exit 0 +include /lib/network +scan_interfaces +config_get WAN wan ifname + +set_rules() { + [ -z "$WAN" ] && exit + $IPT $1 input_rule -i $WAN -p tcp --dport 1863:1864 -j ACCEPT + $IPT $1 input_rule -i $WAN -p tcp --dport 4443 -j ACCEPT + $IPT $1 input_rule -i $WAN -p tcp --dport 5566 -j ACCEPT + $IPT $1 input_rule -i $WAN -p tcp --dport 40000:40099 -j ACCEPT +} + +start() { + if [ -e /var/run/$NAME.pid ]; then + echo "$DESC: $NAME already started." + exit 0 + fi + echo -n "Starting $DESC: $NAME" + + set_rules -A + test -e /var/run/$NAME.pid || touch /var/run/$NAME.pid + /usr/sbin/$NAME + echo "." +} + +stop() { + set_rules -D 2>/dev/null >/dev/null + + if [ ! -e /var/run/$NAME.pid ]; then + echo "$DESC: $NAME is not running." + exit 0 + fi + echo -n "Stopping $DESC: $NAME" + + killall $NAME + rm -f /var/run/$NAME.pid + + echo "." +} diff --git a/net/rp-l2tp/files/rp-l2tpd.init b/net/rp-l2tp/files/rp-l2tpd.init index 4e03836bbe..8051cfd596 100755 --- a/net/rp-l2tp/files/rp-l2tpd.init +++ b/net/rp-l2tp/files/rp-l2tpd.init @@ -1,17 +1,16 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/rp-l2tpd RUN_D=/var/run [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - l2tpd $OPTIONS - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + l2tpd $OPTIONS +} + +stop() { + killall l2tpd +} -exit $? diff --git a/net/rp-pppoe/files/pppoe-client.init b/net/rp-pppoe/files/pppoe-client.init index fb3f4ca3e8..ba6c7cd72d 100644 --- a/net/rp-pppoe/files/pppoe-client.init +++ b/net/rp-pppoe/files/pppoe-client.init @@ -1,12 +1,11 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -case "$1" in - start|stop) - adsl-$1 - ;; - *) - echo "usage: $0 {start|stop}" - exit 1 -esac +start() { + adsl-start +} + +stop() { + adsl-stop +} -exit $? diff --git a/net/rp-pppoe/files/pppoe-relay.init b/net/rp-pppoe/files/pppoe-relay.init index d8212f2588..53878c3026 100644 --- a/net/rp-pppoe/files/pppoe-relay.init +++ b/net/rp-pppoe/files/pppoe-relay.init @@ -1,15 +1,14 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/pppoe-relay [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - pppoe-relay $OPTIONS - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + pppoe-relay $OPTIONS +} + +stop() { + killall pppoe-relay +} -exit $? diff --git a/net/rp-pppoe/files/pppoe-server.init b/net/rp-pppoe/files/pppoe-server.init index 2768895de0..b25f61974d 100644 --- a/net/rp-pppoe/files/pppoe-server.init +++ b/net/rp-pppoe/files/pppoe-server.init @@ -1,15 +1,13 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/pppoe-server [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - pppoe-server $OPTIONS - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + pppoe-server $OPTIONS +} -exit $? +stop() { + killall pppoe-server +} diff --git a/net/samba/files/samba.init b/net/samba/files/samba.init index c3c600ae3e..a30dfcf46e 100644 --- a/net/samba/files/samba.init +++ b/net/samba/files/samba.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/samba RUN_D=/var/run/samba @@ -6,19 +7,13 @@ NMBD_PID_F=$RUN_D/nmbd.pid SMBD_PID_F=$RUN_D/smbd.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - mkdir -p $RUN_D - nmbd -D $NMBD_OPTIONS - smbd -D $SMBD_OPTIONS - ;; - stop) - [ -f $SMBD_PID_F ] && kill $(cat $SMBD_PID_F) - [ -f $NMBD_PID_F ] && kill $(cat $NMBD_PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + mkdir -p $RUN_D + nmbd -D $NMBD_OPTIONS + smbd -D $SMBD_OPTIONS +} +stop() { + [ -f $SMBD_PID_F ] && kill $(cat $SMBD_PID_F) + [ -f $NMBD_PID_F ] && kill $(cat $NMBD_PID_F) +} -exit $? diff --git a/net/scanlogd/files/scanlogd.init b/net/scanlogd/files/scanlogd.init index 762d55e8cd..541b1026a1 100755 --- a/net/scanlogd/files/scanlogd.init +++ b/net/scanlogd/files/scanlogd.init @@ -1,3 +1,11 @@ -#!/bin/sh -mkdir -p `grep "^scanlogd:" /etc/passwd | cut -d: -f6` -/usr/sbin/scanlogd +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + mkdir -p `grep "^scanlogd:" /etc/passwd | cut -d: -f6` + /usr/sbin/scanlogd +} + +stop() { + killall scanlogd +} diff --git a/net/siproxd/files/siproxd.init b/net/siproxd/files/siproxd.init index f8739d43f0..32b2ca94f6 100644 --- a/net/siproxd/files/siproxd.init +++ b/net/siproxd/files/siproxd.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=siproxd DEFAULT=/etc/default/$BIN @@ -6,16 +7,12 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - mkdir -p $RUN_D - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac -exit $? +start() { + mkdir -p $RUN_D + $BIN $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} + diff --git a/net/srelay/files/srelay.init b/net/srelay/files/srelay.init index 9e5a5f5654..e3de144395 100755 --- a/net/srelay/files/srelay.init +++ b/net/srelay/files/srelay.init @@ -1,5 +1,12 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -if [ -f /etc/srelay.conf ];then - srelay -c /etc/srelay.conf -r -s -fi +start() { + if [ -f /etc/srelay.conf ];then + srelay -c /etc/srelay.conf -r -s + fi +} + +stop() { + killall srelay +} diff --git a/net/tor/files/tor.init b/net/tor/files/tor.init index 8eb2db49f9..5de8663148 100644 --- a/net/tor/files/tor.init +++ b/net/tor/files/tor.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=tor DEFAULT=/etc/default/$BIN @@ -7,18 +8,13 @@ RUN_D=/var/run PID_F=$RUN_D/$BIN.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - mkdir -p $LOG_D - mkdir -p $RUN_D - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + mkdir -p $LOG_D + mkdir -p $RUN_D + $BIN $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} -exit $? diff --git a/net/ulogd/files/ulogd.init b/net/ulogd/files/ulogd.init index d3863c5f2a..61a0879401 100644 --- a/net/ulogd/files/ulogd.init +++ b/net/ulogd/files/ulogd.init @@ -1,17 +1,15 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=ulogd DEFAULT=/etc/default/$BIN LOG_D=/var/log [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - $BIN $OPTIONS - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + $BIN $OPTIONS +} -exit $? +stop() { + killall $BIN +} diff --git a/net/updatedd/files/S55ddns b/net/updatedd/files/S55ddns index 75df45190d..faaccb552c 100644 --- a/net/updatedd/files/S55ddns +++ b/net/updatedd/files/S55ddns @@ -1,13 +1,20 @@ -#!/bin/sh -. /etc/nvram.sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org -ddnsupdate=$(nvram get ddns_update) -[ "$ddnsupdate" = 1 ]&& { - service=$(nvram get ddns_service) - uname=$(nvram get ddns_user) - passwd=$(nvram get ddns_password) - host=$(nvram get ddns_host) - - /usr/bin/updatedd -Y $service -- $uname:$passwd $host +start() { + . /etc/nvram.sh + + ddnsupdate=$(nvram get ddns_update) + [ "$ddnsupdate" = 1 ]&& { + service=$(nvram get ddns_service) + uname=$(nvram get ddns_user) + passwd=$(nvram get ddns_password) + host=$(nvram get ddns_host) + + /usr/bin/updatedd -Y $service -- $uname:$passwd $host + } } +stop() { + killall updatedd +} diff --git a/net/vrrpd/files/vrrpd.init b/net/vrrpd/files/vrrpd.init index 5afc734381..64d686f67c 100644 --- a/net/vrrpd/files/vrrpd.init +++ b/net/vrrpd/files/vrrpd.init @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BIN=vrrpd DEFAULT=/etc/default/$BIN @@ -6,16 +7,11 @@ DEFAULT=/etc/default/$BIN RUN_D=/var/run PID_F=$RUN_D/$BIN_${IF}_${ID}.pid -case $1 in - start) - $BIN $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) >/dev/null 2>&1 - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + $BIN $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) >/dev/null 2>&1 +} -exit $? diff --git a/net/vsftpd/files/vsftpd.init b/net/vsftpd/files/vsftpd.init index 4d4f4f240d..ce41110527 100644 --- a/net/vsftpd/files/vsftpd.init +++ b/net/vsftpd/files/vsftpd.init @@ -1,15 +1,12 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common RUN_D=/var/run/vsftpd -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - vsftpd - ;; - *) - echo "usage: $0 (start)" - exit 1 -esac +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + vsftpd +} -exit $? +stop() { + killall vsftpd +} diff --git a/net/wifidog/files/wifidog.init b/net/wifidog/files/wifidog.init index 03e2ea2217..d5aaf7ca68 100644 --- a/net/wifidog/files/wifidog.init +++ b/net/wifidog/files/wifidog.init @@ -1,3 +1,11 @@ -#!/bin/sh -/usr/bin/wifidog-init start +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + /usr/bin/wifidog-init start +} + +stop() { + /usr/bin/wifidog-init stop +} diff --git a/net/xinetd/files/xinetd.init b/net/xinetd/files/xinetd.init index 2df7a8196c..40411926a5 100644 --- a/net/xinetd/files/xinetd.init +++ b/net/xinetd/files/xinetd.init @@ -1,21 +1,17 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org DEFAULT=/etc/default/xinetd RUN_D=/var/run PID_F=$RUN_D/xinetd.pid [ -f $DEFAULT ] && . $DEFAULT -case $1 in - start) - [ -d $RUN_D ] || mkdir -p $RUN_D - xinetd $OPTIONS - ;; - stop) - [ -f $PID_F ] && kill $(cat $PID_F) - ;; - *) - echo "usage: $0 (start|stop)" - exit 1 -esac +start() { + [ -d $RUN_D ] || mkdir -p $RUN_D + xinetd $OPTIONS +} + +stop() { + [ -f $PID_F ] && kill $(cat $PID_F) +} -exit $? diff --git a/utils/collectd/files/S80collectd b/utils/collectd/files/S80collectd index aa767fbc48..f35e4f50f1 100755 --- a/utils/collectd/files/S80collectd +++ b/utils/collectd/files/S80collectd @@ -1,17 +1,24 @@ -#!/bin/sh +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org BINARY="/usr/sbin/collectd" PIDFILE="/var/run/collectd.pid" DATADIR="/var/lib/collectd" -[ -x "$BINARY" ] || exit 1; +start() { + [ -x "$BINARY" ] || exit 1; -if [ -e "$PIDFILE" ] -then - kill $(cat "$PIDFILE") 2>/dev/null - sleep 1 -fi + if [ -e "$PIDFILE" ] + then + kill $(cat "$PIDFILE") 2>/dev/null + sleep 1 + fi + + [ -d "$DATADIR" ] || mkdir -p "$DATADIR"; -[ -d "$DATADIR" ] || mkdir -p "$DATADIR"; + $BINARY +} -$BINARY +stop() { + kill $(cat "$PIDFILE") 2>/dev/null +}