Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

verif_env_thomx.sh 9.68 KB
Newer Older
1 2
#!/bin/bash

3
## ThomX environment verification script for computers managed by control-command team
4

5 6
## BEWARE : this script does not assure  that configuration is correct, 
## it is just a fast method to check if elements are bad configured
7

8 9
## continue when an error is encountered
set +e
10

11 12
## Set to 1 to print every message
DEBUG=1
13

14 15 16
cd $(dirname "$0")
REPO_DIR=$(pwd)/

17 18 19 20 21 22 23 24 25 26 27 28 29

## Getting printing functions
source "${REPO_DIR}/utils.sh"

## Getting global variables
source "${REPO_DIR}/globals.sh"

## Getting installation settings
source "${REPO_DIR}/installation_parameters.sh"

if [[ "${DEBUG}" -eq 1 ]]
then
  info "Installation settings"
30 31 32 33 34 35 36
  echo "DOWNLOAD_ONLY=${DOWNLOAD_ONLY}"
  echo "DEPENDENCIES=${DEPENDENCIES}"
  echo "DATABASE=${DATABASE}"
  echo "TANGO=${TANGO}"
  echo "CLIENT=${CLIENT}"
  echo "TANGO_DB=${TANGO_DB}"
  echo "ARCHIVING=${ARCHIVING}"
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  echo
fi

### Checking and correcting of initial configuration

## ${SERVERNAME} == ${TANGOSERVER} -> TANGO-DB=1

## ARCHIVING=1 -> DATABASE=1
if [[ "${DEPENDENCIES}" -eq 1 ]] \
   && [[ "${DATABASE}" -eq 0 ]] \
   && [[ "${ARCHIVING}" -eq 1 ]]
then
  warning "installation of ARCHIVING asked, DATABASE will be considered set."
  DATABASE=1
fi


54 55 56 57 58 59 60 61
## CLIENT=1 -> TANGO=1
if [ "${DEPENDENCIES}" == "1" ] && [ "${CLIENT}" -eq "1" ]
then
  warning "installation of CLIENT asked, TANGO will be considered set."
  TANGO=1
fi


62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
## TANGO_DB=1 -> TANGO=1 & DATABASE=1
if [ "${DEPENDENCIES}" == "1" ] && [ "${TANGO_DB}" -eq "1" ]
then
  warning "installation of TANGO_DB asked, TANGO will be considered set."
  TANGO=1
  DATABASE=1
fi











## global variable definition
81
CORRECT_TANGO_HOST="srv-2.thomx.fr:20000"
82
ERROR=0
83
typeset -a PAQUETS_PIP PAQUETS_VERSION
84 85 86 87 88
## pip packages
PIP_PACKAGES_NUMBER=4
## test
#PIP_PACKAGES_NUMBER=5
PIP_PACKAGES=(
89 90 91 92
  [0]="fandango"
  [1]="taurus"
  [2]="PyYAML"
  [3]="QtPy"
93 94
## test
#   [3]="test_pip"
95
)
96 97
## pip packages version
PIP_PACKAGES_VERSION=(
98 99 100 101
  [0]="13.9.0"
  [1]="4.4.0"
  [2]="3.13"
  [3]="1.2.1"
102 103
## test
#  [3]="1.2.2test"
104
)
105 106 107
DEBIAN_PACKAGES="python-qt4 python-qwt5-qt4 python-qtpy qt4-designer pyqt4-dev-tools"
## test
#DEBIAN_PACKAGES="test python-qt4 python-qwt5-qt4 python-qtpy qt4-designer pyqt4-dev-tools"
Philippe Gauron's avatar
Philippe Gauron committed
108
DEBIAN_PACKAGES_CLIENT="ntpdate libx32gcc-6-dev libgl1-mesa-dev:i386 libxinerama1:i386"
109

110

111 112


113 114 115 116 117 118 119 120



### INSTALLATION TEST

## DATABASE
if [[ "${DATABASE}" -eq 1 ]]
then
121 122
  OUTPUT_DPKG=$(dpkg -s mariadb-server | grep Status)
  if [[ "${OUTPUT_DPKG}" == "Status: install ok installed" ]]
123 124 125 126 127 128 129 130 131 132 133
  then
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "DB server installed"
    fi
    DBSERVER_INSTALLED=1
  else
    warning "DB server not installed!"
    DBSERVER_INSTALLED=0
  fi

134 135
  OUTPUT_DPKG=$(dpkg -s mariadb-client | grep Status)
  if [ "${OUTPUT_DPKG}" == "Status: install ok installed" ]
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
  then
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "DB client installed"
    fi
    DBCLIENT_INSTALLED=1
  else
    warning "DB client not installed!"
    DBCLIENT_INSTALLED=0
  fi

  /usr/sbin/service mysql status &> /dev/null && DATABASE_RUNNING=1
  if [[ "${DBCLIENT_INSTALLED}" -eq 1 ]] \
     && [[ "${DBSERVER_INSTALLED}" -eq 1 ]] \
     && [[ "${DATABASE_RUNNING}" -eq 1 ]]
  then
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "DATABASE running"
    fi

    echo "Following asked password is MariaDB password for tango database"
    RESULT_DATABASE=$(mysql -h localhost -u tango tango -p -e "SHOW tables")
    if [[ "${RESULT_DATABASE}" != "${CORRECT_OUTPUT_DATABASE}" ]]
    then
      if [[ "${DEBUG}" -eq 1 ]]
      then
        info "DATABASE successfully installed"
      fi
    else
      warning "DATABASE installation failed!"
    fi
  else
    warning "DATABASE not running!"
  fi
fi

## TANGO
if [[ "${TANGO}" -eq 1 ]]
175
then
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
  ### yat & yat4tango
  if [[ -d /usr/include/yat ]] \
     && [[ -d /usr/include/yat4tango ]] \
     && [[ -e /usr/lib/libyat.so ]] \
     && [[ -e /usr/lib/libyat4tango.so ]]
  then
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "yat & yat4tango successfully installed"
    fi
  else
    warning "yat & yat4tango installation failed!"
  fi

  ### Java version
  #### check if Java is not openjdk
  if [[ $(java -version 2>&1) != *"OpenJDK"* ]]
  then
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "Sun Java JDK successfully installed"
    fi
  else
    warning "OpenJDK Java has been installed"
  fi

  ### TangoTest

  #### if TangoTest/test is not defined
  TANGOTEST_DS_UNDEFINED=1
  /usr/lib/tango/tango_admin --check-server TangoTest/test && TANGOTEST_DS_UNDEFINED=0
  if [[ ${TANGOTEST_DS_UNDEFINED} -ne 0 ]]
  then
    warning "TangoTest Device Server is not defined"
  else
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "TangoTest Device Server is defined"
    fi
  fi

  #### if sys/tg_test/1 is not defined
  TANGOTEST_DEVICE_UNDEFINED=1
  /usr/lib/tango/tango_admin --check-device sys/tg_test/1 && TANGOTEST_DEVICE_UNDEFINED=0
  if [[ "${TANGOTEST_DEVICE_UNDEFINED}" -ne 0 ]]
  then
    warning "sys/tg_test/1 device is not defined"
  else
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "sys/tg_test/1 device is defined"
    fi
  fi

  #### if TangoTest/test does not respond to ping
  TANGOTEST_DEVICE_UNREACHABLE=1
  /usr/lib/tango/tango_admin --ping-device sys/tg_test/1 && TANGOTEST_DEVICE_UNREACHABLE=0
  if [[ "${TANGOTEST_DEVICE_UNREACHABLE}" -ne 0 ]]
  then
    ## starts TangoTest device for instance test 
    /usr/lib/tango/TangoTest test & > /dev/null 
    sleep 1
    TANGOTEST_DEVICE_UNREACHABLE2=1
    /usr/lib/tango/tango_admin --ping-device sys/tg_test/1 && TANGOTEST_DEVICE_UNREACHABLE2=0
    if [[ "${TANGOTEST_DEVICE_UNREACHABLE2}" -ne 0 ]]
    then
      warning "TangoTest/test does not respond to ping"
    else
      if [[ "${DEBUG}" -eq 1 ]]
      then
        info "TangoTest/test has been started"
      fi
    fi
  else
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "TangoTest/test started"
    fi
  fi
255 256 257
fi


258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
### CLIENT
if [[ "${CLIENT}" -eq 1 ]]
then
  ### libzmq libraries (temporary)
  if [[ -d /data/shared/lib/ ]] \
     && [[ -e /data/shared/lib/libzmq.so ]] \
     && [[ -e /data/shared/lib/libzmq.so.5 ]] \
     && [[ -e /data/shared/lib/libzmq.so.5.2.1 ]]
  then
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "local (temporary) libzmq successfully installed"
    fi
  else
    warning "local (temporary) libzmq installation failed!"
  fi

  ### labview libraries
  if [[ -d /data/shared/lib/ ]] \
     && [[ -d /data/shared/lib/labview ]] \
     && [[ -d /data/shared/lib/labview/LabVIEW-2014 ]] \
     && [[ -d /data/shared/lib/labview/runtime ]]
  then
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "local LabView libraries successfully installed"
    fi
  else
    warning "local LabView libraries installation failed!"
  fi

  ## Checking debian packages installation
  for package in ${DEBIAN_PACKAGES_CLIENT}
  do
    DEBIAN_PACKAGE_NOT_INSTALLED=1
    $(dpkg -l | grep ^ii | grep "${package} " > /dev/null) && DEBIAN_PACKAGE_NOT_INSTALLED=0
    if [[ "$?" -ne 0 ]]
    then
      warning "debian package ${package} is not installed"
    else
      if [[ "${DEBUG}" -eq 1 ]]
      then
        info "debian package ${package} is installed"
      fi
    fi
  done
fi

306 307 308 309

### TANGO_HOST
source /etc/tangorc
if [[ "${TANGO_HOST}" == "${CORRECT_TANGO_HOST}" ]]
310
then
311
  if [[ "${DEBUG}" -eq 1 ]]
312 313 314 315 316
  then
    info "TANGO_HOST correctly set to ${TANGO_HOST}"
  fi
else
  warning "TANGO_HOST is not defined to '${CORRECT_TANGO_HOST}' but to '${TANGO_HOST}'"
317 318 319
fi


320 321 322 323 324 325 326 327 328 329






### Environment settings

## python : python -V >= 2.7 and < 3
if [[ ! $(python -V 2>&1) == "Python 2.7"* ]] 
330
then
331 332 333 334 335 336 337
  warning "Python is not installed in version 2.7"
  ERREUR=2
else
  if [[ "${DEBUG}" -eq 1 ]]
  then
    info "Python is not in version 2.7"
  fi
338 339
fi

340 341 342 343

## Check package installation of packages needed for taurus
## fandango==13.9.0 taurus==4.4.0 PyYAML==3.13 QtPy==1.2.1 python-qt4 python-qwt5-qt4 python-qtpy qt4-designer pyqt4-dev-tools
for ((package=0;package<${PIP_PACKAGES_NUMBER}; package++))
344
do
345 346 347
  PIP_PACKAGE_NOT_INSTALLED=1
  PIP_COMMAND=$(pip show "${PIP_PACKAGES[$package]}") && PIP_PACKAGE_NOT_INSTALLED=0
  if [[ "${PIP_PACKAGE_NOT_INSTALLED}" -ne 0 ]]
348
  then
349
    warning "pip package ${PIP_PACKAGES[$package]} is not installed"
350
  else
351 352 353
    COMMAND_VERSION_INCORRECT=1
    echo "${PIP_COMMAND}" | grep "${PIP_PACKAGES_VERSION[$package]}" > /dev/null && COMMAND_VERSION_INCORRECT=0
    if [[ "${COMMAND_VERSION_INCORRECT}" -ne 0 ]]
354
    then
355 356 357 358 359 360
      warning "pip package ${PIP_PACKAGES[$package]} is not installed  with version ${PIP_PACKAGES_VERSION[$package]}"
    else 
      if [[ "${DEBUG}" -eq 1 ]]
      then
        info "pip package ${PIP_PACKAGES[$package]} is installed with version ${PIP_PACKAGES_VERSION[$package]}"
      fi
361 362 363
    fi
  fi
done
364 365

## Checking debian packages installation
366
for package in ${DEBIAN_PACKAGES_CLIENT}
367
do
368 369
  DEBIAN_PACKAGE_NOT_INSTALLED=1
  $(dpkg -l | grep ^ii | grep "${package} " > /dev/null) && DEBIAN_PACKAGE_NOT_INSTALLED=0
370 371
  if [[ "$?" -ne 0 ]]
  then
372 373 374 375 376 377
    warning "debian package ${package} is not installed"
  else
    if [[ "${DEBUG}" -eq 1 ]]
    then
      info "debian package ${package} is installed"
    fi
378 379
  fi
done
380

381 382 383 384
## matlab : check that matlab is 2018b version
## toolbox : Hayg will define which version has to be installed
## Hayg will define what command can be used and what result should be returned

385

386
## tango-binding : Hayg will tell what command can be use and what result should be returned
387 388


389 390
## TANGO_HOST_PROD or TANGO_HOST_DEV : Hayg will tell what command 
## can be use and what result should be returned
391 392


393
# /etc/hosts
394
echo
395
echo "Contents of /etc/hosts/:"
396 397 398 399 400
echo "-----"
cat /etc/hosts
echo "-----"

# /etc/tangorc
401
echo
402
echo "Contents of /etc/tangorc/:"
403 404 405 406 407
echo "-----"
cat /etc/tangorc
echo "-----"

# atkpanel 
408
echo
409
info "La fenêtre qui s'affiche doit avoir un statut vert"
410
echo "Starting sys/database/2 ATKPanel"
411
atkpanel sys/database/2
412

413