puppet/modules/rhizo_base/files/var/SysmoBTS/maint.sh

76 lines
2 KiB
Bash

#!/bin/bash
# This script should be updated from time to time
# with nightly tasks for the BTS
# Consider when making modifications that
# running the script more than once is expected to be safe.
if [ "$PWD" != "/var/SysmoBTS" ]; then
OLDPWD=$PWD
cd /var/SysmoBTS
fi
SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/tmp/known-$RANDOM"
. /home/rhizomatica/bin/vars.sh
for bts in "${!BTS[@]}" ; do
#scp $SSH_OPTS authorized_keys root@${BTS[$bts]}:/home/root/.ssh/
if [ "$?" != "0" ] ; then
echo "No ssh access to BTS?"
continue
fi
# Commands to run on all BTS:
# Nothing to do.
_modelNR=$(ssh $SSH_OPTS ${BTS[$bts]} sysmobts-util model-nr)
if [ "$?" == "127" ]; then
echo "No sysmobts-util?"
continue
fi
_trxNR=$(ssh $SSH_OPTS ${BTS[$bts]} sysmobts-util trx-nr)
if [ "$?" != "0" ] ; then
echo "TRX Number?"
continue
fi
if [ "$_modelNR" == "65535" ] && [ "$_trxNR" == "255" ] ; then
echo "Looks like a SysmoBTS"
# Nothing to do
fi
if [ "$_modelNR" == "2050" ] && [ "$_trxNR" == "0" ] ; then
# Master Verified.
echo "BTS is a 2050 Master"
scp $SSH_OPTS pcu-ns root@${BTS[$bts]}:/bin/
scp $SSH_OPTS tgl-s root@${BTS[$bts]}:/bin/tgl
ssh $SSH_OPTS root@${BTS[$bts]} "chmod 750 /bin/pcu-ns /bin/tgl"
#gunzip -c sysmobts-mgr-arm.gz > sysmobts-mgr
#ssh $SSH_OPTS root@${BTS[$bts]} "systemctl stop sysmobts-mgr"
#scp $SSH_OPTS sysmobts-mgr root@${BTS[$bts]}:/usr/bin/
#ssh $SSH_OPTS root@${BTS[$bts]} "chmod 755 /usr/bin/sysmobts-mgr ; systemctl restart sysmobts-mgr"
# things to do
scp $SSH_OPTS rc.local root@${BTS[$bts]}:/etc/rc.local
ssh $SSH_OPTS root@${BTS[$bts]} "chmod 750 /etc/rc.local"
fi
if [ "$_trxNR" == "1" ] ; then
# Slave Verified.
echo "BTS is a 2050 Slave"
scp $SSH_OPTS pcu-ns root@${BTS[$bts]}:/bin/
scp $SSH_OPTS tgl-m root@${BTS[$bts]}:/bin/tgl
ssh $SSH_OPTS root@${BTS[$bts]} "chmod 750 /bin/pcu-ns /bin/tgl"
# Nothing to do.
fi
done
if [ "$OLDPWD" != "" ]; then
cd $OLDPWD
fi