]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/net.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 5 Apr 2019 05:02:13 +0000 (06:02 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 5 Apr 2019 05:02:13 +0000 (06:02 +0100)
etc/profile.d/net.sh

index ccd7565e81df955955771232640dbf66736bf167..c0ab149c340a76f32b7ce63367286dce29d97587 100644 (file)
@@ -1,3 +1,13 @@
+net_str2mac() {
+       (
+               [ -n "$1" ] && echo "$1" || dd if=/dev/urandom bs=1024 count=1 2>/dev/null
+       ) | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/'
+       #locale str=${1:-"$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null)"}
+       #local str="$1"
+       #[ -n "$str" ] || str="$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null)"
+       #echo "$str" | wc -c
+}
+
 net_gateway_ip() {
        case "$OSTYPE" in
                darwin*) netstat -nr -f inet | awk '$1=="default"{print $2; exit}' ;;