12_network-generate-ula 380 B

123456789101112131415
  1. #!/bin/sh
  2. [ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0
  3. r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"')
  4. r2=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"')
  5. r3=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"')
  6. uci -q batch <<-EOF >/dev/null
  7. set network.globals.ula_prefix=fd$r1:$r2:$r3::/48
  8. commit network
  9. EOF
  10. exit 0