Commit 6c8644e8 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

write-sim-card: better bash

parent f363bd12
#!/bin/bash
#set -xv
SOURCE="${BASH_SOURCE[0]:-$0}"
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
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
export OCP_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
adm="12345678"
plmn="00101"
# Albania
......@@ -36,6 +25,6 @@ while read j ; do
[[ $j = "q" ]] && exit
i=$(printf "%05d" $imsinum)
echo programming imsi: $i
sudo $OCP_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
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment