Changeset 583d755 in freewrt for package/quagga/files/quagga.init


Ignore:
Timestamp:
Jul 12, 2006, 12:40:18 AM (19 years ago)
Author:
Thorsten Glaser <tg@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
4486a95
Parents:
115d022
Message:
  • change the SYSV init system to add a target "autostart"
  • on system startup, call autostart instead of start
  • on autostart, check /etc/rc.conf for whether the service is enabled and act appropriately; fall through into start target
  • move some pre-startup checks into the start target
  • some whitespace cleanup, when it makes much sense (XXX when I get the person who wrote these scripts...)
  • optimise dropbear a little

ok and approved wbx@

git-svn-id: svn://www.freewrt.org/trunk/freewrt@191 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package/quagga/files/quagga.init

    r115d022 r583d755  
    9797# check command
    9898
    99 case ${COMMAND}
    100 in
    101         start|stop|restart)
    102                 ;;
    103         watchrestart)
    104                 if [ -n "$ARG_DAEMONS" ]
    105                 then
    106                         echo "${ME}: watchrestart mode is only for use by watchquagga"
    107                         exit 2
    108                 fi
    109                 ;;
    110         *)
    111                 usage
    112                 ;;
     99case ${COMMAND} in
     100autostart|start|stop|restart)
     101        ;;
     102watchrestart)
     103        if [ -n "$ARG_DAEMONS" ]
     104        then
     105                echo "${ME}: watchrestart mode is only for use by watchquagga"
     106                exit 2
     107        fi
     108        ;;
     109*)
     110        usage
     111        ;;
    113112esac
    114113
    115114# select daemons to start
    116115
    117 case ${COMMAND}
    118 in
    119         start|restart|watchrestart)
    120                 START_DAEMONS=
    121                 for d in ${DAEMONS_STARTSEQ}
    122                 do
    123                         [ -x "${BINDIR}/${d}" -a -f "${CONFDIR}/${d}.conf" ] \
    124                         && START_DAEMONS="${START_DAEMONS}${d} "
    125                 done
    126                 WATCHQUAGGA_DAEMONS=${START_DAEMONS}
    127                 if is_in watchquagga "${DAEMONS_STARTSEQ}"
    128                 then
    129                         START_DAEMONS="${START_DAEMONS} watchquagga"
    130                 fi
    131                 if [ -n "${ARG_DAEMONS}" ]
    132                 then
    133                         if select_subset "${ARG_DAEMONS}" "${DAEMONS}"
    134                         then
    135                                 if select_subset "${ARG_DAEMONS}" "${START_DAEMONS}"
    136                                 then
    137                                         START_DAEMONS=${RESULT}
    138                                 else
    139                                         die "these daemons are not startable:${RESULT}."
    140                                 fi
    141                         else
    142                                 die "unknown daemons:${RESULT}; choose from: ${DAEMONS}."
    143                         fi
    144                 fi
    145                 ;;
     116case ${COMMAND} in
     117autostart|start|restart|watchrestart)
     118        START_DAEMONS=
     119        for d in ${DAEMONS_STARTSEQ}
     120        do
     121                [ -x "${BINDIR}/${d}" -a -f "${CONFDIR}/${d}.conf" ] \
     122                && START_DAEMONS="${START_DAEMONS}${d} "
     123        done
     124        WATCHQUAGGA_DAEMONS=${START_DAEMONS}
     125        if is_in watchquagga "${DAEMONS_STARTSEQ}"
     126        then
     127                START_DAEMONS="${START_DAEMONS} watchquagga"
     128        fi
     129        if [ -n "${ARG_DAEMONS}" ]
     130        then
     131                if select_subset "${ARG_DAEMONS}" "${DAEMONS}"
     132                then
     133                        if select_subset "${ARG_DAEMONS}" "${START_DAEMONS}"
     134                        then
     135                                START_DAEMONS=${RESULT}
     136                        else
     137                                die "these daemons are not startable:${RESULT}."
     138                        fi
     139                else
     140                        die "unknown daemons:${RESULT}; choose from: ${DAEMONS}."
     141                fi
     142        fi
     143        ;;
    146144esac
    147145
    148146# select daemons to stop
    149147
    150 case ${COMMAND}
    151 in
    152         stop|restart|watchrestart)
    153                 STOP_DAEMONS=${DAEMONS_STOPSEQ}
    154                 if [ -n "${ARG_DAEMONS}" ]
    155                 then
    156                         if select_subset "${ARG_DAEMONS}" "${STOP_DAEMONS}"
    157                         then
    158                                 STOP_DAEMONS=${RESULT}
    159                         else
    160                                 die "unknown daemons:${RESULT}; choose from: ${DAEMONS}."
    161                         fi
    162                 fi
    163                 stop_daemons=
    164                 for d in ${STOP_DAEMONS}
    165                 do
    166                         pidfile=${STATEDIR}/${d}.pid
    167                         if [ -f "${pidfile}" -o -n "$(pidof ${d})" ]
    168                         then
    169                                 stop_daemons="${stop_daemons}${d} "
    170                         elif [ -n "${ARG_DAEMONS}" ]
    171                         then
    172                                 echo "${ME}: found no ${d} process running."
    173                         fi
    174                 done
    175                 STOP_DAEMONS=${stop_daemons}
    176                 ;;
     148case ${COMMAND} in
     149stop|restart|watchrestart)
     150        STOP_DAEMONS=${DAEMONS_STOPSEQ}
     151        if [ -n "${ARG_DAEMONS}" ]
     152        then
     153                if select_subset "${ARG_DAEMONS}" "${STOP_DAEMONS}"
     154                then
     155                        STOP_DAEMONS=${RESULT}
     156                else
     157                        die "unknown daemons:${RESULT}; choose from: ${DAEMONS}."
     158                fi
     159        fi
     160        stop_daemons=
     161        for d in ${STOP_DAEMONS}
     162        do
     163                pidfile=${STATEDIR}/${d}.pid
     164                if [ -f "${pidfile}" -o -n "$(pidof ${d})" ]
     165                then
     166                        stop_daemons="${stop_daemons}${d} "
     167                elif [ -n "${ARG_DAEMONS}" ]
     168                then
     169                        echo "${ME}: found no ${d} process running."
     170                fi
     171        done
     172        STOP_DAEMONS=${stop_daemons}
     173        ;;
    177174esac
    178175
Note: See TracChangeset for help on using the changeset viewer.