View Single Post
Old 02-21-2011, 01:28 PM   #24
yifanlu
Kindle Dissector
yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.
 
Posts: 662
Karma: 170717
Join Date: Jul 2010
Device: Amazon Kindle 3
I've noticed a bug in your script. Amazon looks for "KEYFILES=$(ls /etc/uks/*pem)" aka, files ending with pem in the keys folder. Your keys end with ".hack" or ".amazon", so they won't work on < 3.1.

Also, here's my version of your script:

Code:
#!/bin/sh

PATH=/usr/sbin:/usr/bin:/sbin:/bin
_FUNCTIONS=/etc/rc.d/functions
[ -f ${_FUNCTIONS} ] && . ${_FUNCTIONS}

NAME=update-provider
KEY_DIR=/etc/uks
CONF_DIR=/mnt/us/$NAME

HACKS="HACK_UPDATES"
AMAZON="AMAZON_UPDATES"
SELECTION="amazon"

start() {
	# Make sure extra files aren't considered
	ACTIVE=$(find "$CONF_DIR" -maxdepth 1 -type f | sort -r | grep "$HACKS\|$AMAZON" | head -n 1)
	ACTIVE=${ACTIVE##*/}
	if [ "$ACTIVE" == "$HACKS" ]; then
		SELECTION="hack"
	fi
	
	# Check if user selection changed
	cmp $KEY_DIR/pubprodkey01.pem $KEY_DIR/pubprodkey01.$SELECTION.pem 2>&1 >/dev/null
	if [ $? -ne 0 ]; then
		mntroot_rw
		cp -f "$KEY_DIR/pubprodkey01.$SELECTION.pem" "$KEY_DIR/pubprodkey01.pem"
		cp -f "$KEY_DIR/pubprodkey02.$SELECTION.pem" "$KEY_DIR/pubprodkey02.pem"
		mntroot_ro
	fi
}

case "$1" in
  start)
    start
  ;;
  stop)
  ;;
  restart|force-reload)
    start
  ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
    exit 1
  ;;
esac

exit 0

Last edited by yifanlu; 02-21-2011 at 01:31 PM.
yifanlu is offline   Reply With Quote