package/modules: enable ECHI/OHCI for RT3883
[openwrt.git] / package / base-files / files / etc / rc.common
1 #!/bin/sh
2 # Copyright (C) 2006-2011 OpenWrt.org
3
4 . $IPKG_INSTROOT/etc/functions.sh
5
6 initscript=$1
7 action=${2:-help}
8 shift 2
9
10 start() {
11 return 0
12 }
13
14 stop() {
15 return 0
16 }
17
18 reload() {
19 return 1
20 }
21
22 restart() {
23 trap '' TERM
24 stop "$@"
25 start "$@"
26 }
27
28 boot() {
29 start "$@"
30 }
31
32 shutdown() {
33 stop
34 }
35
36 disable() {
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
42 enable() {
43 name="$(basename "${initscript}")"
44 disable
45 [ -n "$START" -o -n "$STOP" ] || {
46 echo "/etc/init.d/$name does not have a START or STOP value"
47 return 1
48 }
49 [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
50 [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
51 }
52
53 enabled() {
54 name="$(basename "${initscript}")"
55 [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
56 }
57
58 depends() {
59 return 0
60 }
61
62 help() {
63 cat <<EOF
64 Syntax: $initscript [command]
65
66 Available commands:
67 start Start the service
68 stop Stop the service
69 restart Restart the service
70 reload Reload configuration files (or restart if that fails)
71 enable Enable service autostart
72 disable Disable service autostart
73 $EXTRA_HELP
74 EOF
75 }
76
77 . "$initscript"
78
79 ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
80 list_contains ALL_COMMANDS "$action" || action=help
81 [ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
82 $action "$@"
This page took 0.052676 seconds and 5 git commands to generate.