Skip to content
Snippets Groups Projects
Commit 829fffa2 authored by David Mondou's avatar David Mondou
Browse files

Merge branch 'feature/change_hostname_sh' into 'master'

Changed hostname.sh to process the unit and board serial numbers completely in sh.

See merge request !6
parents d4161eba aa31e0ca
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
url="rigadogateway.com"
get_fuse () {
local name=$1
local pad=$2
# read the fuse and pad the left with zeros to the size of $pad
local fuse="0000000000"$(cat /sys/fsl_otp/$name | cut -b 3-)
len=$(( ${#fuse} - $pad ))
echo ${fuse:$len}
}
get_sn () {
local base=$1
local arena=$(get_fuse HW_OCOTP_GP$base 7)
if [[ ${arena:0:2} == "00" ]] ; then
# starts with "00", so doesn't start with ascii hex value
arena=${arena:2}
else
# doesn't start with "00", so starts with ascii hex value
arena=$(printf "\x${arena:0:2}${arena:2}")
fi
local build=$(get_fuse HW_OCOTP_GP$(( $base + 1)) 4)
local unit=$(get_fuse HW_OCOTP_GP$(( $base + 2)) 5)
echo "$arena$build-$unit"
}
if [[ "$(cat /sys/fsl_otp/HW_OCOTP_GP37)" == "0x0" ]] ; then
# No unit serial number set, use board serial number
hostname $(board_serial_number).$url
hostname $(get_sn 34).$url
else
# unit serial number set, use it
hostname $(unit_serial_number).$url
hostname $(get_sn 37).$url
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment