#!/bin/bash
#set -xv
SOURCE=$(readlink -f "${BASH_SOURCE[0]:-$0}")
SOURCE_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
if [ -z "$1" ]; then
  echo "Usage: ./write-sim-card ORS_NUMBER [SIM_NUMBER_START]";
  exit;
fi
adm="12345678"
plmn="00101"
# Albania
#plmn="27603"
# Aruba
#plmn="36301"
#plmn="00112"
#plmn="99999"
if [ -z "$2" ]; then
  imsioffset=1
else
  imsioffset=$2
fi
let imsinum=$1*10+$imsioffset
j=y
while read j ; do
[[ $j = "q" ]] && exit
i=$(printf "%05d" $imsinum)
echo programming imsi: $i
sudo $SOURCE_DIR/program_uicc --adm ${adm} --iccid 898600611000000$i --imsi ${plmn}00000$i --isdn 06000$i --acc 0001 --key 00112233445566778899AABBCCDDEEFF --opc 000102030405060708090A0B0C0D0E0F -spn "RS-ORS$1-$i" --authenticate --noreadafter
let imsinum=$imsinum+1
done