Ignore:
Timestamp:
2009-07-26T14:34:09+02:00 (7 years ago)
Author:
florian
Message:

[pakcage] simplify action handling in rc.common (#5558)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/base-files/files/etc/rc.common

    r12659 r17012  
    11#!/bin/sh 
    2 # Copyright (C) 2006 OpenWrt.org 
     2# Copyright (C) 2006-2009 OpenWrt.org 
    33 
    44. $IPKG_INSTROOT/etc/functions.sh 
     5 
     6initscript=$1 
     7action=${2:-help} 
     8shift 2 
    59 
    610start() { 
     
    6771} 
    6872 
    69 initscript="$1" 
    70 [ "$#" -ge 1 ] && shift 
    71 action="$1" 
    72 [ "$#" -ge 1 ] && shift 
    73  
    7473. "$initscript" 
    7574 
    76 cmds= 
    77 for cmd in $EXTRA_COMMANDS; do 
    78         cmds="${cmds:+$cmds$N}$cmd) $cmd \"\$@\";;" 
    79 done 
    80 eval "case \"\$action\" in 
    81         start) start \"\$@\";; 
    82         stop) stop \"\$@\";; 
    83         reload) reload \"\$@\" || restart \"\$@\";; 
    84         restart) restart \"\$@\";; 
    85         boot) boot \"\$@\";; 
    86         shutdown) shutdown \"\$@\";; 
    87         enable) enable \"\$@\";; 
    88         enabled) enabled \"\$@\";; 
    89         disable) disable \"\$@\";; 
    90         $cmds 
    91         *) help;; 
    92 esac" 
     75ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}" 
     76list_contains ALL_COMMANDS "$action" || action=help 
     77[ "$action" == reload ] && action='eval reload "$@" || restart "$@" && :' 
     78$action "$@" 
Note: See TracChangeset for help on using the changeset viewer.