#!/bin/bash # # genome-bridge: Network bridge for Genome virtualization # # chkconfig: - 15 80 # # description: Network bridge for Genome virtualization. # # # # Source function library. . /etc/init.d/functions BRIDGE="genomebr0" GATEWAY_DEVICE=`ip route | grep ^default | cut -f5 -d" "` status() { /sbin/ifconfig $BRIDGE &> /dev/null } case "$1" in start) status if [ $? == 0 ]; then echo "Bridge is already up" exit 1 fi echo -n $"Starting genome-bridge: " touch /var/lock/subsys/genome-bridge /usr/bin/pkill -f "dhclient $GATEWAY_DEVICE" /usr/bin/pkill -f "dhclient $BRIDGE" /usr/sbin/brctl addbr $BRIDGE /sbin/ifconfig $GATEWAY_DEVICE 0.0.0.0 promisc up /usr/sbin/brctl addif $BRIDGE $GATEWAY_DEVICE /sbin/dhclient $BRIDGE #TODO: support static IPs RETVAL=$? ;; stop) echo -n $"Stopping genome-bridge: " /sbin/ifconfig $BRIDGE down /sbin/service network restart /usr/sbin/brctl delbr $BRIDGE RETVAL=$? rm -rf /var/lock/subsys/genome-bridge ;; restart|reload) $0 stop $0 start ;; status) status RETVAL=$? if [ $RETVAL == 0 ]; then echo "Bridge is up" else echo "Bridge is down" fi exit $RETVAL ;; *) echo $"Usage: $0 {start|stop|status|restart|reload}" RETVAL=1 esac exit $RETVAL