#!/bin/sh # # Create lagg0 if necessary and flip current IP address from re0 to lagg0 # PROVIDE: lagg # REQUIRE: FILESYSTEMS # BEFORE: netif # KEYWORD: nojail . /etc/rc.subr . /etc/network.subr name="lagg" start_cmd="lagg_start" stop_cmd=":" cmdifn= : ${lagg_phys:=re0} : ${lagg_dev:=lagg0} : ${lagg_tmp:=/mnt} lagg_start() { # Ensure that the lagg device exists ifexists "$lagg_dev" || ifconfig "$lagg_dev" create # Create a ramdisk to temporarily hold a copy of ifconfig md_dev=$(/sbin/mdconfig -a -t swap -s 8m) mdmfs -S -s 8m -o async $md_dev "$lagg_tmp" # Copy /rescue (because it's statically linked) tar -cf - -C /rescue . | tar -xf - -C "$lagg_tmp" ### Actually flip the interface # Wanted IP address addr=$(/mnt/ifconfig "$lagg_phys" | grep 'inet ') # Delete address from existing interface /mnt/ifconfig "$lagg_phys" delete # Setup new interface /mnt/ifconfig "$lagg_dev" $addr laggport "$lagg_phys" up # Unwind ramdisk umount /mnt mdconfig -d -u ${md_dev#md} } load_rc_config $name run_rc_command "$@"