Root/package/base-files/files/etc/rc.common

1#!/bin/sh
2# Copyright (C) 2006-2009 OpenWrt.org
3
4. $IPKG_INSTROOT/etc/functions.sh
5
6initscript=$1
7action=${2:-help}
8shift 2
9
10start() {
11    return 0
12}
13
14stop() {
15    return 0
16}
17
18reload() {
19    return 1
20}
21
22restart() {
23    trap '' TERM
24    stop "$@"
25    start "$@"
26}
27
28boot() {
29    start "$@"
30}
31
32shutdown() {
33    return 0
34}
35
36disable() {
37    name="$(basename "${initscript}")"
38    rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
39    rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
40}
41
42enable() {
43    name="$(basename "${initscript}")"
44    disable
45    [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
46    [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
47}
48
49enabled() {
50    name="$(basename "${initscript}")"
51    [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
52}
53
54depends() {
55    return 0
56}
57
58help() {
59    cat <<EOF
60Syntax: $initscript [command]
61
62Available commands:
63    start Start the service
64    stop Stop the service
65    restart Restart the service
66    reload Reload configuration files (or restart if that fails)
67    enable Enable service autostart
68    disable Disable service autostart
69$EXTRA_HELP
70EOF
71}
72
73. "$initscript"
74
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 "$@"
79

Archive Download this file



interactive