source: trunk/package/base-files/files/etc/rc.common @ 12659

Last change on this file since 12659 was 12659, checked in by nico, 8 years ago

make links to statup scripts in /etc/rc.d relative

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/bin/sh
2# Copyright (C) 2006 OpenWrt.org
3
4. $IPKG_INSTROOT/etc/functions.sh
5
6start() {
7        return 0
8}
9
10stop() {
11        return 0
12}
13
14reload() {
15        return 1
16}
17
18restart() {
19        trap '' TERM
20        stop "$@"
21        start "$@"
22}
23
24boot() {
25        start "$@"
26}
27
28shutdown() {
29        return 0
30}
31
32disable() {
33        name="$(basename "${initscript}")"
34        rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
35        rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
36}
37
38enable() {
39        name="$(basename "${initscript}")"
40        disable
41        [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
42        [ "$STOP"  ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
43}
44
45enabled() {
46        name="$(basename "${initscript}")"
47        [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
48}
49
50depends() {
51        return 0
52}
53
54help() {
55        cat <<EOF
56Syntax: $initscript [command]
57
58Available commands:
59        start   Start the service
60        stop    Stop the service
61        restart Restart the service
62        reload  Reload configuration files (or restart if that fails)
63        enable  Enable service autostart
64        disable Disable service autostart
65$EXTRA_HELP
66EOF
67}
68
69initscript="$1"
70[ "$#" -ge 1 ] && shift
71action="$1"
72[ "$#" -ge 1 ] && shift
73
74. "$initscript"
75
76cmds=
77for cmd in $EXTRA_COMMANDS; do
78        cmds="${cmds:+$cmds$N}$cmd) $cmd \"\$@\";;"
79done
80eval "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;;
92esac"
Note: See TracBrowser for help on using the repository browser.