#!/bin/bash

manta=https://us-east.manta.joyent.com
path=/Joyent_Dev/public/SmartOS/hotpatches/OS-5848

curl -sk $manta/$path/prcrhp > /var/tmp/prcrhp
curl -sk $manta/$path/prcrhp.conf > /var/tmp/prcrhp.conf

sum=`cksum /var/tmp/prcrhp`

if [[ "$sum" != "3459515846 153232 /var/tmp/prcrhp" ]]; then
        echo "prcrhp: checksum mismatch: $sum"
        exit 1
fi

sum=`cksum /var/tmp/prcrhp.conf`

if [[ "$sum" != "3477190513 42 /var/tmp/prcrhp.conf" ]]; then
        echo "prcrhp.conf: checksum mismatch: $sum"
        exit 1
fi

echo "Laying down prcrhp..."

sdc-oneachnode -a -X -g /var/tmp/prcrhp -d /kernel/drv/amd64

echo "Laying down prcrhp.conf..."

sdc-oneachnode -a -X -g /var/tmp/prcrhp.conf -d /kernel/drv

echo "Done. \"add_drv prcrhp\" when ready"

