#!/bin/sh hex2mac() { MAC="" seq 2 2 12 | while read i do echo -n ${1} | head -c $i | tail -c 2 if [ $i != 12 ] then echo -n ':' fi done | tr '[:upper:]' '[:lower:]' } if [ "${1}" = start ] then prefix=licheervnano if [ -e /boot/hostname.prefix ] then prefix=$(cat /boot/hostname.prefix) fi old_hostname=$(cat /etc/hostname) new_hostname=${prefix}-$(sha512sum /device_key_legacy | head -c 4) if [ -e /boot/hostname ] then new_hostname=$(cat /boot/hostname) fi if [ "${old_hostname}" != "${new_hostname}" ] then hostname ${new_hostname} echo ${new_hostname} > /etc/hostname sed -i -e "s/${old_hostname}/${new_hostname}/g" /etc/hosts fi echo "hostname: ${new_hostname}" if [ -e /boot/eth.mac ] then new_ethmac=$(cat /boot/ethmac) else new_ethmac=$(hex2mac 48da356f$(sha512sum /device_key_legacy | head -c 4)) fi ifconfig eth0 down ip link set eth0 address ${new_ethmac} ifconfig eth0 up echo "ethernet mac address: ${new_ethmac}" fi