| 1 | #!/bin/sh |
| 2 | VER=1.0 |
| 3 | # ============================================================================ |
| 4 | # |
| 5 | # Copyright (C) THALES. All rights reserved |
| 6 | # Author: Thomas Perennou (Viveris Technologies) |
| 7 | # Date : 03/12/2014 |
| 8 | # ============================================================================ |
| 9 | |
| 10 | ### BEGIN INIT INFO |
| 11 | # Provides: waitswitches |
| 12 | # Required-Start: $network |
| 13 | # Required-Stop: |
| 14 | # Should-Start: |
| 15 | # Default-Start: S |
| 16 | # Default-Stop: |
| 17 | # Short-Description: Wait switches |
| 18 | # Description: Wait for all switches are ready for running |
| 19 | ### END INIT INFO |
| 20 | |
| 21 | ENABLE="yes" |
| 22 | SCRIPTS=/opt/script/check_switches.sh /opt/trc6500/script/check_switches.sh |
| 23 | SCRIPT= |
| 24 | TIMEOUT=360 |
| 25 | |
| 26 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
| 27 | [ -f /etc/default/waitswitches ] && . /etc/default/waitswitches |
| 28 | for s in $SCRIPTS; do [ -x $s ] && SCRIPT=$s; done |
| 29 | [ -x "$SCRIPT" ] || exit 1 |
| 30 | [ "$ENABLE" = "yes" ] || exit 0 |
| 31 | |
| 32 | . /lib/lsb/init-functions |
| 33 | |
| 34 | do_start () { |
| 35 | log_action_msg "Wait all switches" |
| 36 | $SCRIPT -t $TIMEOUT -w |
| 37 | } |
| 38 | |
| 39 | case "$1" in |
| 40 | -v) |
| 41 | echo "$(basename $0), version $VER" |
| 42 | ;; |
| 43 | start) |
| 44 | do_start |
| 45 | ;; |
| 46 | restart|reload|force-reload) |
| 47 | echo "Error: argument '$1' not supported" >&2 |
| 48 | exit 3 |
| 49 | ;; |
| 50 | stop) |
| 51 | # No-op |
| 52 | ;; |
| 53 | *) |
| 54 | echo "Usage: $0 start|stop" >&2 |
| 55 | exit 3 |
| 56 | ;; |
| 57 | esac |
| 58 | |
| 59 | # vim:set tabstop=4 expandtab shiftwidth=4: |