tr069prog.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/sh
  2. # file: tr069prog.sh
  3. # ====================================================================
  4. #
  5. # This script programs a unique TR-069 ACS Username and ACS Password
  6. # into a INT6400 powerline device and updates the Mfg feed file;
  7. # the original MAC, DAK and NMK are preserved; the MFG, NET and USR
  8. # HFIDs are set to the values defined in this file; the ACS Username
  9. # is derived from the original MAC; the ACS Password is derived from
  10. # the local host random number generator;
  11. #
  12. # devices should be programmed and tested using the PTS then updated
  13. # using his script; Atheros Powerline Toolkit 1.3.1 is needed;
  14. #
  15. # --------------------------------------------------------------------
  16. #
  17. # Define environment;
  18. #
  19. ETH=eth0 # PC ethernet port
  20. NVMFILE=tr069.nvm # This is the NVM file to program
  21. REFPIB=tr069.pib # This is the PIB template to use
  22. PIBFILE=tmp.pib # Temp PIB to modify
  23. MFGFILE=mfgfeed.txt # Manufacturing Feed File
  24. #
  25. # Determine device identity;
  26. #
  27. MAC=$(int6kid -Ai ${ETH})
  28. DAK=$(int6kid -Di ${ETH})
  29. NMK=$(int6kid -Mi ${ETH})
  30. #
  31. # Define default HFIDs;
  32. #
  33. MFG="MANUFACTURER MODEL-AB-02-01"
  34. NET="MANUFACTURER MODEL-AB-02-01"
  35. USR="MANUFACTURER MODEL-AB-02-01"
  36. #
  37. # Make a copy of PIB to edit
  38. #
  39. cp ${REFPIB} ${PIBFILE}
  40. #
  41. # Set MAC, DAK, NMK, MFG_HFID, NET_HFID and USR_HFID in PIB file
  42. #
  43. modpib ${PIBFILE} -M ${MAC} -D ${DAK} -N ${NMK} -S "${MFG}" -T "${NET}" -U "${USR}"
  44. UMAC=$(echo $MAC | sed 'y/abcdef/ABCDEF/' | sed 's/://g' | sed 's/ //g')
  45. OUI=$(echo $UMAC | cut -c 1-6)
  46. #
  47. # Build the ACS Username
  48. #
  49. UNAME="$OUI"-"$UMAC"
  50. #
  51. # Generate a 16 character lower case random ACS password
  52. #
  53. RANDOMPWORD=$(</dev/urandom tr -dc a-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 16))
  54. #
  55. # Set Username and Password in PIB file
  56. #
  57. setpib ${PIBFILE} 2DCC username ${UNAME}
  58. setpib ${PIBFILE} 2ECD password ${RANDOMPWORD}
  59. setpib ${PIBFILE} 2FCE byte 01
  60. #
  61. # Write NVM and PIB
  62. #
  63. int6kp -i ${ETH} -P ${PIBFILE} -N ${NVMFILE} -FF -D ${DAK}
  64. FW=$(int6k -qri ${ETH} | rev | cut -d " " -f1 | rev)
  65. #
  66. # Write the record to Mfg feed file
  67. #
  68. echo $UMAC"|"$FW"|"$RANDOMPWORD"|1.0|"$RANDOMPWORD"|000000" >> ${MFGFILE}