Commit c86a1fa0 authored by Joanne Hugé's avatar Joanne Hugé

Add install-amarisoft.sh script

parent 74de04ee
#!/bin/bash
set -e
set -x
usage() {
cat << ENDUSAGE
Usage: $0 [-h] 2021_AMARISOFT_TAR_PATH AMARISOFT_TAR_PATH
-h Show help
ENDUSAGE
1>&2
}
while getopts "h" opt; do
case "${opt}" in
h )
usage
exit 1
;;
* )
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ "$#" -ne 2 ]; then
usage; exit
fi
ORS_NUMBER="$(hostname|sed 's/ors\([0-9]*\)/\1/g')"
BAND="$(/opt/amarisoft/get-sdr-info -b)"
OLD_AMARISOFT_TAR="$(realpath $1)"
AMARISOFT_TAR="$(realpath $2)"
# Cleanup for client
echo "Cleaning up"
# Install standard ORS configurations
echo "Installing standard ORS configurations"
cd $HOME
if ! stat config-amarisoft || ! file -d config-amarisoft; then
git clone https://lab.nexedi.com/nexedi/config-amarisoft
else
cd config-amarisoft
git stash
git fetch origin && git reset --hard origin/master
git stash pop || true
fi
VERSION="$(echo "$(basename $AMARISOFT_TAR)" | sed -n 's/amarisoft\.\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\)\.tar\.gz/\1/gp')"
OLD_VERSION="$(echo "$(basename $OLD_AMARISOFT_TAR)" | sed -n 's/amarisoft\.\(2021-[0-9]\{2\}-[0-9]\{2\}\)\.tar\.gz/\1/gp')"
if [ -z "$VERSION" ]; then
echo "Couldn't parse version from amarisoft tar filename"
echo "Following format is expected: amarisoft.XXXX-XX-XX.tar.gz"
usage; exit
fi
if [ -z "$OLD_VERSION" ]; then
echo "Couldn't parse version from 2021 amarisoft tar filename"
echo "Following format is expected: amarisoft.2021-XX-XX.tar.gz"
usage; exit
fi
if grep -q started $(find /srv/slapgrid -type f -name "*requested_state*" || true); then
echo "Please stop all slapos services before installing root access"
exit
fi
if ps aux | grep -v grep | grep -q "lteenb\|ltemme"; then
echo "Please stop all amarisoft processes before installing root access"
exit
fi
lsmod | grep -q sdr && { rmmod sdr || echo "Can't remove sdr module, please disable lte and reboot"; exit; } || true
OLD_TRX="$HOME/trx_sdr-linux-$OLD_VERSION"
if ! stat $OLD_TRX; then
cd $HOME
tar -xvf $OLD_AMARISOFT_TAR
cd $OLD_VERSION
tar -xvf trx_sdr-linux-$OLD_VERSION.tar.gz
mv trx_sdr-linux-$OLD_VERSION $OLD_TRX
rm -rf $OLD_VERSION
fi
cd $OLD_TRX/kernel && make clean && make && ./init.sh
$OLD_TRX/sdr_util version | grep -q "FPGA revision: 0-09-51" && { echo "Please update your FPGA before continuing, exiting..."; rm -rf $OLD_TRX; exit; }
cd $HOME
tar -xvf $AMARISOFT_TAR
cd $VERSION
./install.sh --default
rm -rf $OLD_AMARISOFT_TAR
rm -rf $AMARISOFT_TAR
RRH_CHECK="/root/trx_sdr/rrh_check.sh"
! grep -q ORS_PATCH $RRH_CHECK && sed -i '/echo "Initialize SDR kernel module"/a \ (cd /root/trx_sdr-linux-'"$OLD_VERSION"'/kernel && make clean && make && ./init.sh && rmmod sdr) # ORS_PATCH' $RRH_CHECK
cd $HOME/config-amarisoft/mme/ors-config
echo "ue_db: [{" > ue_db-ims.cfg
for i in {1..5}; do
cat >> ue_db-ims.cfg << EOF
sim_algo: "milenage",
imsi: "001010000000${ORS_NUMBER}$i",
opc: "000102030405060708090A0B0C0D0E0F",
amf: 0x9001,
sqn: "000000000000",
K: "00112233445566778899AABBCCDDEEFF",
impu: "impu${ORS_NUMBER}$i",
impi: "impi${ORS_NUMBER}$i@amarisoft.com",
EOF
if [ "$i" -ne 5 ]; then
echo "}, {" >> ue_db-ims.cfg
fi
done
echo "}]" >> ue_db-ims.cfg
cd $HOME/enb/config
ln -sf /$HOME/config-amarisoft/enb/ors-config/sib23.asn sib23.asn
if [ "$BAND" = "B39" ]; then
ln -sf /$HOME/config-amarisoft/enb/ors-config/enb.$BAND.cfg enb.cfg
else
ln -sf /$HOME/config-amarisoft/enb/ors-config/gnb.$BAND.cfg enb.cfg
fi
cd $HOME/mme/config
ln -sf /$HOME/config-amarisoft/mme/ors-config/mme-ims.cfg mme.cfg
mv ue_db-ims.cfg ue_db-ims.default.cfg
ln -sf /$HOME/config-amarisoft/mme/ors-config/ue_db* ue_db-ims.cfg
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