script-install.sh 28.8 KB
Newer Older
1 2
#!/bin/bash

gauron's avatar
gauron committed
3 4 5 6 7 8 9 10 11 12
## 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
13
## Based on a Debian 8 / 9
14
## script installation duration : ~ 9 to 15 minutes depending on the options
15

gauron's avatar
gauron committed
16 17 18

### Instructions to launch the script:
##
19
## 1 install OS, with an existing ${ARCHIVING_DIR} directory for archiving
20 21 22
##   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:
gauron's avatar
gauron committed
23 24
##   "su"
##   "apt-get install sudo"
25
##   "usermod -aG sudo [MAINUSER]"
26 27 28
##   then completely close session and open it again
## 3 for installing on virtual machine: check that 
##   /etc/apt/sources.list contains contrib
29
## 4 get the script ("sudo apt-get install git" &
30
##   "git clone https://gitlab.in2p3.fr/CCThomX/installation.git")
31
## 5 check if setxkbmap is well configured if necessary
32 33 34
## 6 configure the INSTALLATION PARAMETERS in the script including 
##   ARCHIVING_DIR
## 7 launch the script with tangoserver name as parameter
35
##   ("cd ThomX-Config ; sudo script-install.sh [TANGOSERVER]")
36
## 8 on distant host, install xauth package (sudo apt-get install xauth)
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
## 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
104 105 106
##
## If any issue occurs, you can check installation parameters are well 
## spelled with command debconf-get-selections from package debconf-utils.
107 108 109



110 111
### INSTALLATION PARAMETERS
## 1 if to install, 0 otherwise
gauron's avatar
gauron committed
112

113
## Downloading packages only
114
DOWNLOAD_ONLY=0
115 116
## Checking and activating dependencies
DEPENDENCIES=1
117
## VirtualBox
118
VIRTUALBOX=0
119
## Database server and PHPMyAdmin
120
DATABASE=0
121
## TANGO base tools
122
TANGO=0
123
## TANGO DB (depends on TANGO and DATABASE)
124
TANGO_DB=0
125
## Archiving (depends on DATABASE)
126
ARCHIVING=0
127

128 129
## Directory where to install 
ARCHIVING_DIR="/var/archivage"
130

131 132
#############################################################

133 134


135 136
## Errors
E_INCORRECT_ARGS=1
137
E_NONROOT=2
138 139
E_INCORRECT_TANGOSERVER=3
E_INCORRECT_HOSTNAME=4
140
E_INCORRECT_SYSTEM=5
141

142 143
E_PARAM_ERROR=11
E_PARAM_WARNING=12
144 145
E_PARAM_INFO=13

146 147
E_ABORT_SCRIPT=21

148
E_ALREADY_INSTALLED=31
149

150
## Default variables
151
DEFAULTTANGOSERVER=${HOSTNAME}
152

gauron's avatar
gauron committed
153
## Colors
154 155 156 157 158 159 160 161 162 163 164 165
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"

166
##  Initialise text attributes to standard without flushing the screen
167
alias init="tput sgr0"
168

169
## Other variables
170
UID_ROOT=0
171 172
REPO_DIR=${PWD}
HOME_DIR="/home/${SUDO_USER}"
173 174


175 176
#############################################################

177
### Printing functions
178

179 180
## error
## Prints a error message and exit from the script with given error code.
181
##
182
## parameters :
183
##   msg : message printed in ${RED}
184
##   code : error code
185

186
function error
187
{
188
  if [ "$#" -eq "2" ]
189
  then
190
    echo -e "${BOLD}${RED}Error: $1!${END_FORMATING}"
191
    exit "$2"
192
  else
193
    echo -e "${BOLD}${RED}Error : incorrect number of parameters $# for function 'error'!${END_FORMATING}"
194
    exit ${E_PARAM_ERROR}
195 196 197 198
  fi
}


199 200
## alerte
## Prints a warning message.
201 202
##
## paramètres :
203
##   msg : message printed in ${YELLOW}
204

205
function warning
206
{
207
  if [ "$#" -eq "1" ]
208
  then
209
    echo -e "${BOLD}${YELLOW}Warning : $1.${END_FORMATING}"
210
  else
211
    error "Incorrect number of parameters $#  for function 'alerte'" ${E_PARAM_WARNING}
212 213 214
  fi
}

215 216
## info
## Prints an information message.
217
##
218
## parameters :
219
##   msg : message printed in ${GREEN}
220 221 222

function info
{
223
  if [ "$#" -eq "1" ]
224
  then
225
    echo -e "${BOLD}${GREEN}Information : $1.${END_FORMATING}"
226
  else
227
    error "Incorrect number of parameters $# for function 'info'" ${E_PARAM_INFO}
228 229 230 231
  fi
}


232
### EXECUTION ###
233
## 
234
## This script must be launched with sudo (or type password when asked)
235

236
## Stop this script at first error
237 238 239
set -e


240
#############################################################
241 242


243
### Checking parameters
244

245
## To launch as root of course
246
if [ "${EUID}" -ne "${UID_ROOT}" ]
247
then
248
  error "You must be root to launch this script" ${E_NONROOT}
249 250
fi  

251
## To launch with 1 parameter maximum
252
if [ "$#" -gt "1" ]
253
then
254
  error "To much parameters.\n\nUsage: $(basename "$0") [TANGOSERVER_name]" ${E_INCORRECT_ARGS}
255 256 257
fi


258
## Debian version
259
if [ "$(/usr/bin/lsb_release -is)" == "Debian" ]
260 261 262 263 264 265 266 267 268 269 270
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
271

272 273
## Definition of the hostname (also used as user's group name)
SERVERNAME=${HOSTNAME}
274

275
info "server will be installed with name '${SERVERNAME}'"
276

277
## Definition of user's group
278
SUDO_GROUP=$(id -g -n "${SUDO_USER}")
279 280 281 282




283 284 285
## Definition of TANGOSERVER name:
## - "tangoserver" as default
## - from given parameter
286
TANGOSERVER=${1-${DEFAULTTANGOSERVER}}
287 288


289
if [ "${TANGOSERVER}" != "${SERVERNAME}" ] && [ "${TANGO_DB}" -eq "1" ]
290
then
291
  error "installation of TANGO_DB is asked but TANGOSERVER (='${TANGOSERVER}') has another name than SERVERNAME (='${SERVERNAME}')" ${E_INCORRECT_TANGOSERVER}
292 293
fi

294
info "server will be installed with TANGOSERVER '${TANGOSERVER}'"
295 296


297

298 299 300

### Checking and correcting of initial configuration

301 302 303
## ${SERVERNAME} == ${TANGOSERVER} -> TANGO-DB=1
if [ "${DEPENDENCIES}" == "1" ] && [ "${SERVERNAME}" == "${TANGOSERVER}" ] \
   && [ "${TANGO_DB}" -eq "0" ]
304
then
305
  warning "${SERVERNAME} == ${TANGOSERVER}, TANGO_DB will be installed."
306 307 308
  TANGO_DB=1
fi

309
## ARCHIVING=1 -> DATABASE=1
310
if [ "${DEPENDENCIES}" == "1" ] && [ "${DATABASE}" -eq "0" ] && [ "${ARCHIVING}" -eq "1" ]
311
then
312 313
  warning "installation of ARCHIVING asked, DATABASE will be installed."
  DATABASE=1
314 315 316
fi


317
## TANGO_DB=1 -> TANGO=1 & DATABASE=1
318
if [ "${DEPENDENCIES}" == "1" ] && [ "${TANGO}" -eq "0" ] && [ "${TANGO_DB}" -eq "1" ]
319
then
320
  ##warning "installation of TANGO_DB asked, TANGO will be installed."
321
  TANGO=1
322
  DATABASE=1
323 324 325
fi


326
## Prints final corrected configuration
327
echo ""
328
echo "Final configuration  to install: "
329
if [ "${VIRTUALBOX}" -eq "1" ]
330
then
331
  echo "VIRTUALBOX"
332
fi
333
if [ "${DATABASE}" -eq "1" ]
334
then
335
  echo "Database server and PHPMyAdmin"
336
fi
337
if [ "${TANGO}" -eq "1" ]
338 339 340
then
  echo "TANGO base tools"
fi
341
if [ "${TANGO_DB}" -eq "1" ]
342 343 344
then
  echo "TANGO DB"
fi
345
if [ "${ARCHIVING}" -eq "1" ]
346 347 348 349
then
  echo "ArchivingRoot"
fi

350

351 352


353
if [ "${DOWNLOAD_ONLY}" -eq "1" ]
354
then
355 356 357
  warning "installation will only download software and will not install anything"
else
  ## Exit if user does not confirm configuration
358 359
  read -p "Do you want to install this configuration? ([Yy]Nn) " CHOICE
  case "${CHOICE}" in
360
    y|Y ) info "Begining installation...";;
361 362
    n|N ) info "Abort installation"; exit ${E_ABORT_SCRIPT};;
    * ) info "Abort installation (invalid answer)"; exit ${E_ABORT_SCRIPT};;
363 364
  esac

365
  if [ "${DATABASE}" -eq "1" ] || [ "${TANGO_DB}" -eq "1" ] || [ "${ARCHIVING}" -eq "1" ]
366 367 368
  then
    ## Get Database root password
    echo "Please enter root password for DATABASE: "
369
    read -s DB_ROOT_PASSWORD
370 371 372
    echo "Please enter tango password for DATABASE: "
    read -s DB_TANGO_PASSWORD
    MYSQL_USER=tango
373
    MYSQL_PASSWORD=${DB_TANGO_PASSWORD}
374
  fi
375

376
fi
377

378

379
## configuration AZERTY (equivalent of
gauron's avatar
gauron committed
380
## "dpkg-reconfigure keyboard-configuration", but in non-interactive mode)
381
## for PC-tower keyboard
382
#sudo setxkbmap -model pc105 -layout fr -variant latin9
383
## for flat USB Mac
384
#setxkbmap -model macintosh -layout fr
385 386
## for DELL latitude laptop
#sudo setxkbmap -model latitude -layout us
387 388 389 390




391
### Preparation of installation tools ###
392

393
## temporarly unactivate of listchanges
394
APT_LISTCHANGES_FRONTEND=none
395 396

## update of packages before installation
397
sudo apt-get update
398

399
## to install packages in non-interactive mode
400
DEBIAN_FRONTEND=noninteractive
401 402 403 404
sudo apt-get install --assume-yes debconf 

## to install keys for additionnal packages repository
sudo apt-get install --assume-yes dirmngr
405 406 407



408 409 410
#############################################################

### Downloading packages
411

412
if [ "${VIRTUALBOX}" -eq "1" ]
413
then
414
  info "downloading software for VIRTUALBOX"
415

416 417 418 419 420 421 422 423
  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
424 425
fi

426
if [ "${DATABASE}" -eq "1" ]
427
then
Philippe Gauron's avatar
Philippe Gauron committed
428
  info "downloading software for Database server and PHPMyAdmin"
429 430 431 432

  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
    ## Debian 9+/MariaDB
433
    sudo apt-get install -d --assume-yes mariadb-client mariadb-server phpmyadmin expect
434 435
  else
    ## Debian 8-/MySQL
436
    sudo apt-get install -d --assume-yes --force-yes mysql-client mysql-server phpmyadmin
437 438 439
  fi
fi

440
if [ "${TANGO_DB}" -eq "1" ]
441
then
Philippe Gauron's avatar
Philippe Gauron committed
442
  info "downloading software for TANGO DB"
443

444
  sudo apt-get install -d --assume-yes tango-db
445 446
fi

447
if [ "${ARCHIVING}" -eq "1" ]
448
then
Philippe Gauron's avatar
Philippe Gauron committed
449
  info "downloading software for ArchivingRoot"
450

451
  sudo apt-get install -d --assume-yes unzip
452 453 454
  mkdir -p "${REPO_DIR}/tmp"
  cd "${REPO_DIR}/tmp"
  if [ ! -f "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ]
455
    then
456
      wget -c "https://owncloud.lal.in2p3.fr/public.php?service=files&t=47ceb87fca676922732a3f5d34d4306d&download" -P "${REPO_DIR}/tmp" -O ArchivingRoot-last.zip
457 458 459
    fi
fi

460
if [ "${TANGO}" -eq "1" ] 
461
then
Philippe Gauron's avatar
Philippe Gauron committed
462
  info "downloading software for TANGO base tools"
463 464 465 466

  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
  ## Debian 9
467 468 469
    ## Install python package manager
    sudo apt install --assume-yes python-pip

470 471
    ## Install Oracle Java
    if ! [ -e /etc/apt/sources.list.d/webupd8team-java.list ] \
472 473
       || [[ "$(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" ]]
474 475 476 477 478 479 480 481 482
    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
483 484
    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
485
    ## needed to replace OpenJDK by Oracle Java
486
    sudo apt-get install -d --assume-yes libxrender1 libxtst6
487 488

    ## TANGO packages
489
    sudo apt-get install -d --assume-yes tango-starter tango-test python-pytango libtango-doc libtango-dev liblog4j1.2-java
490
    LIBTANGO_JAVA=libtango-java_9.2.5a-1_all.deb
491 492 493 494 495 496 497 498 499 500 501 502

    ## 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
503
    pip download -d "${REPO_DIR}/pip-tmp" fandango==13.9.0 taurus==4.4.0 PyYAML==3.13 QtPy==1.2.1
504

505 506
  else
  ## Debian 8
507
    if ! [ -e /etc/apt/sources.list.d/webupd8team-java.list ] \
508 509
         || [[ "$(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" ]]
510 511 512 513 514 515 516 517 518
    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
519 520
    sudo apt-get install --assume-yes --force-yes oracle-java8-installer
    sudo apt-get install -d --assume-yes --force-yes oracle-java8-set-default
521
    ## needed to replace OpenJDK by Oracle Java
522
    sudo apt-get install -d --assume-yes libxrender1 libxtst6
523 524

    ## TANGO packages
525
    sudo apt-get install -d --assume-yes --force-yes tango-common tango-starter tango-test python-pytango libtango8-doc libtango8-dev liblog4j1.2-java
526 527 528 529
    LIBTANGO_JAVA=libtango-java_8.1.2.c-1_all.deb
  fi
  if ! ( sudo apt-get install -f libtango-java )
  then
530
    if [ ! -f "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" ]
531
    then
532
      wget -c "https://people.debian.org/~picca/${LIBTANGO_JAVA}" -P "${REPO_DIR}/tmp"
533 534 535
    fi
  fi
fi
536

537 538 539

info "downloading software for offline installation finished with success"

540
if [ "${DOWNLOAD_ONLY}" -eq "1" ]
541 542 543 544 545 546 547 548 549
then
  exit 0
fi





#############################################################
550

551
### Specific installation for virtual machines (big screen and copy/paste) 
552
if [ "${VIRTUALBOX}" -eq "1" ]
553
then
554
  info "installation of VIRTUALBOX options"
555

556
## Disable screensaver which can block VIRTUALBOX
557 558 559
  sudo apt-get remove --assume-yes light-locker


560
## Installation of VirtualBox addons for bigger resolutions
561 562 563 564 565 566 567 568 569 570 571
  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
Philippe Gauron's avatar
Philippe Gauron committed
572

573 574 575 576 577 578
fi





579
### Installation of DATABASE DB server ###
580
if [ "${DATABASE}" -eq "1" ]
581
then
582 583 584
  info "installation of Database"

  ## check if Database is already installed
585 586
  DATABASE_INSTALLED=0
  dpkg -l mysql-server &> /dev/null && DATABASE_INSTALLED=1
587 588 589 590 591 592 593 594 595 596

  if [ "${DATABASE_INSTALLED}" -eq "1" ]
  then
    info "Database already installed."
  else

    ## configuration of Database server
    if [ "${DEBIAN_VERSION}" -gt "8" ]
    then
      ## Debian 9+/MariaDB
597 598
      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
599 600

      sudo apt-get install --assume-yes mariadb-client mariadb-server
601 602 603 604 605 606 607 608
      ## 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):\"
609
          send \"${DB_ROOT_PASSWORD}\r\"
610 611 612 613 614 615 616 617 618 619 620 621
          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
          ")
622
      echo "${SECURE_MYSQL}"
623
      sudo apt-get purge --assume-yes expect
624 625
    else
      ## Debian 8-/MySQL
626 627
      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
628

629
      sudo apt-get install --assume-yes --force-yes mysql-server mysql-client
630 631 632
    fi

  fi
633

634
  ### Installation of PHPMyAdmin
635

636 637 638 639 640 641
  ## 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
642
    ## Access to PHPMyAdmin for user tango
643 644
    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
645

646
    #echo "phpmyadmin phpmyadmin/mysql/admin-pass string ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections
647 648 649 650 651 652 653 654

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

656
    ## root password for Database
657 658
    #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
659 660

    ## password for phpmyadmin application
661 662
    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
663 664

    ## root password for Database
665 666
    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
667

668
#    echo "phpmyadmin phpmyadmin/password-confirm password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections
669 670

    ## installation of PHPMyAdmin server
671
    sudo apt-get install --assume-yes --force-yes --quiet phpmyadmin
672
  fi
673 674


675
## creation of shortcut
676 677 678 679 680
  ## if file exists
  if [ -e /var/www/phpmyadmin ]
  then
    error "file '/var/www/phpmyadmin' already exists!" ${E_ALREADY_INSTALLED}
  fi
681

682
  sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin
683 684 685 686 687
fi




688

689
## configuration of network names if no DNS
690 691
#sudo sh -c "echo "192.168.1.101   ${TANGOSERVER}"  >> /etc/hosts"
#sudo sh -c 'echo "192.168.1.110   ${SERVERNAME}" >> /etc/hosts'
692 693 694 695 696





697
### installation of TANGO DB for TANGO server
698
if [ "${TANGO_DB}" -eq "1" ]
699 700 701
then
  info "installation of TANGO_DB"

702
  #tango-db depends on tango-common
703 704
  echo "tango-common tango-common/tango-host string ${TANGOSERVER}:20000" | sudo debconf-set-selections

705 706 707 708
  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
  ## Debian 9+/MariaDB
    echo 'tango-db tango-db/dbconfig-install boolean true' | sudo debconf-set-selections
709 710
    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
711 712 713 714
  else
    ## Debian 8-/MySQL

    echo 'tango-db tango-db/dbconfig-install boolean true' | sudo debconf-set-selections
715 716
    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
717 718
  fi

719
  sudo apt-get install --assume-yes tango-db
720 721 722 723 724 725

fi




726

727
### Installation of TANGO base tools
728
if [ "${TANGO}" -eq "1" ]
729
then
730 731
  info "installation of TANGO base tools"
### Installation of Java
732
  sudo apt-get --assume-yes install oracle-java8-installer oracle-java8-set-default
733
  ## needed to replace OpenJDK by Oracle Java
734
  sudo apt-get install --assume-yes libxrender1 libxtst6
735

736

gauron's avatar
gauron committed
737
### configuration of TANGO
738

gauron's avatar
gauron committed
739
## configuration tango-common
740
  echo "tango-common tango-common/tango-host string ${TANGOSERVER}:20000" | sudo debconf-set-selections
741

gauron's avatar
gauron committed
742
## configuration into /etc/tangorc
743 744
sudo sh -c 'echo "source /etc/tangorc" >> /etc/bash.bashrc'
sudo sh -c 'echo "export TANGO_HOST" >> /etc/bash.bashrc'
745

746
## installation of TANGO
747 748 749 750
  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
  ## Debian 9 and +
    echo "installation TANGO Debian 9+"
751 752

    ## TANGO packages
753 754
    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
755 756 757 758 759 760 761 762

    ## 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
763
    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
764

765 766 767 768 769 770 771 772
  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
773
    if [ ! -f "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" ]
774
    then
775
      wget -c "https://people.debian.org/~picca/${LIBTANGO_JAVA}" -P "${REPO_DIR}/tmp"
776
    fi
777
    sudo dpkg -i "${REPO_DIR}/tmp/${LIBTANGO_JAVA}"
778
  fi
779

780 781 782 783 784 785 786
fi






gauron's avatar
gauron committed
787
### installation of ArchivingRoot ###
788
if [ "${ARCHIVING}" -eq "1" ]
789
then
790
  info "installation of ARCHIVING"
791 792 793

  sudo mkdir -p /opt/ArchivingRoot
  cd /opt/ArchivingRoot
794

795
  if [ -e "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ]
796
  then
797
    cp "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ./
798
  else
799
    wget -c "https://owncloud.lal.in2p3.fr/public.php?service=files&t=47ceb87fca676922732a3f5d34d4306d&download" -P "${REPO_DIR}/tmp" -O ArchivingRoot-last.zip
800
  fi
801
  sudo apt-get install unzip
802
  sudo unzip -o ArchivingRoot-last.zip
803
  sudo rm ArchivingRoot-last.zip
804
  cd "${REPO_DIR}/"
805

gauron's avatar
gauron committed
806
## configuration into /etc/tangorc
807
  sudo sh -c 'echo "ARCHIVING_ROOT=/opt/ArchivingRoot" >> /etc/tangorc'
808
  sudo sh -c 'echo "export ARCHIVING_ROOT" >> /etc/bash.bashrc'
809 810


811
## configuration of ArchivingRoot
812

813
## creates TDB and HDB databases into Database
814 815
  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
816
  mysql -h localhost -u root -p"${DB_ROOT_PASSWORD}" < "${REPO_DIR}/archive1/create-SNAPDB-MyISAM.sql"
817

818

gauron's avatar
gauron committed
819
## Declaration of Archiving Device Servers into TANGO DB from TANGOSERVER