[package] base-files:
[openwrt.git] / 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
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 return 0
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 [ "$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
49 enabled() {
50 name="$(basename "${initscript}")"
51 [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
52 }
53
54 depends() {
55 return 0
56 }
57
58 help() {
59 cat <<EOF
60 Syntax: $initscript [command]
61
62 Available 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
70 EOF
71 }
72
73 . "$initscript"
74
75 ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
76 list_contains ALL_COMMANDS "$action" || action=help
77 [ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
78 $action "$@"
This page took 0.051651 seconds and 5 git commands to generate.