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

Commit d9cbc914 authored by Philippe Gauron's avatar Philippe Gauron
Browse files

Merge branch 'tests-installation' into 'master'

Tests installation et installation java

See merge request CCThomX/installation!15
parents 2d6b3919 63b42203
## Error codes
E_INCORRECT_ARGS=1
E_NONROOT=2
E_INCORRECT_TANGOSERVER=3
E_INCORRECT_HOSTNAME=4
E_INCORRECT_SYSTEM=5
E_INCORRECT_DB_ROOT_PWD=6
E_INCORRECT_DB_TANGO_PWD=7
E_PARAM_ERROR=11
E_PARAM_WARNING=12
E_PARAM_INFO=13
E_ABORT_SCRIPT=21
E_ALREADY_INSTALLED=31
E_TANGOTEST_DS_UNDEFINED=41
E_TANGOTEST_DEVICE_UNDEFINED=42
E_TANGOTEST_DEVICE_UNREACHABLE=43
E_INCORRECT_JDK=44
## Awaited results
CORRECT_OUTPUT_DATABASE="+--------------------------------+
| Tables_in_tango |
+--------------------------------+
| access_address |
| access_device |
| attribute_alias |
| attribute_class |
| class_attribute_history_id |
| class_history_id |
| class_pipe_history_id |
| device |
| device_attribute_history_id |
| device_history_id |
| device_pipe_history_id |
| event |
| object_history_id |
| property |
| property_attribute_class |
| property_attribute_class_hist |
| property_attribute_device |
| property_attribute_device_hist |
| property_class |
| property_class_hist |
| property_device |
| property_device_hist |
| property_hist |
| property_pipe_class |
| property_pipe_class_hist |
| property_pipe_device |
| property_pipe_device_hist |
| server |
+--------------------------------+
28 rows in set ([0-9]\.[0-9]{2} sec)"
### INSTALLATION SETTINGS
## This file is sourced by installation, uninstallation and verification scripts
## 1 if to install, 0 otherwise
echo "==========================="
echo " INSTALLATION PARAMETERS"
echo "==========================="
## Downloading packages only
DOWNLOAD_ONLY=0
## Checking and activating dependencies
DEPENDENCIES=1
## Database server and PHPMyAdmin
DATABASE=0
## TANGO base tools
TANGO=0
## TANGO DB (depends on TANGO and DATABASE)
TANGO_DB=1
## Archiving (depends on DATABASE)
ARCHIVING=0
## Directory where to install
ARCHIVING_DIR="/var/archivage"
#!/bin/bash
sudo apt-get update
sudo apt-get clean
sudo apt-get autoremove --assume-yes
sudo apt-get upgrade --assume-yes
# stop at first error
set -e
## test desinstallation
sudo apt install --assume-yes kdiff3 debconf-utils
echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | sudo debconf-set-selections
sudo apt-get remove --purge phpmyadmin
## Removing of ARCHIVING installation packages
sudo apt purge --assume-yes unzip
sudo rm -rf /opt/ArchivingRoot
sudo rm -rf /etc/tangorc
if [ -h /etc/bashrc ]
then
sudo rm -f /etc/bash.bashrc
fi
sudo rm -rf /var/archivage
sudo apt-get remove --assume-yes --purge oracle-java8-installer oracle-java8-set-default mariadb-client mariadb-server
#sudo apt-get remove --purge phpmyadmin
## yat & yat4tango libraries
sudo apt purge --assume-yes subversion pkg-config cmake
sudo rm -f /var/www/phpmyadmin
## libtango-java
sudo apt purge --assume-yes libtango-java
## Removing of TANGO installation packages
## Hggit
sudo pip uninstall -y dulwich
###### TODO : uninstall hg-git
## GUI packages
sudo pip uninstall -y fandango taurus PyYAML QtPy
sudo apt purge --assume-yes python-qt4 qt4-designer pyqt4-dev-tools
sudo apt purge --assume-yes python-pytango python-qtpy python-qwt5-qt4 python-guiqwt python-pymca5 python-ply spyder python-lxml
## Development packages
sudo apt purge --assume-yes python-dev gcc g++ make xemacs21 man
### tango packages
#### TODO
#### dbconfig-common doit supprimer la base de données et révoquer les déconfigurer tango-db
echo 'dbconfig-common dbconfig-common/dbconfig-remove boolean true' | sudo debconf-set-selections
#### dbconfig-common doit supprimer la base de données et révoquer les droits
#### défaire la configuration de la base de données de tango-db avec dbconfig-common
#### supprimer la base de données pour tango-db
sudo apt purge --assume-yes tango-common tango-starter tango-test python-pytango libtango-doc libtango-dev liblog4j1.2-java
### Oracle 8
echo PURGE | sudo debconf-communicate oracle-java8-set-default
sudo apt purge --assume-yes oracle-java8-installer oracle-java8-set-default #libxrender1 libxtst6
## Removing of TANGODB installation packages
sudo apt purge --assume-yes tango-db
## Removing DATABASE installation packages
#echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | sudo debconf-set-selections
echo PURGE | sudo debconf-communicate phpmyadmin
sudo service mysql stop
sudo apt purge --assume-yes phpmyadmin
echo PURGE | sudo debconf-communicate mariadb-client
echo PURGE | sudo debconf-communicate mariadb-server
sudo apt purge --assume-yes mariadb-client mariadb-server expect
sudo apt purge --assume-yes "mysql*"
sudo rm -rf /etc/mysql/ y
sudo service mysql stop
sudo apt-get remove --assume-yes --purge "mysql*"
sudo rm -rf /etc/mysql/
sudo rm -f /etc/bash.bashrc
## Removing VIRTUALBOX installation packages
sudo apt purge --assume-yes modules-assistant build-essential
sudo updatedb
locate mysql
## Removing common tools for all installations
sudo apt purge --assume-yes host mercurial python-pip
## Removing installation tools ###
sudo apt purge --assume-yes debconf dirmngr
#sudo apt-get update
#sudo apt-get clean
sudo apt-get autoremove --assume-yes
#sudo apt-get upgrade --assume-yes
#sudo apt-get update
This diff is collapsed.
#############################################################
### Colors
BLACK="\E[30;47m"
RED="\E[31;40m"
GREEN="\E[32;40m"
YELLOW="\E[33;40m"
BLUE="\E[34;40m"
MAGENTA="\E[35;40m"
CYAN="\E[36;40m"
WHITE="\E[37;40m"
END_FORMATING="\033[0m"
BOLD="\033[1m"
UNDERLINE="\033[4m"
### Printing functions
## error
## Prints a error message and exit from the script with given error code.
##
## parameters :
## msg : message printed in ${RED}
## code : error code
function error
{
if [ "$#" -eq "2" ]
then
echo -e "${BOLD}${RED}Error: $1!${END_FORMATING}"
exit "$2"
else
echo -e "${BOLD}${RED}Error : incorrect number of parameters $# for function 'error'!${END_FORMATING}"
exit ${E_PARAM_ERROR}
fi
}
## alerte
## Prints a warning message.
##
## paramètres :
## msg : message printed in ${YELLOW}
function warning
{
if [ "$#" -eq "1" ]
then
echo -e "${BOLD}${YELLOW}Warning : $1.${END_FORMATING}"
else
error "Incorrect number of parameters $# for function 'warning'" ${E_PARAM_WARNING}
fi
}
## info
## Prints an information message.
##
## parameters :
## msg : message printed in ${GREEN}
function info
{
if [ "$#" -eq "1" ]
then
echo -e "${BOLD}${GREEN}Information : $1.${END_FORMATING}"
else
error "Incorrect number of parameters $# for function 'info'" ${E_PARAM_INFO}
fi
}
### EXECUTION ###
##
## This script must be launched with sudo (or type password when asked)
## Stop this script at first error
set -e
#!/bin/bash
## ATTENTION : ce script n'est pas une garantie absolue que la configuration est correcte
## mais juste une méthode rapide de vérifier que des éléments sont mal configurés
## ThomX environment verification script for computers managed by control-command team
## Script de vérification d'environnement ThomX pour les machines gérées par le CC
## BEWARE : this script does not assure that configuration is correct,
## it is just a fast method to check if elements are bad configured
## continue when an error is encountered
set +e
## Set to 1 to print every message
DEBUG=1
## initialisation des variables globales
TANGO_HOST_CORRECT="srv-2.thomx.fr:20000"
ERREUR=0
REPO_DIR=$(pwd)/$(dirname "$0")
## 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"
echo "DOWNLOAD_ONLY=$DOWNLOAD_ONLY"
echo "DEPENDENCIES=$DEPENDENCIES"
echo "DATABASE=$DATABASE"
echo "TANGO=$TANGO"
echo "TANGO_DB=$TANGO_DB"
echo "ARCHIVING=$ARCHIVING"
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
## 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
CORRECT_TANGO_HOST="srv2.thomx.fr:20000"
ERROR=0
typeset -a PAQUETS_PIP PAQUETS_VERSION
# paquets pip
PAQUETS_PIP=(
## pip packages
PIP_PACKAGES_NUMBER=4
## test
#PIP_PACKAGES_NUMBER=5
PIP_PACKAGES=(
[0]="fandango"
[1]="taurus"
[2]="PyYAML"
[3]="QtPy"
## test
# [3]="test_pip"
)
# versions des paquets pip
PAQUETS_VERSION=(
## pip packages version
PIP_PACKAGES_VERSION=(
[0]="13.9.0"
[1]="4.4.0"
[2]="3.13"
[3]="1.2.1"
## test
# [3]="1.2.2test"
)
PAQUETS_DEBIAN="python-qt4 python-qwt5-qt4 python-qtpy qt4-designer pyqt4-dev-tools"
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"
# java : java -showversion ne doit pas contenir openjdk
if [[ $(java -version 2>&1) == *"OpenJDK"* ]]
### INSTALLATION TEST
## DATABASE
if [[ "${DATABASE}" -eq 1 ]]
then
OUTPUT_DBSERVER=$(dpkg -s mariadb-server | grep Status)
if [[ "${OUTPUT_DBSERVER}" == "Status: install ok installed" ]]
then
if [[ "${DEBUG}" -eq 1 ]]
then
info "DB server installed"
fi
DBSERVER_INSTALLED=1
else
warning "DB server not installed!"
DBSERVER_INSTALLED=0
fi
OUTPUT_DBCLIENT=$(dpkg -s mariadb-client | grep Status)
if [ "${OUTPUT_DBCLIENT}" == "Status: install ok installed" ]
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 ]]
then
echo "ERREUR : Java est installé en OpenJDK au lieu de la version Sun"
ERREUR=1
### 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
fi
#python : python -V >= 2.7 mais < 3
if [[ ! $(python -V 2>&1) == "Python 2.7"* ]]
### TANGO_HOST
source /etc/tangorc
if [[ "${TANGO_HOST}" == "${CORRECT_TANGO_HOST}" ]]
then
echo "ERREUR : Python n'est pas en version 2.7"
ERREUR=2
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
#TANGO_HOST
if [[ "${TANGO_HOST}" != "${TANGO_HOST_CORRECT}" ]]
### Environment settings
## python : python -V >= 2.7 and < 3
if [[ ! $(python -V 2>&1) == "Python 2.7"* ]]
then
echo "ERREUR : TANGO_HOST n'est pas défini à '${TANGO_HOST_CORRECT}' mais à '${TANGO_HOST}'"
ERREUR=3
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
# vérification d'installation des paquets nécessaires à 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<=3; package++))
## 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_COMMANDE=$(pip show ${PAQUETS_PIP[$package]})
RETOUR_PIP=$?
if [[ "${RETOUR_PIP}" -ne 0 ]]
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
echo "ERREUR : ${PAQUETS_PIP[$package]} n'est pas installé"
warning "pip package ${PIP_PACKAGES[$package]} is not installed"
else
echo "${PIP_COMMANDE}" | grep "${PAQUETS_VERSION[$package]}" > /dev/null
RETOUR_COMMANDE_VERSION=$?
if [[ "${RETOUR_COMMANDE_VERSION}" -ne 0 ]]
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
echo "ERREUR : ${PAQUETS_PIP[$package]} n'est pas installé dans la version ${PAQUETS_VERSION[$package]}"
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
for package in ${PAQUETS_DEBIAN}
## Checking debian packages installation
for package in ${DEBIAN_PACKAGES}
do
dpkg -l | grep ^ii | grep "${package} " > /dev/null
DEBIAN_PACKAGE_NOT_INSTALLED=1
$(dpkg -l | grep ^ii | grep "${package} " > /dev/null) && DEBIAN_PACKAGE_NOT_INSTALLED=0
if [[ "$?" -ne 0 ]]
then
echo "ERREUR : ${package} n'est pas installé"
warning "debian package ${package} is not installed"
else
if [[ "${DEBUG}" -eq 1 ]]
then
info "debian package ${package} is installed"
fi
fi
done
#matlab : Hayg indique quelle commande peut être utilisée et quelle est le résultat attendu
## 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
## tango-binding : Hayg will tell what command can be use and what result should be returned
#tango-binding : Hayg indique quelle commande peut être utilisée et quelle est le résultat attendu
## TANGO_HOST_PROD or TANGO_HOST_DEV : Hayg will tell what command
## can be use and what result should be returned
#TANGO_HOST_PROD ou TANGO_HOST_DEV : Hayg indique quelle commande peut être utilisée et quelle est le résultat attendu