1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#!/bin/sh
# Author: Martin Peylo <debian@izac.de>
### BEGIN INIT INFO
# Provides: tipc
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: TIPC Transparent Inter Process Communication
# Description: TIPC is an IPC for clusters
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Transparent Inter Process Communication"
NAME="tipcutils"
TIPCCONFIG="/sbin/tipc-config"
MODULE=/lib/modules/`uname -r`/kernel/net/tipc/tipc.ko
# Exit if the module is not installed
[ -e "$MODULE" ] || exit 0
# Exit if tipc-config is not installed
[ -x "$TIPCCONFIG" ] || exit 0
# Exit if the configuration is not installed
[ -e "/etc/default/$NAME" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
start_interfaces()
{
INTERFACES=`/sbin/ifconfig -a | sed -e '/^[^ ]/ { s/^\([^ ]*\).*$/\1/; p; }; d;'`
for IF in $INTERFACES
do
for TIPC_IF in $TIPC_INTERFACES
do
if [ $TIPC_IF = $IF ]; then
IFACE=$IF /etc/network/if-up.d/$NAME
fi
done
done
}
start_tipc()
{
echo Starting TIPC
if [ -n "$TIPC_NETID" ]; then
# Loads the module
test "$TIPC_VERBOSITY" = 1 && echo modprobe -q tipc
if ! modprobe -q tipc; then
echo "Error configuring TIPC, loading the kernel module failed!"
exit 0
fi
test "$TIPC_VERBOSITY" = 1 && echo $TIPCCONFIG -netid="$TIPC_NETID"
if ! $TIPCCONFIG -netid="$TIPC_NETID"; then
echo "Error configuring TIPC, setting the nedid to $TIPC_NETID failed!"
exit 0
fi
fi
if [ -n "$TIPC_REMOTE_MANAGEMENT" ]; then
test "$TIPC_VERBOSITY" = 1 && echo $TIPCCONFIG -mng="$TIPC_REMOTE_MANAGEMENT"
if [ "$TIPC_REMOTE_MANAGEMENT" = "true" ] || [ "$TIPC_REMOTE_MANAGEMENT" = "enable" ]; then
TIPC_REM_MGMNT="enable"
else
TIPC_REM_MGMNT="disable"
fi
if ! $TIPCCONFIG -mng="$TIPC_REM_MGMNT"; then
echo "Error configuring TIPC, setting the remote management to \"$TIPC_REM_MGMNT\" failed!"
exit 0
fi
fi
if [ -n "$TIPC_ADDR" ]; then
test "$TIPC_VERBOSITY" = 1 && echo $TIPCCONFIG -addr="$TIPC_ADDR"
if ! $TIPCCONFIG -addr="$TIPC_ADDR"; then
echo "Error configuring TIPC, setting the address to \"$TIPC_ADDR\" failed!"
exit 0
fi
fi
start_interfaces
}
stop_tipc()
{
# only unloading the module stops tipc
( lsmod |grep -q tipc ) && rmmod tipc
}
case "$1" in
start)
if [ "$TIPC_CONFIGURED" != "true" ]; then
echo TIPC is not configured in \"/etc/default/$NAME\".
echo To configure TIPC, run \`dpkg-reconfigure -plow tipcutils\`!
exit 0
fi
start_tipc
;;
stop)
stop_tipc
;;
restart|force-reload)
stop_tipc
start_tipc
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
:
|