#!/bin/bash
 if [ $# -lt 1 ] || [ "${1%elp}" = "-h" ] || [ "${1%elp}" = "--h" ] ; then
   echo "\
   Usage: ${0##*/} [-h] karma_mount_point

   For a RK mounted on karma_mount_point, uses karma_helper 
   to create the file karma_mount_point/device_settings.
   This file contains the Rio Karma serial number needed for 
   properly setting the local cache ~/.openrio/pearl-serialNo/fileinfo
 "
   exit 0
 fi
#
TMP=${TMPDIR:-/tmp}/${0##*/}.$$ ; trap "rm $TMP* 2>/dev/null" EXIT
PATH=$PATH:.
#
umount $1
karma_helper -u
karma_helper -l
karma_helper -r
karma_helper -i | sed '/^ *$/d' > $TMP
karma_helper -b
#
echo -n Mounting the RK on $1" "
while ! mount $1 2>/dev/null ; do sleep 1 ; echo -n \. ; done
echo " "mounted!
echo Creating $1/device_settings
#
cp $TMP $1/device_settings
