#!/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 8 / 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-get 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 ## 4 get the script ("sudo apt-get 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 ThomX-Config ; sudo script-install.sh [TANGOSERVER]") ## 8 on distant host, install xauth package (sudo apt-get 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 ## `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 ## Fully Qualified Domain Name (FQDN) of the computer ## + 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: ## + TANGO_DB tests should be completed ## + test GUI: ## - get IHM repo : `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 `git 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_PARAM_ERROR=11 E_PARAM_WARNING=12 E_PARAM_INFO=13 E_ABORT_SCRIPT=21 E_ALREADY_INSTALLED=31 ## 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}" ############################################################# ### 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 'alerte'" ${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: ## - "tangoserver" 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}" -eq "0" ] && [ "${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 enter tango password for DATABASE: " read -s DB_TANGO_PASSWORD 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-get update ## to install packages in non-interactive mode DEBIAN_FRONTEND=noninteractive sudo apt-get install --assume-yes debconf ## to install keys for additionnal packages repository sudo apt-get install --assume-yes dirmngr ############################################################# ### Downloading packages if [ "${VIRTUALBOX}" -eq "1" ] then info "downloading software for VIRTUALBOX" if [ "${DEBIAN_VERSION}" -gt "8" ] then ## Debian 9+/MariaDB sudo apt-get install -d modules-assistant else ## Debian 8-/MySQL sudo apt-get install -d --assume-yes debconf xserver-xorg-core virtualbox-guest-x11 fi fi if [ "${DATABASE}" -eq "1" ] then info "downloading software for Database server and PHPMyAdmin" if [ "${DEBIAN_VERSION}" -gt "8" ] then ## Debian 9+/MariaDB sudo apt-get install -d --assume-yes mariadb-client mariadb-server phpmyadmin expect else ## Debian 8-/MySQL sudo apt-get install -d --assume-yes --force-yes mysql-client mysql-server phpmyadmin fi fi if [ "${TANGO_DB}" -eq "1" ] then info "downloading software for TANGO DB" sudo apt-get install -d --assume-yes tango-db fi if [ "${ARCHIVING}" -eq "1" ] then info "downloading software for ArchivingRoot" sudo apt-get install -d --assume-yes unzip mkdir -p "${REPO_DIR}/tmp" cd "${REPO_DIR}/tmp" 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 info "downloading software for TANGO base tools" if [ "${DEBIAN_VERSION}" -gt "8" ] then ## Debian 9 ## Install python package manager sudo apt install --assume-yes python-pip ## Install Oracle Java if ! [ -e /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-get update fi ## Accept automatically Oracle license echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections #echo "oracle-java8-installer shared/accepted-oracle-licence-v1-1 boolean true" | sudo debconf-set-selections sudo apt-get install --assume-yes --allow-downgrades --allow-change-held-packages oracle-java8-installer sudo apt-get install -d --assume-yes oracle-java8-set-default ## needed to replace OpenJDK by Oracle Java sudo apt-get install -d --assume-yes libxrender1 libxtst6 ## TANGO packages sudo apt-get install -d --assume-yes 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 gcc g++ make xemacs21 git mercurial man ## GUI packages sudo apt install -d --assume-yes python-dulwich python-dev python-pip python-qt4 python-qwt5-qt4 python-qtpy qt4-designer pyqt4-dev-tools ## GUI pip packages if [ ! -d "${REPO_DIR}/pip-tmp" ] then mkdir "${REPO_DIR}/pip-tmp" fi pip download -d "${REPO_DIR}/pip-tmp" fandango==13.9.0 taurus==4.4.0 PyYAML==3.13 QtPy==1.2.1 else ## Debian 8 if ! [ -e /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-get update fi ## Accept automatically Oracle license echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections #echo "oracle-java8-installer shared/accepted-oracle-licence-v1-1 boolean true" | sudo debconf-set-selections sudo apt-get install --assume-yes --force-yes oracle-java8-installer sudo apt-get install -d --assume-yes --force-yes oracle-java8-set-default ## needed to replace OpenJDK by Oracle Java sudo apt-get install -d --assume-yes libxrender1 libxtst6 ## TANGO packages sudo apt-get install -d --assume-yes --force-yes tango-common tango-starter tango-test python-pytango libtango8-doc libtango8-dev liblog4j1.2-java LIBTANGO_JAVA=libtango-java_8.1.2.c-1_all.deb fi if ! ( sudo apt-get install -f libtango-java ) then if [ ! -f "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" ] then wget -c "https://people.debian.org/~picca/${LIBTANGO_JAVA}" -P "${REPO_DIR}/tmp" fi fi fi info "downloading software for offline installation finished with success" if [ "${DOWNLOAD_ONLY}" -eq "1" ] then exit 0 fi ############################################################# ### Specific installation for virtual machines (big screen and copy/paste) if [ "${VIRTUALBOX}" -eq "1" ] then info "installation of VIRTUALBOX options" ## Disable screensaver which can block VIRTUALBOX sudo apt-get remove --assume-yes light-locker ## Installation of VirtualBox addons for bigger resolutions if [ "${DEBIAN_VERSION}" -gt "8" ] then ## Debian 9+ sudo apt-get install modules-assistant sudo m-a prepare sudo sh /media/cdrom/VBoxLinuxAdditions.run else ## Debian 8- sudo apt-get install --assume-yes xserver-xorg-core sudo apt-get install -f --assume-yes virtualbox-guest-x11 fi fi ### Installation of DATABASE DB server ### if [ "${DATABASE}" -eq "1" ] then 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 if [ "${DEBIAN_VERSION}" -gt "8" ] then ## 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-get install --assume-yes mariadb-client mariadb-server ## package expect is used to answer non-interactively to questions asked ## by mysql_secure_installation sudo apt-get 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-get purge --assume-yes expect else ## Debian 8-/MySQL echo "mysql-server mysql-server/root_password password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections echo "mysql-server mysql-server/root_password_again password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections sudo apt-get install --assume-yes --force-yes mysql-server mysql-client fi fi ### Installation of PHPMyAdmin ## configuration of PHPMyAdmin if [ "${DEBIAN_VERSION}" -gt "8" ] then ## Debian 9+/MariaDB 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 #echo "phpmyadmin phpmyadmin/app-password-confirm password ${DB_TANGO_PASSWORD}" | sudo debconf-set-selections #echo "phpmyadmin phpmyadmin/mysql/admin-pass string ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections ## installation of PHPMyAdmin server sudo apt-get install --assume-yes --quiet phpmyadmin else ## Debian 8-/MySQL echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | sudo debconf-set-selections echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | sudo debconf-set-selections ## root password for Database #echo "phpmyadmin phpmyadmin/setup-password password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections #echo "phpmyadmin phpmyadmin/password-confirm password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections ## password for phpmyadmin application echo "phpmyadmin phpmyadmin/mysql/app-pass password ${DB_TANGO_PASSWORD}" | sudo debconf-set-selections echo "phpmyadmin phpmyadmin/app-password-confirm password ${DB_TANGO_PASSWORD}" | sudo debconf-set-selections ## root password for Database echo "phpmyadmin phpmyadmin/mysql/admin-pass password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections # echo "phpmyadmin phpmyadmin/mysql/app-password-confirm password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections # echo "phpmyadmin phpmyadmin/password-confirm password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections ## installation of PHPMyAdmin server sudo apt-get install --assume-yes --force-yes --quiet phpmyadmin fi ## 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 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 if [ "${DEBIAN_VERSION}" -gt "8" ] then ## Debian 9+/MariaDB 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 else ## Debian 8-/MySQL 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 fi sudo apt-get install --assume-yes tango-db fi ### Installation of TANGO base tools if [ "${TANGO}" -eq "1" ] then info "installation of TANGO base tools" ### Installation of Java sudo apt-get --assume-yes install oracle-java8-installer oracle-java8-set-default ## needed to replace OpenJDK by Oracle Java sudo apt-get 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 if [ "${DEBIAN_VERSION}" -gt "8" ] then ## Debian 9 and + echo "installation TANGO Debian 9+" ## TANGO packages sudo apt-get --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 gcc g++ make xemacs21 git mercurial man ## GUI packages sudo apt --assume-yes install python-dulwich python-dev python-pip python-qt4 python-qwt5-qt4 python-qtpy qt4-designer pyqt4-dev-tools ## GUI pip packages pip install --no-index --find-links="${REPO_DIR}/pip-tmp" fandango==13.9.0 taurus==4.4.0 PyYAML==3.13 QtPy==1.2.1 else # Debian 8 and - echo "installation TANGO Debian 8-" sudo apt-get install --assume-yes --force-yes tango-common tango-starter tango-test python-pytango libtango8-doc libtango8-dev liblog4j1.2-java LIBTANGO_JAVA=libtango-java_8.1.2.c-1_all.deb fi if ! ( sudo apt-get install -f libtango-java ) then if [ ! -f "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" ] then wget -c "https://people.debian.org/~picca/${LIBTANGO_JAVA}" -P "${REPO_DIR}/tmp" fi sudo dpkg -i "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" fi fi ### installation of ArchivingRoot ### if [ "${ARCHIVING}" -eq "1" ] then info "installation of ARCHIVING" sudo mkdir -p /opt/ArchivingRoot cd /opt/ArchivingRoot if [ -e "${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-get 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 [ -e /etc/bashrc ] then error "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 #sed -i -e "/#bind-address[ ]*=[ ]*\*/d" /etc/mysql/my.cnf #echo 'bind-address = *' >> /etc/mysql/my.cnf ## skip-networking force DB Server to not listen TCP/IP connections #sudo sed -i -e "s/skip-networking/#skip-networking/g" /etc/mysql/my.cnf 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-get autoremove --assume-yes rm -rf "${REPO_DIR}/tmp" "${REPO_DIR}/pip-tmp" source /etc/bash.bashrc source ~/.bashrc info "installation finished with success" ## 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