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

verif_env_thomx.sh 10.2 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

Philippe Gauron's avatar
Philippe Gauron committed
14
cd "$(dirname "$0")"
15 16
REPO_DIR=$(pwd)/

17 18 19 20 21 22 23 24 25 26

## 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"

Philippe Gauron's avatar
Philippe Gauron committed
27
if [ "${DEBUG}" -eq 1 ] 
28 29
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
  echo
fi

### Checking and correcting of initial configuration

## ${SERVERNAME} == ${TANGOSERVER} -> TANGO-DB=1
43 44 45 46 47 48 49 50
if [ "${DEPENDENCIES}" -eq 1 ] \
   && [ "${SERVERNAME}" == "${TANGOSERVER}" ] \
   && [ "${TANGO_DB}" -eq 0 ]
then
  warning "${SERVERNAME} == ${TANGOSERVER}, TANGO_DB will be be considered set."
  TANGO_DB=1
fi

51 52

## ARCHIVING=1 -> DATABASE=1
Philippe Gauron's avatar
Philippe Gauron committed
53 54 55
if [ "${DEPENDENCIES}" -eq 1 ] \
   && [ "${DATABASE}" -eq 0 ] \
   && [ "${ARCHIVING}" -eq 1 ] 
56 57 58 59 60 61
then
  warning "installation of ARCHIVING asked, DATABASE will be considered set."
  DATABASE=1
fi


62
## CLIENT=1 -> TANGO=1
Philippe Gauron's avatar
Philippe Gauron committed
63 64
if [ "${DEPENDENCIES}" == 1 ] \
   && [ "${CLIENT}" -eq 1 ] 
65 66 67 68 69 70
then
  warning "installation of CLIENT asked, TANGO will be considered set."
  TANGO=1
fi


71
## TANGO_DB=1 -> TANGO=1 & DATABASE=1
72 73
if [ "${DEPENDENCIES}" -eq 1 ] \
   && [ "${TANGO_DB}" -eq 1 ]
74
then
75 76 77 78 79 80 81 82 83 84
  if [ "${TANGO}" -eq 0 ]
  then
    warning "installation of TANGO_DB asked, TANGO will be considered set."
    TANGO=1
  fi
  if [ "${DATABASE}" -eq 0 ]
  then
    warning "installation of TANGO_DB asked, DATABASE will be considered set."
    DATABASE=1
  fi
85 86 87 88 89 90 91 92 93 94 95 96
fi










## global variable definition
97
CORRECT_TANGO_HOST="srv-2.thomx.fr:20000"
98
ERROR=0
99
typeset -a PAQUETS_PIP PAQUETS_VERSION
100 101 102 103 104
## pip packages
PIP_PACKAGES_NUMBER=4
## test
#PIP_PACKAGES_NUMBER=5
PIP_PACKAGES=(
105 106 107 108
  [0]="fandango"
  [1]="taurus"
  [2]="PyYAML"
  [3]="QtPy"
109 110
## test
#   [3]="test_pip"
111
)
112 113
## pip packages version
PIP_PACKAGES_VERSION=(
114 115 116 117
  [0]="13.9.0"
  [1]="4.4.0"
  [2]="3.13"
  [3]="1.2.1"
118 119
## test
#  [3]="1.2.2test"
120
)
121 122 123
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
124
DEBIAN_PACKAGES_CLIENT="ntpdate libx32gcc-6-dev libgl1-mesa-dev:i386 libxinerama1:i386"
125

126

127 128


129 130 131 132 133 134



### INSTALLATION TEST

## DATABASE
Philippe Gauron's avatar
Philippe Gauron committed
135
if [ "${DATABASE}" -eq 1 ] 
136
then
137
  OUTPUT_DPKG=$(dpkg -s mariadb-server | grep Status)
Philippe Gauron's avatar
Philippe Gauron committed
138
  if [ "${OUTPUT_DPKG}" == "Status: install ok installed" ] 
139
  then
Philippe Gauron's avatar
Philippe Gauron committed
140
    if [ "${DEBUG}" -eq 1 ] 
141 142 143 144 145 146 147 148 149
    then
      info "DB server installed"
    fi
    DBSERVER_INSTALLED=1
  else
    warning "DB server not installed!"
    DBSERVER_INSTALLED=0
  fi

150 151
  OUTPUT_DPKG=$(dpkg -s mariadb-client | grep Status)
  if [ "${OUTPUT_DPKG}" == "Status: install ok installed" ]
152
  then
Philippe Gauron's avatar
Philippe Gauron committed
153
    if [ "${DEBUG}" -eq 1 ] 
154 155 156 157 158 159 160 161 162 163
    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
Philippe Gauron's avatar
Philippe Gauron committed
164 165 166
  if [ "${DBCLIENT_INSTALLED}" -eq 1 ] \
     && [ "${DBSERVER_INSTALLED}" -eq 1 ] \
     && [ "${DATABASE_RUNNING}" -eq 1 ] 
167
  then
Philippe Gauron's avatar
Philippe Gauron committed
168
    if [ "${DEBUG}" -eq 1 ] 
169 170 171 172
    then
      info "DATABASE running"
    fi

Philippe Gauron's avatar
Philippe Gauron committed
173 174 175 176 177 178 179
  else
    warning "DATABASE not running!"
  fi
fi


##TANGO_DB
Philippe Gauron's avatar
Philippe Gauron committed
180
if [ "${TANGO_DB}" -eq 1 ] 
Philippe Gauron's avatar
Philippe Gauron committed
181 182
then
  echo "Following asked password is MariaDB password for tango database"
Philippe Gauron's avatar
Philippe Gauron committed
183 184
  RESULT_DATABASE=$(mysql -h "${TANGOSERVER}" -u tango tango -p -e "SHOW tables")
  if [ "${RESULT_DATABASE}" != "${CORRECT_OUTPUT_DATABASE}" ] 
Philippe Gauron's avatar
Philippe Gauron committed
185
  then
Philippe Gauron's avatar
Philippe Gauron committed
186
    if [ "${DEBUG}" -eq 1 ] 
187
    then
Philippe Gauron's avatar
Philippe Gauron committed
188
      info "DATABASE successfully installed"
189 190
    fi
  else
Philippe Gauron's avatar
Philippe Gauron committed
191
    warning "DATABASE installation failed!"
192 193 194 195
  fi
fi

## TANGO
Philippe Gauron's avatar
Philippe Gauron committed
196
if [ "${TANGO}" -eq 1 ] 
197
then
198
  ### yat & yat4tango
Philippe Gauron's avatar
Philippe Gauron committed
199 200 201 202
  if [ -d /usr/include/yat ] \
     && [ -d /usr/include/yat4tango ] \
     && [ -e /usr/lib/libyat.so ] \
     && [ -e /usr/lib/libyat4tango.so ] 
203
  then
Philippe Gauron's avatar
Philippe Gauron committed
204
    if [ "${DEBUG}" -eq 1 ] 
205 206 207 208 209 210 211
    then
      info "yat & yat4tango successfully installed"
    fi
  else
    warning "yat & yat4tango installation failed!"
  fi

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 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272


  ### Environment settings

  ## python : python -V >= 2.7 and < 3
  if [[ ! $(python -V 2>&1) == "Python 2.7"* ]] 
  then
    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
  fi


  ## 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++))
  do
    PIP_PACKAGE_NOT_INSTALLED=1
    PIP_COMMAND=$(pip show "${PIP_PACKAGES[$package]}") && PIP_PACKAGE_NOT_INSTALLED=0
    if [ "${PIP_PACKAGE_NOT_INSTALLED}" -ne 0 ] 
    then
      warning "pip package ${PIP_PACKAGES[$package]} is not installed"
    else
      COMMAND_VERSION_INCORRECT=1
      echo "${PIP_COMMAND}" | grep "${PIP_PACKAGES_VERSION[$package]}" > /dev/null && COMMAND_VERSION_INCORRECT=0
      if [ "${COMMAND_VERSION_INCORRECT}" -ne 0 ] 
      then
        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
      fi
    fi
  done

  ## Checking debian packages installation
  for package in ${DEBIAN_PACKAGES}
  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





273 274 275 276
  ### Java version
  #### check if Java is not openjdk
  if [[ $(java -version 2>&1) != *"OpenJDK"* ]]
  then
Philippe Gauron's avatar
Philippe Gauron committed
277
    if [ "${DEBUG}" -eq 1 ] 
278 279 280 281 282 283 284 285 286 287 288 289
    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
Philippe Gauron's avatar
Philippe Gauron committed
290
  if [ ${TANGOTEST_DS_UNDEFINED} -ne 0 ] 
291 292 293
  then
    warning "TangoTest Device Server is not defined"
  else
Philippe Gauron's avatar
Philippe Gauron committed
294
    if [ "${DEBUG}" -eq 1 ] 
295 296 297 298 299 300 301 302
    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
Philippe Gauron's avatar
Philippe Gauron committed
303
  if [ "${TANGOTEST_DEVICE_UNDEFINED}" -ne 0 ] 
304 305 306
  then
    warning "sys/tg_test/1 device is not defined"
  else
Philippe Gauron's avatar
Philippe Gauron committed
307
    if [ "${DEBUG}" -eq 1 ] 
308 309 310 311 312 313 314 315
    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
Philippe Gauron's avatar
Philippe Gauron committed
316
  if [ "${TANGOTEST_DEVICE_UNREACHABLE}" -ne 0 ] 
317 318 319 320 321 322
  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
Philippe Gauron's avatar
Philippe Gauron committed
323
    if [ "${TANGOTEST_DEVICE_UNREACHABLE2}" -ne 0 ] 
324 325 326
    then
      warning "TangoTest/test does not respond to ping"
    else
Philippe Gauron's avatar
Philippe Gauron committed
327
      if [ "${DEBUG}" -eq 1 ] 
328 329 330 331 332
      then
        info "TangoTest/test has been started"
      fi
    fi
  else
Philippe Gauron's avatar
Philippe Gauron committed
333
    if [ "${DEBUG}" -eq 1 ] 
334 335 336 337
    then
      info "TangoTest/test started"
    fi
  fi
338 339 340 341 342 343 344 345 346 347 348 349

  ### Checking TANGO_HOST
  source /etc/tangorc
  if [ "${TANGO_HOST}" == "${CORRECT_TANGO_HOST}" ] 
  then
    if [ "${DEBUG}" -eq 1 ] 
    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}'"
  fi
350 351 352
fi


353
### CLIENT
Philippe Gauron's avatar
Philippe Gauron committed
354
if [ "${CLIENT}" -eq 1 ] 
355 356
then
  ### libzmq libraries (temporary)
Philippe Gauron's avatar
Philippe Gauron committed
357 358 359 360
  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 ] 
361
  then
Philippe Gauron's avatar
Philippe Gauron committed
362
    if [ "${DEBUG}" -eq 1 ] 
363 364 365 366 367 368 369 370
    then
      info "local (temporary) libzmq successfully installed"
    fi
  else
    warning "local (temporary) libzmq installation failed!"
  fi

  ### labview libraries
Philippe Gauron's avatar
Philippe Gauron committed
371 372 373 374
  if [ -d /data/shared/lib/ ] \
     && [ -d /data/shared/lib/labview ] \
     && [ -d /data/shared/lib/labview/LabVIEW-2014 ] \
     && [ -d /data/shared/lib/labview/runtime ] 
375
  then
Philippe Gauron's avatar
Philippe Gauron committed
376
    if [ "${DEBUG}" -eq 1 ] 
377
    then
378
      info "local LabView libraries for GUI successfully installed"
379 380
    fi
  else
381
    warning "local LabView libraries for GUI installation failed!"
382 383 384 385 386 387
  fi

  ## Checking debian packages installation
  for package in ${DEBIAN_PACKAGES_CLIENT}
  do
    DEBIAN_PACKAGE_NOT_INSTALLED=1
Philippe Gauron's avatar
Philippe Gauron committed
388 389
    dpkg -l | grep ^ii | grep "${package} " > /dev/null && DEBIAN_PACKAGE_NOT_INSTALLED=0
    if [ "$?" -ne 0 ] 
390 391 392
    then
      warning "debian package ${package} is not installed"
    else
Philippe Gauron's avatar
Philippe Gauron committed
393
      if [ "${DEBUG}" -eq 1 ] 
394 395 396 397 398 399 400
      then
        info "debian package ${package} is installed"
      fi
    fi
  done
fi

401

402

403 404


405 406 407 408 409 410 411







412

413 414 415 416
## 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

417

418
## tango-binding : Hayg will tell what command can be use and what result should be returned
419 420


421 422
## TANGO_HOST_PROD or TANGO_HOST_DEV : Hayg will tell what command 
## can be use and what result should be returned
423 424


425
# /etc/hosts
426
echo
427
echo "Contents of /etc/hosts/:"
428 429 430 431 432
echo "-----"
cat /etc/hosts
echo "-----"

# /etc/tangorc
433
echo
434
echo "Contents of /etc/tangorc/:"
435 436 437 438
echo "-----"
cat /etc/tangorc
echo "-----"

439 440 441 442 443 444 445 446
if [ "${TANGO}" -eq 1 ] 
then
  # atkpanel 
  echo
  info "La fenêtre qui s'affiche doit avoir un statut vert"
  echo "Starting sys/database/2 ATKPanel"
  atkpanel sys/database/2
fi