-
-
Save pocki80/ab7e239ff78433f4ce8dec371aa0b237 to your computer and use it in GitHub Desktop.
boot-loader-update-check.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## load from github: | |
#curl -sS https://gist.githubusercontent.com/pocki80/ab7e239ff78433f4ce8dec371aa0b237/raw/boot-loader-update-check.sh | bash | |
# | |
## see https://community.ubnt.com/t5/EdgeMAX-Updates-Blog/EdgeMAX-EdgeRouter-X-X-SFP-bootloader-update/ba-p/1472216 | |
# | |
## check patch situation and propose commands | |
model=$(/usr/sbin/ubnt-hal show-version | grep "HW model"); c="0" | |
#sudo /usr/bin/ubnt-upgrade-boot --show ## show system boot-image | |
#/usr/sbin/ubnt-hal-e getBoardIdE ## get boardtype, i.e. "e50" for EdgeRouterX | |
#cat /tmp/device_model ## get model, i.e. ER-X, ER-X-SFP, ER-6P, EP-R8, EP-R6 | |
if ! (grep "^mtd2:" /proc/mtd 2>/dev/null | grep -q '00080000 00020000 "Bootloader"'); then | |
echo -e "\nInvalid device - do not update!\n" | |
elif (echo "$model" | grep -qi "EdgeRouter X "); then | |
echo -e "\n$model" | |
current=$(sudo md5sum /dev/mtdblock2 | cut -d" " -f1) | |
patched='7580ebd7ce9303243292f586ab7c6daf' | |
if [ "$current" == "$patched" ]; then | |
echo -e "already patched - do not update!\n" | |
elif [ "$current" == "fdb9059dce69d9902303c15c5870ee05" ] || [ "$current" == "dbce6273c8740383f84040e33f7fffe7" ]; then | |
version=$(cat /root.dev/version | awk '{print $2}' | tr -d 'v') | |
versionmajor=$(echo $version | cut -d "." -f1) | |
versionsub1=$(echo $version | cut -d "." -f2) | |
versionsub2=$(echo $version | cut -d "." -f3) | |
[ $versionmajor -eq 1 ] && [ $versionsub1 -eq 10 ] && [ $versionsub2 -ge 5 ] && echo "ATTENTION: POE stays on during reboot (v1.10.5+)" | |
[ $versionmajor -eq 2 ] && echo "ATTENTION: POE stays on during reboot (v2.0+)" | |
for i in $(grep -l br0 /opt/vyatta/config/active/interfaces/ethernet/*/bridge-group/bridge/node.val | cut -d"/" -f8); do | |
[ $(/sbin/ethtool $i | grep -c "Link detected: yes") -eq 1 ] && [ ! "$(/usr/sbin/ubnt-ifctl show-poe-status | grep -E "^$i" | awk '{print $2}')" == "ON" ] && c=$(($c +1)) | |
done | |
[ $(($c +0)) \> 1 ] \ | |
&& echo -e "unpatched - there are $c active eth-ports without poe - you should update!\n" \ | |
|| echo -e "unpatched - $c non-poe-port has a link - consider to update...\n" | |
echo " curl -O https://dl.ubnt.com/firmwares/edgemax/v1.8.0/update-boot.sh" | |
echo -e " sudo bash update-boot.sh\n" | |
else | |
echo -e "unknown current md5sum - please check device-type and patchlevel!\n" | |
fi | |
else | |
echo -e "\nThis is not an EdgeRouter - do not update!\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment