#!/bin/bash ## SYNTAX ### ## ## Lignes of this script can be 3 types : ## - beginning with "###" when line is doc title ## - beginning with "##" when line is documentation ## - beginning with "#" when line is a commented line for testing ## - beginning without any "#" when line is interpreted ### Installation of a TANGO server ## Based on a Debian 9 ## script installation duration : ~ 9 to 15 minutes depending on the options ### Instructions to launch the script: ## ## 1 install OS, with an existing ${ARCHIVING_DIR} directory for archiving ## installation, and on a distinct partition to avoid disk crashing ## if temporary files are not deleted ## 2 check that /etc/sudoers contains the main user, if not: ## "su" ## "apt install sudo" ## "usermod -aG sudo [MAINUSER]" ## then completely close session and open it again ## 3 for installing on virtual machine: check that ## /etc/apt/sources.list contains contrib ## check that cdrom is removed/commented from this file if necessary ## 4 get the script ("sudo apt install git" & ## "git clone https://gitlab.in2p3.fr/CCThomX/installation.git") ## 5 check if setxkbmap is well configured if necessary ## 6 configure the INSTALLATION PARAMETERS in the script including ## ARCHIVING_DIR ## 7 launch the script with TANGOSERVER name as parameter ## ("cd installation ; sudo script-install.sh [TANGOSERVER]") ## 8 on distant host, install xauth package (sudo apt install xauth) ## 9 test: ## * DOWNLOAD_ONLY: launching the script with the same configuration ## should work offline ## * VIRTUALBOX: increasing the size of virtualbox window should ## increase the size of virtual screen ## * DATABASE: connection to MariaDB (Debian 9) or MySQL (Debian 8) ## should work : this is automatically checked at the end of installation. ## `mysql -h localhost -u tango -p` followed by `USE tango` and then `SHOW tables;` ## should print following tables: ## +--------------------------------+ ## | 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.00 sec)` ## ## * TANGO_DB: ## + in a terminal different from the one used to execute ## `./script-install.sh`, `echo ${TANGO_HOST}` should return the ## hostname of the TANGO server (not a Fully Qualified Domaine Name) ## + launch `jive` should launch a window like ## https://tango-controls.readthedocs.io/en/latest/tools-and-extensions/jive/index.html ## + launch `atkpanel sys/database/2` should display a java window ## with a green status ## + TANGO tests should be completed after those tests ## * TANGO: ## + yat & yat4tango installation : check presence of /usr/include/yat & ## /usr/include/yat4tango directories and libraries /usr/lib/libyat.so & ## /usr/lib/libyat4tango.so : this is automatically checked at the end of ## installation ## + `java -version` should not return openjdk ## + test GUI: ## - get IHM repo : `hg clone https://gitlab.in2p3.fr/CCThomX/IHM.git` ## - launch `jive`, and check that into Server panel, ## TangoTest/test/TangoTest the `sys/tg_test/1` object contains ## `Exported: true` with an accessible `port` ## - if former step is not checked, launch on the server TangoTest ## device server with `/usr/lib/tango/TangoTest test` and check that ## terminal displays `Ready to accept request` ## - ` cd IHM/RFCanon and launch `./RF_Canon.py`, a window should appear ## while data changes every second ## + configure SSH with a private key giving access to DS-LAL repo and get ## the repo `hg clone git@gitlab.in2p3.fr:CCThomX/DS-LAL.git` ## Then build a DS. ## * ARCHIVING: to complete by JCM ## ## If any issue occurs, you can check installation parameters are well ## spelled with command debconf-get-selections from package debconf-utils. ### INSTALLATION PARAMETERS ## 1 if to install, 0 otherwise ## Downloading packages only DOWNLOAD_ONLY=0 ## Checking and activating dependencies DEPENDENCIES=1 ## VirtualBox VIRTUALBOX=0 ## Database server and PHPMyAdmin DATABASE=0 ## TANGO base tools TANGO=0 ## TANGO DB (depends on TANGO and DATABASE) TANGO_DB=0 ## Archiving (depends on DATABASE) ARCHIVING=0 ## Directory where to install ARCHIVING_DIR="/var/archivage" ############################################################# ## Errors 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 ## Default variables DEFAULTTANGOSERVER=${HOSTNAME} ## 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" ## Initialise text attributes to standard without flushing the screen alias init="tput sgr0" ## Other variables UID_ROOT=0 REPO_DIR=${PWD} HOME_DIR="/home/${SUDO_USER}" 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)" ############################################################# ### 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 ############################################################# ### Checking parameters ## To launch as root of course if [ "${EUID}" -ne "${UID_ROOT}" ] then error "You must be root to launch this script" ${E_NONROOT} fi ## To launch with 1 parameter maximum if [ "$#" -gt "1" ] then error "To much parameters.\n\nUsage: $(basename "$0") [TANGOSERVER_name]" ${E_INCORRECT_ARGS} fi ## Debian version if [ "$(/usr/bin/lsb_release -is)" == "Debian" ] then DEBIAN_VERSION=$(/usr/bin/lsb_release -cs) case ${DEBIAN_VERSION} in stretch*) DEBIAN_VERSION=9;; jessie*) DEBIAN_VERSION=8;; *) error "Operating System is not a Debian 8/9!" ${E_INCORRECT_SYSTEM};; esac echo "Debian version : ${DEBIAN_VERSION}" else error "Operating System is not a Debian 8/9!" ${E_INCORRECT_SYSTEM} fi ## Definition of the hostname (also used as user's group name) SERVERNAME=${HOSTNAME} info "server will be installed with name '${SERVERNAME}'" ## Definition of user's group SUDO_GROUP=$(id -g -n "${SUDO_USER}") ## Definition of TANGOSERVER name: ## - "${HOSTNAME}" as default ## - from given parameter TANGOSERVER=${1-${DEFAULTTANGOSERVER}} if [ "${TANGOSERVER}" != "${SERVERNAME}" ] && [ "${TANGO_DB}" -eq "1" ] then error "installation of TANGO_DB is asked but TANGOSERVER (='${TANGOSERVER}') has another name than SERVERNAME (='${SERVERNAME}')" ${E_INCORRECT_TANGOSERVER} fi info "server will be installed with TANGOSERVER '${TANGOSERVER}'" ### Checking and correcting of initial configuration ## ${SERVERNAME} == ${TANGOSERVER} -> TANGO-DB=1 if [ "${DEPENDENCIES}" == "1" ] \ && [ "${SERVERNAME}" == "${TANGOSERVER}" ] \ && [ "${TANGO_DB}" -eq "0" ] then warning "${SERVERNAME} == ${TANGOSERVER}, TANGO_DB will be installed." TANGO_DB=1 fi ## ARCHIVING=1 -> DATABASE=1 if [ "${DEPENDENCIES}" == "1" ] && [ "${DATABASE}" -eq "0" ] && [ "${ARCHIVING}" -eq "1" ] then warning "installation of ARCHIVING asked, DATABASE will be installed." 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 installed." TANGO=1 DATABASE=1 fi ## Prints final corrected configuration echo "" echo "Final configuration to install: " if [ "${VIRTUALBOX}" -eq "1" ] then echo "VIRTUALBOX" fi if [ "${DATABASE}" -eq "1" ] then echo "Database server and PHPMyAdmin" fi if [ "${TANGO}" -eq "1" ] then echo "TANGO base tools" fi if [ "${TANGO_DB}" -eq "1" ] then echo "TANGO DB" fi if [ "${ARCHIVING}" -eq "1" ] then echo "ArchivingRoot" fi if [ "${DOWNLOAD_ONLY}" -eq "1" ] then warning "installation will only download software and will not install anything" else ## Exit if user does not confirm configuration read -p "Do you want to install this configuration? ([Yy]Nn) " CHOICE case "${CHOICE}" in y|Y ) info "Begining installation...";; n|N ) info "Abort installation"; exit ${E_ABORT_SCRIPT};; * ) info "Abort installation (invalid answer)"; exit ${E_ABORT_SCRIPT};; esac if [ "${DATABASE}" -eq "1" ] || [ "${TANGO_DB}" -eq "1" ] || [ "${ARCHIVING}" -eq "1" ] then ## Get Database root password echo "Please enter root password for DATABASE: " read -s DB_ROOT_PASSWORD echo "Please confirm root password for DATABASE: " read -s DB_ROOT_PASSWORD2 while test "${DB_ROOT_PASSWORD}" != "${DB_ROOT_PASSWORD2}" do warning "Passwords are not equals." echo "Please enter root password for DATABASE: " read -s DB_ROOT_PASSWORD echo "Please confirm root password for DATABASE: " read -s DB_ROOT_PASSWORD2 done echo echo "Please enter tango password for DATABASE: " read -s DB_TANGO_PASSWORD echo "Please confirm tango password for DATABASE: " read -s DB_TANGO_PASSWORD2 while test "${DB_TANGO_PASSWORD}" != "${DB_TANGO_PASSWORD2}" do warning "Passwords are not equals." echo "Please enter tango password for DATABASE: " read -s DB_TANGO_PASSWORD echo "Please confirm tango password for DATABASE: " read -s DB_TANGO_PASSWORD2 done MYSQL_USER=tango MYSQL_PASSWORD=${DB_TANGO_PASSWORD} fi fi ## configuration AZERTY (equivalent of ## "dpkg-reconfigure keyboard-configuration", but in non-interactive mode) ## for PC-tower keyboard #sudo setxkbmap -model pc105 -layout fr -variant latin9 ## for flat USB Mac #setxkbmap -model macintosh -layout fr ## for DELL latitude laptop #sudo setxkbmap -model latitude -layout us ### Preparation of installation tools ### ## temporarly unactivate of listchanges APT_LISTCHANGES_FRONTEND=none ## update of packages before installation sudo apt update ## to install packages in non-interactive mode DEBIAN_FRONTEND=noninteractive sudo apt install --assume-yes debconf ## to install keys for additionnal packages repository sudo apt install --assume-yes dirmngr # creating temporary directory for installation mkdir -p "${REPO_DIR}/tmp" ############################################################# ### Downloading packages ## Common tools for all installations # host, to find offline IP hosts sudo apt install -d host # git mercurial sudo apt install --assume-yes git mercurial # pip sudo apt install --assume-yes python-pip if [ "${VIRTUALBOX}" -eq "1" ] then echo info "downloading software for VIRTUALBOX" sudo apt install -d modules-assistant build-essential fi if [ "${DATABASE}" -eq "1" ] then echo info "downloading software for Database server and PHPMyAdmin" ## Debian 9+/MariaDB sudo apt install -d --assume-yes mariadb-client mariadb-server phpmyadmin expect fi if [ "${TANGO_DB}" -eq "1" ] then echo info "downloading software for TANGO DB" sudo apt install -d --assume-yes tango-db fi if [ "${ARCHIVING}" -eq "1" ] then echo info "downloading software for ArchivingRoot" sudo apt install -d --assume-yes unzip if [ ! -f "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ] then wget -c "https://owncloud.lal.in2p3.fr/public.php?service=files&t=47ceb87fca676922732a3f5d34d4306d&download" -P "${REPO_DIR}/tmp" -O ArchivingRoot-last.zip fi fi if [ "${TANGO}" -eq "1" ] then echo info "downloading software for TANGO base tools" ## Install Oracle Java 8 if ! [ -f /etc/apt/sources.list.d/webupd8team-java.list ] \ || [[ "$(grep -q 'deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main' /etc/apt/sources.list.d/webupd8team-java.list)" -eq "1" ]] \ || [[ "$(grep -q 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main' /etc/apt/sources.list.d/webupd8team-java.list)" -eq "1" ]] then echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 sudo apt update fi ## Accept automatically Oracle license echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections sudo apt install --assume-yes --allow-downgrades --allow-change-held-packages oracle-java8-installer sudo apt install --assume-yes oracle-java8-set-default ## needed to replace OpenJDK by Oracle Java sudo apt install -d --assume-yes libxrender1 libxtst6 ## TANGO packages sudo apt install -d --assume-yes tango-common tango-starter tango-test python-pytango libtango-doc libtango-dev liblog4j1.2-java LIBTANGO_JAVA=libtango-java_9.2.5a-1_all.deb ## Development packages sudo apt install -d --assume-yes python-dev sudo apt install -d --assume-yes gcc g++ make xemacs21 man ## GUI packages sudo apt install -d --assume-yes python-pytango python-qtpy python-qwt5-qt4 python-guiqwt python-pymca5 python-ply spyder python-lxml sudo apt install -d --assume-yes python-qt4 qt4-designer pyqt4-dev-tools ## GUI pip packages if [ ! -d "${REPO_DIR}/tmp" ] then mkdir "${REPO_DIR}/tmp" fi if [ "${DOWNLOAD_ONLY}" -eq "1" ] then ## If Download mode, internet connection is mandatory PIP_OPTION="" else ## Else, pip download can fail PIP_OPTION=" --exists-action i" fi if [ ! -f "${REPO_DIR}/tmp/fandango-13.9.0.tar.gz" ] then pip ${PIP_OPTION} download -d ${REPO_DIR}/tmp fandango==13.9.0 fi if [ ! -f "${REPO_DIR}/tmp/taurus-4.4.0-py2-none-any.whl" ] then pip ${PIP_OPTION} download -d ${REPO_DIR}/tmp taurus==4.4.0 fi if [ ! -f "${REPO_DIR}/tmp/PyYAML-3.13.tar.gz" ] then pip ${PIP_OPTION} download -d ${REPO_DIR}/tmp PyYAML==3.13 fi if [ ! -f "${REPO_DIR}/tmp/QtPy-1.2.1-py2.py3-none-any.whl" ] then pip ${PIP_OPTION} download -d ${REPO_DIR}/tmp QtPy==1.2.1 fi ## Hggit configuration if [ -z `find "${REPO_DIR}/tmp/" -maxdepth 1 -type f -name "dulwich-*.tar.gz" -printf 1 -quit` ] then pip ${PIP_OPTION} download -d ${REPO_DIR}/tmp "dulwich>=0.19.0" fi mkdir -p "${REPO_DIR}/tmp/hgext" if [ ! -d "${REPO_DIR}/tmp/hgext/hg-git" ] then hg clone https://bitbucket.org/durin42/hg-git "${REPO_DIR}/tmp/hgext/hg-git" fi ## yat & yat4tango libraries sudo apt install --assume-yes subversion sudo apt install --assume-yes -d pkg-config cmake if [ ! -d "${REPO_DIR}/tmp/YAT-1.14.5" ] then svn checkout https://svn.code.sf.net/p/tango-cs/code/share/yat/tags/YAT-1.14.5 "${REPO_DIR}/tmp/YAT-1.14.5" fi if [ ! -d "${REPO_DIR}/tmp/YAT4Tango-1.11.4" ] then svn checkout https://svn.code.sf.net/p/tango-cs/code/share/yat4tango/tags/YAT4Tango-1.11.4 "${REPO_DIR}/tmp/YAT4Tango-1.11.4" fi if [ ! -e "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" ] then wget -c "https://people.debian.org/~picca/${LIBTANGO_JAVA}" -P "${REPO_DIR}/tmp" fi fi echo echo info "downloading software for offline installation finished with success" echo "===================================================================" echo echo if [ "${DOWNLOAD_ONLY}" -eq "1" ] then exit 0 fi ############################################################# ## Common tools for all installations # host, to find sudo apt install --assume-yes host ### Specific installation for virtual machines (big screen and copy/paste) if [ "${VIRTUALBOX}" -eq "1" ] then echo info "installation of VIRTUALBOX options" ## Disable screensaver which can block VIRTUALBOX sudo apt remove --assume-yes light-locker ## Installation of VirtualBox addons for bigger resolutions sudo apt install modules-assistant build-essential sudo m-a prepare sudo sh /media/cdrom/VBoxLinuxAdditions.run fi ### Installation of DATABASE DB server ### if [ "${DATABASE}" -eq "1" ] then echo info "installation of Database" ## check if Database is already installed DATABASE_INSTALLED=0 dpkg -l mysql-server &> /dev/null && DATABASE_INSTALLED=1 if [ "${DATABASE_INSTALLED}" -eq "1" ] then info "Database already installed." else ## configuration of Database server ## Debian 9+/MariaDB echo "mariadb-server mysql-server/root_password password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections echo "mariadb-server mysql-server/root_password_again password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections sudo apt install --assume-yes mariadb-client mariadb-server ## package expect is used to answer non-interactively to questions asked ## by mysql_secure_installation sudo apt install --assume-yes expect ## questions and answers for mysql_secure_installation SECURE_MYSQL=$(expect -c " set timeout 10 spawn mysql_secure_installation expect \"Enter current password for root (enter for none):\" send \"${DB_ROOT_PASSWORD}\r\" expect \"Change the root password?\" send \"n\r\" expect \"Remove anonymous users?\" send \"y\r\" expect \"Disallow root login remotely?\" send \"y\r\" expect \"Remove test database and access to it?\" send \"y\r\" expect \"Reload privilege tables now?\" send \"y\r\" expect eof ") echo "${SECURE_MYSQL}" sudo apt purge --assume-yes expect fi ### Installation of PHPMyAdmin ## configuration of PHPMyAdmin echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | sudo debconf-set-selections echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | sudo debconf-set-selections ## Access to PHPMyAdmin for user tango echo "phpmyadmin phpmyadmin/mysql/app-pass password ${DB_TANGO_PASSWORD}" | sudo debconf-set-selections ## installation of PHPMyAdmin server sudo apt install --assume-yes --quiet phpmyadmin ## creation of shortcut ## if file exists if [ -e /var/www/phpmyadmin ] then error "file '/var/www/phpmyadmin' already exists!" ${E_ALREADY_INSTALLED} fi sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin fi ## configuration of network names if no DNS #sudo sh -c "echo "192.168.1.101 ${TANGOSERVER}" >> /etc/hosts" #sudo sh -c 'echo "192.168.1.110 ${SERVERNAME}" >> /etc/hosts' ### installation of TANGO DB for TANGO server if [ "${TANGO_DB}" -eq "1" ] then echo info "installation of TANGO_DB" #tango-db depends on tango-common echo "tango-common tango-common/tango-host string ${TANGOSERVER}:20000" | sudo debconf-set-selections echo 'tango-db tango-db/dbconfig-install boolean true' | sudo debconf-set-selections echo "tango-db tango-db/mysql/admin-pass string ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections echo "tango-db tango-db/mysql/app-pass password ${DB_TANGO_PASSWORD}" | sudo debconf-set-selections sudo apt install --assume-yes tango-db fi ### Installation of TANGO base tools if [ "${TANGO}" -eq "1" ] then echo info "installation of TANGO base tools" ### Installation of Java sudo apt install --assume-yes oracle-java8-installer oracle-java8-set-default ## needed to replace OpenJDK by Oracle Java sudo apt install --assume-yes libxrender1 libxtst6 ### configuration of TANGO ## configuration tango-common echo "tango-common tango-common/tango-host string ${TANGOSERVER}:20000" | sudo debconf-set-selections ## configuration into /etc/tangorc sudo sh -c 'echo "source /etc/tangorc" >> /etc/bash.bashrc' sudo sh -c 'echo "export TANGO_HOST" >> /etc/bash.bashrc' ## installation of TANGO info "installation TANGO Debian 9+" ## TANGO packages sudo apt --assume-yes install tango-common tango-starter tango-test python-pytango libtango-doc libtango-dev liblog4j1.2-java LIBTANGO_JAVA=libtango-java_9.2.5a-1_all.deb ## Development packages sudo apt --assume-yes install python-pip sudo apt --assume-yes install gcc g++ make xemacs21 man ## GUI packages sudo apt --assume-yes install python-pytango python-qtpy python-qwt5-qt4 python-guiqwt python-pymca5 python-ply spyder python-lxml sudo apt --assume-yes install python-qt4 qt4-designer pyqt4-dev-tools ## GUI pip packages pip install --no-index --find-links="${REPO_DIR}/tmp" fandango==13.9.0 taurus==4.4.0 PyYAML==3.13 QtPy==1.2.1 ## Hggit configuration pip install --no-index --find-links="${REPO_DIR}/tmp" "dulwich>=0.19.0" if [ ! -d "${REPO_DIR}/tmp/hgext" ] then mkdir -p "${REPO_DIR}/tmp/hgext" fi if [ ! -d "${REPO_DIR}/tmp/hgext/hg-git" ] then hg clone https://bitbucket.org/durin42/hg-git "${REPO_DIR}tmp/hgext/hg-git" fi cd "${REPO_DIR}/tmp/hgext/hg-git" sudo python setup.py install cd "${REPO_DIR}" sudo sh -c 'echo "[extensions]" >> /etc/mercurial/hgrc' sudo sh -c 'echo "# Hg-Git plugin for Mercurial" >> /etc/mercurial/hgrc' sudo sh -c 'echo "hgext.bookmarks =" >> /etc/mercurial/hgrc' sudo sh -c 'echo "hggit =" >> /etc/mercurial/hgrc' ## yat & yat4tango libraries sudo apt install --assume-yes subversion sudo apt install --assume-yes pkg-config cmake if [ ! -d "${REPO_DIR}/tmp/YAT-1.14.5" ] then svn checkout https://svn.code.sf.net/p/tango-cs/code/share/yat/tags/YAT-1.14.5 tmp/YAT-1.14.5 fi if [ ! -d "${REPO_DIR}/tmp/YAT4Tango-1.11.4" ] then svn checkout https://svn.code.sf.net/p/tango-cs/code/share/yat4tango/tags/YAT4Tango-1.11.4 tmp/YAT4Tango-1.11.4 fi export PKG_CONFIG_PATH=/usr/lib/pkgconfig cd "${REPO_DIR}/tmp/YAT-1.14.5" cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr make sudo make install cd "${REPO_DIR}/tmp/YAT4Tango-1.11.4" cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr make sudo make install cd "${REPO_DIR}" if ! ( sudo apt install -f libtango-java ) then sudo dpkg -i "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" fi fi ### installation of ArchivingRoot ### if [ "${ARCHIVING}" -eq "1" ] then echo info "installation of ARCHIVING" sudo mkdir -p /opt/ArchivingRoot cd /opt/ArchivingRoot if [ -f "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ] then cp "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ./ else wget -c "https://owncloud.lal.in2p3.fr/public.php?service=files&t=47ceb87fca676922732a3f5d34d4306d&download" -P "${REPO_DIR}/tmp" -O ArchivingRoot-last.zip fi sudo apt install unzip sudo unzip -o ArchivingRoot-last.zip sudo rm ArchivingRoot-last.zip cd "${REPO_DIR}" ## configuration into /etc/tangorc sudo sh -c 'echo "ARCHIVING_ROOT=/opt/ArchivingRoot" >> /etc/tangorc' sudo sh -c 'echo "export ARCHIVING_ROOT" >> /etc/bash.bashrc' ## configuration of ArchivingRoot ## creates TDB and HDB databases into Database mysql -h localhost -u root -p"${DB_ROOT_PASSWORD}" < /opt/ArchivingRoot/db/create-TDB-MyISAM.sql mysql -h localhost -u root -p"${DB_ROOT_PASSWORD}" < /opt/ArchivingRoot/db/create-HDB-MyISAM.sql mysql -h localhost -u root -p"${DB_ROOT_PASSWORD}" < "${REPO_DIR}/archive1/create-SNAPDB-MyISAM.sql" ## Declaration of Archiving Device Servers into TANGO DB from TANGOSERVER ## if installation of TANGO-DB server and ARCHIVING if [ "${SERVERNAME}" == "${TANGOSERVER}" ] then warning "installation of Archiving Device Servers : non installed" warning "Archiving DS have to be installed locally on server. through '127.0.0.1' host" # mysql -h "${TANGOSERVER}" -u tango -p"${DB_TANGO_PASSWORD}" < "${REPO_DIR}/swthomx2/essai-hdb-device-installation.sql" # mysql -h "${TANGOSERVER}" -u tango -p"${DB_TANGO_PASSWORD}" < "${REPO_DIR}/swthomx2/essai-tdb-device-installation.sql" fi ## Giving execution rights and changing owner of archiving files to user sudo chmod u+x /opt/ArchivingRoot/device/linux/* sudo chown -R "${SUDO_USER}:${SUDO_GROUP}" /opt/ArchivingRoot/* sudo chmod u+x -R /opt/ArchivingRoot/bin/linux/ ## using SHELL bash instead of dash to avoid errors when launching ## /opt/ArchivingRoot/device/linux/HdbArchiver echo 'dash dash/sh boolean false' | sudo debconf-set-selections sudo dpkg-reconfigure -p critical dash ## alias bashrc ## if file already exists if [ -h /etc/bashrc ] then warning "file '/etc/bashrc' already exists!" ${E_ALREADY_INSTALLED} fi sudo ln -s /etc/bash.bashrc /etc/bashrc ## Giving read/write rights and ownership to user for ${ARCHIVING_DIR} if [ ! -d "${ARCHIVING_DIR}" ] then warning "${ARCHIVING_DIR} does not exist, creation of this directory." mkdir "${ARCHIVING_DIR}" fi sudo chown -R "${SUDO_USER}:${SUDO_GROUP}" "${ARCHIVING_DIR}" sudo chmod u+x -R "${ARCHIVING_DIR}" ## if directory already exists if [ -d "${ARCHIVING_DIR}/tdb" ] then error "file \'${ARCHIVING_DIR}/tdb\' already exists!" ${E_ALREADY_INSTALLED} fi if [ -d "$ARCHIVING_DIR/hdb" ] then error "file '${ARCHIVING_DIR}/hdb' already exists!" ${E_ALREADY_INSTALLED} fi sudo mkdir "${ARCHIVING_DIR}/tdb" "${ARCHIVING_DIR}/hdb" sudo chmod ugo+rw "${ARCHIVING_DIR}/tdb" "${ARCHIVING_DIR}/hdb" ## Update of /etc/mysql/my.cnf to allow external connections: ## comment bind-address and skip-networking into my.cnf file ## bind-address force DB server to listen only several hosts sed -i -e "s/\(^bind-address[ ]*=.*$\)/#\1/g" /etc/mysql/my.cnf ## skip-networking force DB Server to not listen TCP/IP connections sudo service mysql restart ## cleaning temporary archive files ## giving the rights to use crontab sudo sh -c 'echo '"${SUDO_USER}"' >> /etc/cron.allow' ## enter cleaning into crontab echo "0 2 * * * ${REPO_DIR}/archive1/delete_unmodified_since.sh > ${ARCHIVING_DIR}/hdbtdb_delete_data_and_diary_files.log" | sudo tee --append "/var/spool/cron/crontabs/${USERNAME}" ## starting activating cleaning now sudo service cron restart fi ## Reactivating apt-listchanges APT_LISTCHANGES_FRONTEND=pager ## Cleaning unused packages sudo apt autoremove --assume-yes rm -rf "${REPO_DIR}/tmp" source /etc/bash.bashrc source ~/.bashrc echo echo info "installation finished with success" echo "==================================" echo echo ## TODO ## using /var/www/html/img/logo.ico and /var/www/html/img/logo.png ## phpmyadmin password to change manually after installation ## configuring DS with Jive ### INSTALLATION TEST ## DATABASE if [ "${DATABASE}" -eq "1" ] then 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 info "DATABASE successfully installed" else warning "DATABASE installation failed!" fi fi ## TANGO if [ "${TANGO}" -eq "1" ] then ### yat & yat4tango if [ -d /usr/include/yat ] \ && [ -d /usr/include/yat4tango ] \ && [ -e /usr/lib/libyat.so ] \ && [ -e /usr/lib/libyat4tango.so ] then info "yat & yat4tango successfully installed" else warning "yat & yat4tango installation failed!" fi ### Java version #### check if Java is not openjdk if [[ $(java -version 2>&1) != *"OpenJDK"* ]] then info "Sun Java JDK successfully installed" else error "OpenJDK Java has been installed" ${E_INCORRECT_JDK} fi ### TangoTest #### if TangoTest/test is not defined /usr/lib/tango/tango_admin --check-server TangoTest/test TANGOTEST_DS_UNDEFINED=$? if [[ ${TANGOTEST_DS_UNDEFINED} -ne 0 ]] then error "TangoTest Device Server is not defined" ${E_TANGOTEST_DS_UNDEFINED} fi #### if sys/tg_test/1 is not defined /usr/lib/tango/tango_admin --check-device sys/tg_test/1 TANGOTEST_DEVICE_UNDEFINED=$? if [[ "${TANGOTEST_DEVICE_UNDEFINED}" -ne 0 ]] then error "sys/tg_test/1 device is not defined" ${E_TANGOTEST_DEVICE_UNDEFINED} fi #### if TangoTest/test does not respond to ping /usr/lib/tango/tango_admin --ping-device sys/tg_test/1 TANGOTEST_DEVICE_UNREACHABLE=$? if [[ "${TANGOTEST_DEVICE_UNREACHABLE}" -ne 0 ]] then /usr/lib/tango/TangoTest test & sleep 1 /usr/lib/tango/tango_admin --ping-device sys/tg_test/1 TANGOTEST_DEVICE_UNREACHABLE=$? if [[ "${TANGOTEST_DEVICE_UNREACHABLE}" -ne 0 ]] then error "TangoTest/test does not respond to ping" ${E_TANGOTEST_DEVICE_UNREACHABLE} else info "TangoTest/test has been started" fi fi fi ## TANGO_DB if [ "${TANGO_DB}" -eq "1" ] then ### TANGO_HOST source /etc/tangorc if [ "${TANGO_HOST}" == "${TANGOSERVER}:20000" ] then info "TANGO_HOST correctly set to ${TANGO_HOST}" else warning "TANGO_HOST='${TANGO_HOST}' is not set to '${TANGO_HOST}'!" fi fi