#!/usr/bin/env bash
#
# Copyright 2008, Centova Technologies Inc.
#
# This script is used with re-issuable licenses to force a manual key update.
# Use this if you get an unexpected "License expired" message when logging in
# to Centova Cast.
#
RUNASCC=`dirname $0`/../system/runascc/runascc

ACTIVEDOMAIN=`$RUNASCC exec ccmanage sanitycheck nopassword | sed 's/^OK //'`

echo "Attempting to update license key for $ACTIVEDOMAIN ..."
RES=`$RUNASCC exec ccmanage reissuelicense @current`
OK=`echo "$RES" | grep -c "^OK"`
if [ $OK -gt 0 ]; then
	echo "License successfully updated for $ACTIVEDOMAIN"
else
	echo "License update failed.  Output was:"
	echo $RES
	exit 1
fi
exit 0

