#!/bin/sh UPDATE_URL="http://ppa.linuxfactory.or.kr/images/petitboot" reboot() { echo 1 > /proc/sys/kernel/sysrq echo b > /proc/sysrq-trigger } get_cpuinfo_hardware() { grep ^Hardware /proc/cpuinfo | sed 's/Hardware\s*:\s*//' } get_machine() { case "$(get_cpuinfo_hardware)" in "Hardkernel ODROID-N2" | "Hardkernel ODROID-N2Plus") echo "odroidn2" ;; "Hardkernel ODROID-HC4") echo "odroidhc4" ;; esac } . /etc/spiupdate url=$UPDATE_URL/$(get_machine)/latest update=$(wget -qO - $url 2>/dev/null) if [ "x$update" = "x" ]; then echo "E: Invalid update info from $url" exit 1 fi hash1=$(echo $update | awk '{print $1}') link=$(echo $update | awk '{print $2}') mkdir -p /opt if ! wget $link -O /opt/spiboot.img 2>/dev/null; then echo "E: Invalid download link '$link'" exit 1 fi hash2=$(md5sum /opt/spiboot.img | awk '{print $1}') if [ $hash1 != $hash2 ]; then echo "E: Update binary is invalid (hash is not matched)" exit 1 fi if spiflash_update; then sleep 5 reboot fi