1#!/bin/sh 2# Copyright (C) 2006-2012 OpenWrt.org 3 4LAN_IF=ethlan 5BR_IF=br0 6WAN_IF=brwan 7CONFIG=/bin/config 8 9. $IPKG_INSTROOT/lib/functions.sh 10. $IPKG_INSTROOT/lib/functions/service.sh 11 12initscript=$1 13action=${2:-help} 14shift 2 15 16start() { 17 return 0 18} 19 20stop() { 21 return 0 22} 23 24reload() { 25 return 1 26} 27 28restart() { 29 trap '' TERM 30 stop "$@" 31 start "$@" 32} 33 34boot() { 35 start "$@" 36} 37 38shutdown() { 39 stop 40} 41 42disable() { 43 name="$(basename "${initscript}")" 44 rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name 45 rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name 46} 47 48enable() { 49 name="$(basename "${initscript}")" 50 disable 51 [ -n "$START" -o -n "$STOP" ] || { 52 echo "/etc/init.d/$name does not have a START or STOP value" 53 return 1 54 } 55 [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" 56 [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" 57} 58 59enabled() { 60 name="$(basename "${initscript}")" 61 [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ] 62} 63 64depends() { 65 return 0 66} 67 68help() { 69 cat <<EOF 70Syntax: $initscript [command] 71 72Available commands: 73 start Start the service 74 stop Stop the service 75 restart Restart the service 76 reload Reload configuration files (or restart if that fails) 77 enable Enable service autostart 78 disable Disable service autostart 79$EXTRA_HELP 80EOF 81} 82 83${INIT_TRACE:+set -x} 84 85. "$initscript" 86 87ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}" 88list_contains ALL_COMMANDS "$action" || action=help 89[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :' 90$action "$@" 91