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

   Mounts the RK on karma_mount_point and creates an empty index file 
   (var/smalldb), along with a fids directory (fids0/_00000), if needed.
 "
   exit 0
 fi
#
WASMOUNTED=1
if mount $1 2>/dev/null ; then
   WASMOUNTED=0
   echo -n Mounting the RK on $1" "
   while mount $1 2>/dev/null ; do sleep 1 ; echo -n \. ; done
   echo " "mounted!
fi
mkdir -p $1/{var,fids0/_00000}
if [ -f $1/var/smalldb ] ; then
   echo The file $1/var/smalldb already existed.
else
   echo Creating empty $1/var/smalldb
   touch $1/var/smalldb
fi
if [ $WASMOUNTED == 0 ] ; then 
   echo -n Unmounting $1 ..." "
   umount $1
   echo done!
fi