-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrefreshTools.sh
executable file
·74 lines (62 loc) · 2.58 KB
/
refreshTools.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# refresh ukmon-pitools
# Copyright (C) 2018-2023 Mark McIntyre
myself=$(readlink -f $0)
here="$( cd "$(dirname "$myself")" >/dev/null 2>&1 ; pwd -P )"
cd $here
export PYTHONPATH=$here:~/source/RMS
source ~/vRMS/bin/activate
echo "checking required python libs are installed"
pip list | grep boto3 || pip install boto3
# python-crontab v2.5.1 for python 2.7 backwards compatability. Sigh.
pip list | grep python-crontab | grep 2.5.1 || pip install python-crontab==2.5.1
pip list | grep paramiko || pip install paramiko
# validate the ini file
echo "checking ini file is valid"
python -c "import ukmonInstaller as pp ; pp.validateIni('${here}', '3.11.55.160');"
source $here/ukmon.ini
echo "refreshing toolset"
git stash
git pull
git stash apply
# creating an ssh key if not already present
if [ ! -f ${UKMONKEY} ] ; then
echo "creating ukmon ssh key"
ssh-keygen -t rsa -f ${UKMONKEY} -q -N ''
echo "Copy this public key and email it to the ukmon team, then "
echo "wait for confirmation its been installed and rerun this script"
echo ""
cat ${UKMONKEY}.pub
echo ""
read -p "Press any key to continue"
fi
# if the station is configured, retrieve the AWS keys and test connectivity.
if [[ "$LOCATION" != "NOTCONFIGURED" && "$LOCATION" != "" ]] ; then
echo "checking for ukmon config changes"
python -c "import ukmonInstaller as pp ; pp.getLatestKeys('${here}') ;"
if [ -f archive.key ] ; then \rm archive.key ; fi
echo "checking the RMS config file, crontab and icons"
source ~/vRMS/bin/activate
source $here/ukmon.ini
cd $(dirname $RMSCFG)
export PYTHONPATH=$here:~/source/RMS
python -c "import ukmonInstaller as pp ; pp.installUkmonFeed('${RMSCFG}');"
echo "testing connections"
python $here/sendToLive.py test test
python $here/uploadToArchive.py test
echo "if you did not see two success messages contact us for advice"
if [ "$DOCKER_RUNNING" != "true" ] ; then read -p "Press any key to finish" ; fi
echo "done"
else
statid=$(grep stationID $RMSCFG | awk -F" " '{print $2}')
if [ "$statid" == "XX0001" ] ; then
echo "You must configure RMS before setting up the ukmon tools"
else
python -c "import ukmonInstaller as pp ; pp.addDesktopIcons('${here}', '${statid}');"
echo "Location missing - unable to continue. Please obtain a location code from the UKMON team,"
echo "then update the UKMON Config File using the desktop icon and rerun this script."
fi
sleep 5
if [ "$DOCKER_RUNNING" != "true" ] ; then read -p "Press any key to end" ; fi
exit 1
fi