#!/bin/sh # # @(#) generate-rfc4193-addr.sh # # (c) Sep 2004 - Nov 2005 Holger Zuleger # # do what the name suggest # # firstpart = 64-Bit NTP time # secondpart = EUI-64 Identifier or 48 Bit MAC-Adress # sha1sum ($firstpart | $secondpart ) # use least significant 40 Bits of sha1sum # Build global Prefix (locally assigned == FD00::/8) # # (M1) 11. May 2006 # - check added, to complain if firstpart or secondpart is empty # - firstpart calculation changed in such a way, that only one reference # time is stored (ntpdate since version 4.2.0 use a list of ntp servers) # PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin debug=0 NTPSERVER=pool.ntp.org #(M1) firstpart=`ntpdate -d -q $NTPSERVER 2>/dev/null | sed "/reference/q" | sed -n "/reference/s/^reference time: *\([^ ]*\) .*/\1/p" | tr -d "."` secondpart=`ifconfig eth0 | grep "inet6 addr: fe80" | sed -n "s|^.*::\([^/]*\)/.*|\1|p" | tr -d ":"` #(M1) if test -z "$firstpart" -o -z "$secondpart" then echo "$0: installation error: check if ntpdate and ifconfig is in search path" exit 1 fi test $debug -eq 1 && echo "Firstpart: $firstpart" test $debug -eq 1 && echo "Secondpart: $secondpart" test $debug -eq 1 && echo "123456789o123456789o123456789o123456789o123456789o123456789o" test $debug -eq 1 && echo ${firstpart}${secondpart} | sha1sum globalid=`echo ${firstpart}${secondpart} | sha1sum | cut -c31-40` test $debug -eq 1 && echo $globalid echo fd${globalid} | sed "s|\(....\)\(....\)\(....\)|\1:\2:\3::/48|"