Skip to content

Instantly share code, notes, and snippets.

@DennisLfromGA
Created July 6, 2017 00:12
Show Gist options
  • Save DennisLfromGA/63615638cb06cf1a5924cc3b131be3be to your computer and use it in GitHub Desktop.
Save DennisLfromGA/63615638cb06cf1a5924cc3b131be3be to your computer and use it in GitHub Desktop.
Shows Vital Product Data (VPD) for Chrome OS device.
#!/bin/sh -e
### 'cb' - Shows Vital Product Data (VPD) for Chrome OS device.
###
### Typical VPD data
###
## sudo dump_vpd_log --full --stdout
## "mlb_serial_number"="CN0V..................."
## "ppid"="CN0V..................."
## "asset_tag"=""
## "model_name"="Dell Chromebook 13 7310"
## "serial_number"="8SV...."
## "service_tag"="8SV...."
## "initial_locale"="en-US"
## "initial_timezone"="America/Los_Angeles"
## "keyboard_layout"="xkb:us::eng"
## "region"="us"
## "rlz_brand_code"="DEAE"
## "___ro_rw_delimiter___"="___RW_VPD_below___"
## "gbind_attribute"="=CioKIFFntDzhD9lBY3xoNwpHSYnzGMo....................................."
## "ubind_attribute"="=CioKIF_ufa0KSDK3iN4ANjHdCA9S0gf....................................."
## "ActivateDate"="2016-06"
## "block_devmode"="0"
## "check_enrollment"="0"
###
### Variables
###
APPLICATION="${0##*/}"
VPDMSG="Shows Vital Product Data (VPD) for Chrome OS device."
VPDOUT='/tmp/vpd.log'
XIT=0
###
### Start with current data
###
rm $VPDOUT 2>/dev/null || true
sudo dump_vpd_log --full --stdout > $VPDOUT || true
###
### Grab data for each attribute
###
mlb=$(echo "MLB Serial Number: $(cat $VPDOUT | grep '"mlb' | cut -d = -f 2 | sed 's/"//g')")
ppid=$(echo "PPID: $(cat $VPDOUT | grep '"ppid' | cut -d = -f 2 | sed 's/"//g')")
mod=$(echo "Model Name: $(cat $VPDOUT | grep '"mod' | cut -d = -f 2 | sed 's/"//g')")
seri=$(echo "Serial Number: $(cat $VPDOUT | grep '"seri' | cut -d = -f 2 | sed 's/"//g')")
serv=$(echo "Service Tag: $(cat $VPDOUT | grep '"serv' | cut -d = -f 2 | sed 's/"//g')")
loc=$(echo "Locale: $(cat $VPDOUT | grep 'locale' | cut -d = -f 2 | sed 's/"//g')")
tim=$(echo "Timezone: $(cat $VPDOUT | grep 'timezone' | cut -d = -f 2 | sed 's/"//g')")
key=$(echo "Keyboard Layout: $(cat $VPDOUT | grep '"key' | cut -d = -f 2 | sed 's/"//g')")
reg=$(echo "Region: $(cat $VPDOUT | grep 'region' | cut -d = -f 2 | sed 's/"//g')")
rlz=$(echo "RLZ Brand Code: $(cat $VPDOUT | grep 'region' | cut -d = -f 2 | sed 's/"//g')")
act=$(echo "Activate Date: $(cat $VPDOUT | grep '"Act' | cut -d = -f 2 | sed 's/"//g')")
dev=$(echo "Block Devmode: $(cat $VPDOUT | grep '"block' | cut -d = -f 2 | sed 's/"//g')")
enr=$(echo "Enterprise Enrolled: $(cat $VPDOUT | grep '"check' | cut -d = -f 2 | sed 's/"//g')")
all=$(env echo -e "$mod\n$seri\n$serv\n$loc\n$tim\n$key\n$reg\n$rlz\n$mlb\n$ppid\n$act\n$dev\n$enr")
###
### Check for links to 'cb'
###
case $APPLICATION in
cb|vpd) :;;
mlb*) echo "$mlb"; exit $XIT;;
ppid*) echo "$ppid"; exit $XIT;;
mod*) echo "$mod"; exit $XIT;;
seri*|sn) echo "$seri"; exit $XIT;;
serv*|tag) echo "$serv"; exit $XIT;;
loc*) echo "$loc"; exit $XIT;;
tim*|tz) echo "$tim"; exit $XIT;;
key*|kb) echo "$key"; exit $XIT;;
reg*) echo "$reg"; exit $XIT;;
rlz*) echo "$rlz"; exit $XIT;;
act*|ad) echo "$act"; exit $XIT;;
dev*|dm) echo "$dev"; exit $XIT;;
enr*) echo "$enr"; exit $XIT;;
esac
###
### Show all attributes
###
if [ -z "$1" ]; then
echo "$VPDMSG"
env echo -e "\n$all"
fi
###
### Check for command-line options
###
while [ "$#" -gt 0 ];
do
case "$1" in
mlb*) echo "$mlb";;
ppid*) echo "$ppid";;
mod*) echo "$mod";;
seri*|sn) echo "$seri";;
serv*|tag) echo "$serv";;
loc*) echo "$loc";;
tim*) echo "$tim";;
key*) echo "$key";;
reg*) echo "$reg";;
rlz*) echo "$rlz";;
act*) echo "$act";;
dev*|dm) echo "$dev";;
enr*) echo "$enr";;
all*) echo "$all";;
*) echo "$VPDMSG"
echo "Usage: cb [model|serial|service|locale|timezone|keyboard|region|rlz|mlb|ppid|activate|devmode|enrolled|all"
env echo -e "\n$all"
XIT=1 ;;
esac
shift
done
###
exit $XIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment