Last change
on this file since 1928 was
1928,
checked in by price, 16 years ago
|
config-init.sh: degrade to non-bash gracefully
|
File size:
1022 bytes
|
Rev | Line | |
---|
[1211] | 1 | # For a package which only configures another, "parent" package. |
---|
| 2 | # |
---|
[1928] | 3 | # Global variable PARENTPACKAGE names parent; unset for no parent, |
---|
| 4 | # array for (zero or one or) many parents. |
---|
[1211] | 5 | # |
---|
| 6 | # Global variable PACKAGE names this package, for log message. |
---|
| 7 | # |
---|
[1928] | 8 | # If BASH_VERSION is null or unset, accepts only one parent in |
---|
| 9 | # PARENTPACKAGE, or empty for zero. |
---|
[1211] | 10 | |
---|
| 11 | . /lib/init/vars.sh |
---|
| 12 | . /lib/lsb/init-functions |
---|
| 13 | . /lib/init/gen-files.sh |
---|
| 14 | |
---|
[1928] | 15 | if [ $BASH_VERSION ]; then |
---|
| 16 | handle_parents () { |
---|
| 17 | for p in "${PARENTPACKAGE[@]}"; do |
---|
| 18 | invoke-rc.d "$p" "$1" |
---|
| 19 | done |
---|
| 20 | } |
---|
| 21 | else |
---|
| 22 | handle_parents () { |
---|
| 23 | if [ -n "$PARENTPACKAGE" ]; then |
---|
| 24 | invoke-rc.d "$PARENTPACKAGE" "$1" |
---|
| 25 | fi |
---|
| 26 | } |
---|
| 27 | fi |
---|
| 28 | |
---|
[1211] | 29 | config_init () { |
---|
| 30 | case "$1" in |
---|
| 31 | start|reload|force-reload|restart) |
---|
| 32 | log_begin_msg "Reloading config for $PACKAGE" |
---|
| 33 | gen_files |
---|
| 34 | log_end_msg $? |
---|
[1928] | 35 | handle_parents "$1" |
---|
[1211] | 36 | ;; |
---|
| 37 | stop) |
---|
[1928] | 38 | handle_parents "$1" |
---|
[1211] | 39 | ;; |
---|
| 40 | *) |
---|
| 41 | log_success_msg "Usage: /etc/init.d/$PACKAGE {start|reload|force-reload|restart|stop}" |
---|
| 42 | ;; |
---|
| 43 | esac |
---|
| 44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.