script/init.d/ethercat
author Florian Pose <fp@igh-essen.com>
Thu, 02 Oct 2008 09:56:39 +0000
branchstable-1.3
changeset 1760 036f19bde00b
parent 1745 07fd94c5119d
permissions -rwxr-xr-x
Fixed lsec for terminals that do not support getting the terminal width.
1740
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
#!/bin/sh
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
#------------------------------------------------------------------------------
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
#  Init script for EtherCAT
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#  $Id$
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
#  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
#  This file is part of the IgH EtherCAT Master.
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#  The IgH EtherCAT Master is free software; you can redistribute it
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
#  and/or modify it under the terms of the GNU General Public License
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
#  as published by the Free Software Foundation; either version 2 of the
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
#  License, or (at your option) any later version.
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
#  The IgH EtherCAT Master is distributed in the hope that it will be
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
#  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
#  GNU General Public License for more details.
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
#  You should have received a copy of the GNU General Public License
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
#  along with the IgH EtherCAT Master; if not, write to the Free Software
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
#  The right to use EtherCAT Technology is granted and comes free of
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
#  charge under condition of compatibility of product made by
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#  Licensee. People intending to distribute/sell products based on the
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#  code, have to sign an agreement to guarantee that products using
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#  software based on IgH EtherCAT master stay compatible with the actual
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#  EtherCAT specification (which are released themselves as an open
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#  standard) as the (only) precondition to have the right to use EtherCAT
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#  Technology, IP and trade marks.
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#------------------------------------------------------------------------------
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
### BEGIN INIT INFO
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
# Provides:          ethercat
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
# Required-Start:    $local_fs $syslog $network
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
# Should-Start:      $time ntp
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
# Required-Stop:     $local_fs $syslog $network
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
# Should-Stop:       $time ntp
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
# Default-Start:     3 5
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
# Default-Stop:      0 1 2 6
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
# Short-Description: IgH EtherCAT master modules
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
# Description:
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
### END INIT INFO
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
#------------------------------------------------------------------------------
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    52
MODPROBE=/sbin/modprobe
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    53
RMMOD=/sbin/rmmod
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    54
MODINFO=/sbin/modinfo
1740
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
#------------------------------------------------------------------------------
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
ETHERCAT_CONFIG=/etc/sysconfig/ethercat
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    60
if [ ! -r ${ETHERCAT_CONFIG} ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    61
    echo ${ETHERCAT_CONFIG} not existing;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    62
    if [ "${1}" = "stop" ]; then
1740
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	exit 0
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
    else
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	exit 6
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
    fi
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
fi
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    69
. ${ETHERCAT_CONFIG}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    70
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    71
#------------------------------------------------------------------------------
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    72
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    73
function exit_success()
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    74
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    75
    if [ -r /etc/rc.status ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    76
        rc_reset
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    77
        rc_status -v
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    78
        rc_exit
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    79
    else
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    80
        echo " done"
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    81
        exit 0
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    82
    fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    83
}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    84
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    85
#------------------------------------------------------------------------------
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    86
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    87
function exit_running()
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    88
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    89
    if [ -r /etc/rc.status ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    90
        rc_reset
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    91
        rc_status -v
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    92
        rc_exit
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    93
    else
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    94
        echo " running"
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    95
        exit 0
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    96
    fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    97
}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    98
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
    99
#------------------------------------------------------------------------------
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   100
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   101
function exit_fail()
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   102
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   103
    if [ -r /etc/rc.status ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   104
        rc_failed
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   105
        rc_status -v
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   106
        rc_exit
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   107
    else
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   108
        echo " failed"
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   109
        exit 1
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   110
    fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   111
}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   112
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   113
#------------------------------------------------------------------------------
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   114
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   115
function exit_dead()
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   116
{
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   117
    if [ -r /etc/rc.status ]; then
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   118
        rc_failed
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   119
        rc_status -v
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   120
        rc_exit
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   121
    else
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   122
        echo " dead"
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   123
        exit 1
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   124
    fi
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   125
}
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   126
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   127
#------------------------------------------------------------------------------
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   128
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   129
function parse_mac_address()
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   130
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   131
    if [ -z "${1}" ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   132
        MAC=""
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   133
    elif echo ${1} | grep -qE '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$'; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   134
        MAC=${1}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   135
    else
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   136
        echo Invalid MAC address \"${1}\" in ${ETHERCAT_CONFIG}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   137
        exit_fail
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   138
    fi 
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   139
}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   140
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   141
#------------------------------------------------------------------------------
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   142
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   143
if [ -r /etc/rc.status ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   144
    . /etc/rc.status
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   145
    rc_reset
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   146
fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   147
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   148
case "${1}" in
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   149
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   150
start)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   151
    echo -n "Starting EtherCAT master "
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   152
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   153
    # construct DEVICES and BACKUPS from configuration variables
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   154
    DEVICES=""
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   155
    BACKUPS=""
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   156
    MASTER_INDEX=0
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   157
    while true; do
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   158
        DEVICE=$(eval echo "\${MASTER${MASTER_INDEX}_DEVICE}")
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   159
        BACKUP=$(eval echo "\${MASTER${MASTER_INDEX}_BACKUP}")
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   160
        if [ -z "${DEVICE}" ]; then break; fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   161
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   162
        if [ ${MASTER_INDEX} -gt 0 ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   163
            DEVICES=${DEVICES},
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   164
            BACKUPS=${BACKUPS},
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   165
        fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   166
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   167
        parse_mac_address ${DEVICE}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   168
        DEVICES=${DEVICES}${MAC}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   169
        
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   170
        parse_mac_address ${BACKUP}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   171
        BACKUPS=${BACKUPS}${MAC}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   172
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   173
        MASTER_INDEX=$(expr ${MASTER_INDEX} + 1)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   174
    done
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   175
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   176
    # load master module
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   177
    if ! ${MODPROBE} ec_master main=${DEVICES} backup=${BACKUPS}; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   178
        exit_fail
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   179
    fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   180
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   181
    # check for modules to replace
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   182
    for MODULE in ${DEVICE_MODULES}; do
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   183
        ECMODULE=ec_${MODULE}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   184
        if ! ${MODINFO} ${ECMODULE} > /dev/null; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   185
            continue # ec_* module not found
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   186
        fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   187
        if lsmod | grep "^${MODULE} " > /dev/null; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   188
            if ! ${RMMOD} ${MODULE}; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   189
                exit_fail
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   190
            fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   191
        fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   192
        if ! ${MODPROBE} ${ECMODULE}; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   193
            ${MODPROBE} ${MODULE} # try to restore module
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   194
            exit_fail
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   195
        fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   196
    done
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   197
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   198
    exit_success
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   199
    ;;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   200
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   201
stop)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   202
    echo -n "Shutting down EtherCAT master "
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   203
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   204
    # unload EtherCAT device modules
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   205
    for MODULE in ${DEVICE_MODULES} master; do
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   206
        ECMODULE=ec_${MODULE}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   207
        if ! lsmod | grep -q "^${ECMODULE} "; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   208
            continue # ec_* module not loaded
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   209
        fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   210
        if ! ${RMMOD} ${ECMODULE}; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   211
            exit_fail
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   212
        fi;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   213
    done
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   214
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   215
    sleep 1
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   216
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   217
    # reload previous modules
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   218
    for MODULE in ${DEVICE_MODULES}; do
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   219
        if ! ${MODPROBE} ${MODULE}; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   220
            echo Warning: Failed to restore ${MODULE}.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   221
        fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   222
    done
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   223
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   224
    exit_success
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   225
    ;;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   226
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   227
restart)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   228
    $0 stop || exit 1
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   229
    sleep 1
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   230
    $0 start
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   231
    ;;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   232
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   233
status)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   234
    echo -n "Checking for EtherCAT "
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   235
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   236
    lsmod | grep -q "^ec_master "
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   237
    MASTERS_RUNNING=$?
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   238
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   239
    ! grep -q "(WAITING)" /sys/ethercat/master*/info
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   240
    MASTERS_IDLE=$?
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   241
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   242
    # master module loaded and masters not waiting for devices?
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   243
    if [ ${MASTERS_RUNNING} -eq 0 -a ${MASTERS_IDLE} -eq 0 ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   244
        exit_running
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   245
    else
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   246
        exit_dead
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   247
    fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   248
    ;;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   249
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   250
*)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   251
    echo "USAGE: $0 {start|stop|restart|status}"
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   252
    ;;
1740
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
esac
fa0af75bfbe9 MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   256
if [ -r /etc/rc.status ]; then
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   257
    rc_exit
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   258
else
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   259
    exit 1
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   260
fi
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   261
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1740
diff changeset
   262
#------------------------------------------------------------------------------