script-install.sh 31.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 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
##   "su"
24
##   "apt 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
##   check that cdrom is removed/commented from this file if necessary
30
## 4 get the script ("sudo apt install git" &
31
##   "git clone https://gitlab.in2p3.fr/CCThomX/installation.git")
32
## 5 check if setxkbmap is well configured if necessary
33 34
## 6 configure the INSTALLATION PARAMETERS in the script including 
##   ARCHIVING_DIR
35
## 7 launch the script with TANGOSERVER name as parameter
36
##   ("cd installation ; sudo script-install.sh [TANGOSERVER]")
37
## 8 on distant host, install xauth package (sudo apt install xauth)
38 39 40 41 42 43
## 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) 
44
##     should work : this is automatically checked at the end of installation.
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
##     `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)`
##     
81 82 83 84 85 86 87 88 89
##   * 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
90
##   * TANGO: 
91 92
##     + yat & yat4tango installation : check presence of /usr/include/yat &
##       /usr/include/yat4tango directories and libraries /usr/lib/libyat.so &
93 94
##       /usr/lib/libyat4tango.so : this is automatically checked at the end of 
##       installation
95
##     + `java -version` should not return openjdk
96
##     + test GUI:
97
##       - get IHM repo : `hg clone https://gitlab.in2p3.fr/CCThomX/IHM.git`
98 99 100 101 102 103 104 105 106
##       - 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 
107
##       the repo `hg clone git@gitlab.in2p3.fr:CCThomX/DS-LAL.git`
108 109
##       Then build a DS.
##   * ARCHIVING: to complete by JCM
110 111 112
##
## If any issue occurs, you can check installation parameters are well 
## spelled with command debconf-get-selections from package debconf-utils.
113 114 115



116 117
### INSTALLATION PARAMETERS
## 1 if to install, 0 otherwise
gauron's avatar
gauron committed
118

119
## Downloading packages only
120
DOWNLOAD_ONLY=0
121 122
## Checking and activating dependencies
DEPENDENCIES=1
123
## VirtualBox
124
VIRTUALBOX=0
125
## Database server and PHPMyAdmin
126
DATABASE=0
127
## TANGO base tools
128
TANGO=0
129
## TANGO DB (depends on TANGO and DATABASE)
130
TANGO_DB=0
131
## Archiving (depends on DATABASE)
132
ARCHIVING=0
133

134 135
## Directory where to install 
ARCHIVING_DIR="/var/archivage"
136

137 138
#############################################################

139 140


141 142
## Errors
E_INCORRECT_ARGS=1
143
E_NONROOT=2
144 145
E_INCORRECT_TANGOSERVER=3
E_INCORRECT_HOSTNAME=4
146
E_INCORRECT_SYSTEM=5
147 148
E_INCORRECT_DB_ROOT_PWD=6
E_INCORRECT_DB_TANGO_PWD=7
149

150 151
E_PARAM_ERROR=11
E_PARAM_WARNING=12
152 153
E_PARAM_INFO=13

154 155
E_ABORT_SCRIPT=21

156
E_ALREADY_INSTALLED=31
157

158 159 160
E_TANGOTEST_DS_UNDEFINED=41
E_TANGOTEST_DEVICE_UNDEFINED=42
E_TANGOTEST_DEVICE_UNREACHABLE=43
161
E_INCORRECT_JDK=44
162

163
## Default variables
164
DEFAULTTANGOSERVER=${HOSTNAME}
165

gauron's avatar
gauron committed
166
## Colors
167 168 169 170 171 172 173 174 175 176 177 178
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"

179
##  Initialise text attributes to standard without flushing the screen
180
alias init="tput sgr0"
181

182
## Other variables
183
UID_ROOT=0
184 185
REPO_DIR=${PWD}
HOME_DIR="/home/${SUDO_USER}"
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
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)"
219

220 221
#############################################################

222
### Printing functions
223

224 225
## error
## Prints a error message and exit from the script with given error code.
226
##
227
## parameters :
228
##   msg : message printed in ${RED}
229
##   code : error code
230

231
function error
232
{
233
  if [ "$#" -eq "2" ]
234
  then
235
    echo -e "${BOLD}${RED}Error: $1!${END_FORMATING}"
236
    exit "$2"
237
  else
238
    echo -e "${BOLD}${RED}Error : incorrect number of parameters $# for function 'error'!${END_FORMATING}"
239
    exit ${E_PARAM_ERROR}
240 241 242 243
  fi
}


244 245
## alerte
## Prints a warning message.
246 247
##
## paramètres :
248
##   msg : message printed in ${YELLOW}
249

250
function warning
251
{
252
  if [ "$#" -eq "1" ]
253
  then
254
    echo -e "${BOLD}${YELLOW}Warning : $1.${END_FORMATING}"
255
  else
256
    error "Incorrect number of parameters $#  for function 'warning'" ${E_PARAM_WARNING}
257 258 259
  fi
}

260 261
## info
## Prints an information message.
262
##
263
## parameters :
264
##   msg : message printed in ${GREEN}
265 266 267

function info
{
268
  if [ "$#" -eq "1" ]
269
  then
270
    echo -e "${BOLD}${GREEN}Information : $1.${END_FORMATING}"
271
  else
272
    error "Incorrect number of parameters $# for function 'info'" ${E_PARAM_INFO}
273 274 275 276
  fi
}


277
### EXECUTION ###
278
## 
279
## This script must be launched with sudo (or type password when asked)
280

281
## Stop this script at first error
282 283 284
set -e


285
#############################################################
286 287


288
### Checking parameters
289

290
## To launch as root of course
291
if [ "${EUID}" -ne "${UID_ROOT}" ]
292
then
293
  error "You must be root to launch this script" ${E_NONROOT}
294 295
fi  

296
## To launch with 1 parameter maximum
297
if [ "$#" -gt "1" ]
298
then
299
  error "To much parameters.\n\nUsage: $(basename "$0") [TANGOSERVER_name]" ${E_INCORRECT_ARGS}
300 301 302
fi


303
## Debian version
304
if [ "$(/usr/bin/lsb_release -is)" == "Debian" ]
305 306 307 308 309 310 311 312 313 314 315
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
316

317 318
## Definition of the hostname (also used as user's group name)
SERVERNAME=${HOSTNAME}
319

320
info "server will be installed with name '${SERVERNAME}'"
321

322
## Definition of user's group
323
SUDO_GROUP=$(id -g -n "${SUDO_USER}")
324 325 326 327




328
## Definition of TANGOSERVER name:
329
## - "${HOSTNAME}" as default
330
## - from given parameter
331
TANGOSERVER=${1-${DEFAULTTANGOSERVER}}
332 333


334
if [ "${TANGOSERVER}" != "${SERVERNAME}" ] && [ "${TANGO_DB}" -eq "1" ]
335
then
336
  error "installation of TANGO_DB is asked but TANGOSERVER (='${TANGOSERVER}') has another name than SERVERNAME (='${SERVERNAME}')" ${E_INCORRECT_TANGOSERVER}
337 338
fi

339
info "server will be installed with TANGOSERVER '${TANGOSERVER}'"
340 341


342

343 344 345

### Checking and correcting of initial configuration

346
## ${SERVERNAME} == ${TANGOSERVER} -> TANGO-DB=1
347 348
if [ "${DEPENDENCIES}" == "1" ] \
   && [ "${SERVERNAME}" == "${TANGOSERVER}" ] \
349
   && [ "${TANGO_DB}" -eq "0" ]
350
then
351
  warning "${SERVERNAME} == ${TANGOSERVER}, TANGO_DB will be installed."
352 353 354
  TANGO_DB=1
fi

355
## ARCHIVING=1 -> DATABASE=1
356
if [ "${DEPENDENCIES}" == "1" ] && [ "${DATABASE}" -eq "0" ] && [ "${ARCHIVING}" -eq "1" ]
357
then
358 359
  warning "installation of ARCHIVING asked, DATABASE will be installed."
  DATABASE=1
360 361 362
fi


363
## TANGO_DB=1 -> TANGO=1 & DATABASE=1
364
if [ "${DEPENDENCIES}" == "1" ] && [ "${TANGO_DB}" -eq "1" ]
365
then
366
  ##warning "installation of TANGO_DB asked, TANGO will be installed."
367
  TANGO=1
368
  DATABASE=1
369 370 371
fi


372
## Prints final corrected configuration
373
echo ""
374
echo "Final configuration  to install: "
375
if [ "${VIRTUALBOX}" -eq "1" ]
376
then
377
  echo "VIRTUALBOX"
378
fi
379
if [ "${DATABASE}" -eq "1" ]
380
then
381
  echo "Database server and PHPMyAdmin"
382
fi
383
if [ "${TANGO}" -eq "1" ]
384 385 386
then
  echo "TANGO base tools"
fi
387
if [ "${TANGO_DB}" -eq "1" ]
388 389 390
then
  echo "TANGO DB"
fi
391
if [ "${ARCHIVING}" -eq "1" ]
392 393 394 395
then
  echo "ArchivingRoot"
fi

396

397 398


399
if [ "${DOWNLOAD_ONLY}" -eq "1" ]
400
then
401 402 403
  warning "installation will only download software and will not install anything"
else
  ## Exit if user does not confirm configuration
404 405
  read -p "Do you want to install this configuration? ([Yy]Nn) " CHOICE
  case "${CHOICE}" in
406
    y|Y ) info "Begining installation...";;
407 408
    n|N ) info "Abort installation"; exit ${E_ABORT_SCRIPT};;
    * ) info "Abort installation (invalid answer)"; exit ${E_ABORT_SCRIPT};;
409 410
  esac

411
  if [ "${DATABASE}" -eq "1" ] || [ "${TANGO_DB}" -eq "1" ] || [ "${ARCHIVING}" -eq "1" ]
412 413 414
  then
    ## Get Database root password
    echo "Please enter root password for DATABASE: "
415
    read -s DB_ROOT_PASSWORD
416 417 418
    echo "Please confirm root password for DATABASE: "
    read -s DB_ROOT_PASSWORD2
    while test "${DB_ROOT_PASSWORD}" != "${DB_ROOT_PASSWORD2}"
419
    do warning "Passwords are not equals."
420 421 422 423 424 425 426
       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

427 428
    echo "Please enter tango password for DATABASE: "
    read -s DB_TANGO_PASSWORD
429 430 431
    echo "Please confirm tango password for DATABASE: "
    read -s DB_TANGO_PASSWORD2
    while test "${DB_TANGO_PASSWORD}" != "${DB_TANGO_PASSWORD2}"
432
    do warning "Passwords are not equals."
433 434 435 436 437
       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
438
    MYSQL_USER=tango
439
    MYSQL_PASSWORD=${DB_TANGO_PASSWORD}
440
  fi
441

442
fi
443

444

445
## configuration AZERTY (equivalent of
gauron's avatar
gauron committed
446
## "dpkg-reconfigure keyboard-configuration", but in non-interactive mode)
447
## for PC-tower keyboard
448
#sudo setxkbmap -model pc105 -layout fr -variant latin9
449
## for flat USB Mac
450
#setxkbmap -model macintosh -layout fr
451 452
## for DELL latitude laptop
#sudo setxkbmap -model latitude -layout us
453 454 455 456




457
### Preparation of installation tools ###
458

459
## temporarly unactivate of listchanges
460
APT_LISTCHANGES_FRONTEND=none
461 462

## update of packages before installation
463
sudo apt update
464

465
## to install packages in non-interactive mode
466
DEBIAN_FRONTEND=noninteractive
467
sudo apt install --assume-yes debconf 
468 469

## to install keys for additionnal packages repository
470
sudo apt install --assume-yes dirmngr
471

472 473
# creating temporary directory for installation
mkdir -p "${REPO_DIR}/tmp"
474 475


476 477 478
#############################################################

### Downloading packages
479

Philippe Gauron's avatar
Philippe Gauron committed
480
## Common tools for all installations
481
# host, to find offline IP hosts
Philippe Gauron's avatar
Philippe Gauron committed
482
sudo apt install -d host
483 484
# git mercurial
sudo apt install --assume-yes git mercurial
485 486
# pip
sudo apt install --assume-yes python-pip
Philippe Gauron's avatar
Philippe Gauron committed
487

488
if [ "${VIRTUALBOX}" -eq "1" ]
489
then
490
  echo
491
  info "downloading software for VIRTUALBOX"
492

493
  sudo apt install -d modules-assistant build-essential
494 495
fi

496
if [ "${DATABASE}" -eq "1" ]
497
then
498
  echo
Philippe Gauron's avatar
Philippe Gauron committed
499
  info "downloading software for Database server and PHPMyAdmin"
500

501 502
  ## Debian 9+/MariaDB
  sudo apt install -d --assume-yes mariadb-client mariadb-server phpmyadmin expect
503 504
fi

505
if [ "${TANGO_DB}" -eq "1" ]
506
then
507
  echo
Philippe Gauron's avatar
Philippe Gauron committed
508
  info "downloading software for TANGO DB"
509

510
  sudo apt install -d --assume-yes tango-db
511 512
fi

513
if [ "${ARCHIVING}" -eq "1" ]
514
then
515
  echo
Philippe Gauron's avatar
Philippe Gauron committed
516
  info "downloading software for ArchivingRoot"
517

518
  sudo apt install -d --assume-yes unzip
519
  if [ ! -f "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ]
520
    then
521
      wget -c "https://owncloud.lal.in2p3.fr/public.php?service=files&t=47ceb87fca676922732a3f5d34d4306d&download" -P "${REPO_DIR}/tmp" -O ArchivingRoot-last.zip
522
  fi
523 524
fi

525
if [ "${TANGO}" -eq "1" ] 
526
then
527
  echo
Philippe Gauron's avatar
Philippe Gauron committed
528
  info "downloading software for TANGO base tools"
529

530 531
  ## Install Oracle Java 8
  if ! [ -f /etc/apt/sources.list.d/webupd8team-java.list ] \
532 533
       || [[ "$(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" ]]
534 535 536 537 538 539 540 541 542 543 544 545
  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
546

547 548 549
  ## 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
550

551 552 553 554 555 556 557
  ## 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
558

559 560 561 562 563 564 565 566 567
  ## 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=""
568
  else
569 570
    ## Else, pip download can fail
    PIP_OPTION=" --exists-action i"
571
  fi
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
  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" ]
596
  then
597 598 599 600 601 602 603
    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
    
604
  if [ ! -d "${REPO_DIR}/tmp/YAT-1.14.5" ]
605 606 607
  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
608
  if [ ! -d "${REPO_DIR}/tmp/YAT4Tango-1.11.4" ]
609 610
  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"
611
  fi
612

613 614 615 616
  if [ ! -e "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" ]
  then
    wget -c "https://people.debian.org/~picca/${LIBTANGO_JAVA}" -P "${REPO_DIR}/tmp"
  fi
617
fi
618

619

620 621
echo
echo
622
info "downloading software for offline installation finished with success"
623 624 625
echo "==================================================================="
echo
echo
626

627
if [ "${DOWNLOAD_ONLY}" -eq "1" ]
628 629 630 631 632 633 634 635 636
then
  exit 0
fi





#############################################################
637

Philippe Gauron's avatar
Philippe Gauron committed
638 639 640 641 642
## Common tools for all installations
# host, to find 
sudo apt install --assume-yes host


643
### Specific installation for virtual machines (big screen and copy/paste) 
644
if [ "${VIRTUALBOX}" -eq "1" ]
645
then
646
  echo
647
  info "installation of VIRTUALBOX options"
648

649
## Disable screensaver which can block VIRTUALBOX
650
  sudo apt remove --assume-yes light-locker
651 652


653
## Installation of VirtualBox addons for bigger resolutions
654 655 656
  sudo apt install modules-assistant build-essential
  sudo m-a prepare
  sudo sh /media/cdrom/VBoxLinuxAdditions.run
657 658 659
fi


660
### Installation of DATABASE DB server ###
661
if [ "${DATABASE}" -eq "1" ]
662
then
663
  echo
664 665 666
  info "installation of Database"

  ## check if Database is already installed
667 668
  DATABASE_INSTALLED=0
  dpkg -l mysql-server &> /dev/null && DATABASE_INSTALLED=1
669 670 671 672 673 674 675

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

    ## configuration of Database server
676 677 678 679 680 681 682 683 684 685
    ## 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 "
686 687 688
          set timeout 10
          spawn mysql_secure_installation
          expect \"Enter current password for root (enter for none):\"
689
          send \"${DB_ROOT_PASSWORD}\r\"
690 691 692 693 694 695 696 697 698 699 700 701
          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
          ")
702 703
    echo "${SECURE_MYSQL}"
    sudo apt purge --assume-yes expect
704
  fi
705

706
  ### Installation of PHPMyAdmin
707

708
  ## configuration of PHPMyAdmin
709 710 711 712
  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
713

714 715
  ## installation of PHPMyAdmin server
  sudo apt install --assume-yes --quiet phpmyadmin
716

717
## creation of shortcut
718 719 720 721 722
  ## if file exists
  if [ -e /var/www/phpmyadmin ]
  then
    error "file '/var/www/phpmyadmin' already exists!" ${E_ALREADY_INSTALLED}
  fi
723

724
  sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin
725 726 727 728 729
fi




730

731
## configuration of network names if no DNS
732 733
#sudo sh -c "echo "192.168.1.101   ${TANGOSERVER}"  >> /etc/hosts"
#sudo sh -c 'echo "192.168.1.110   ${SERVERNAME}" >> /etc/hosts'
734 735 736 737 738





739
### installation of TANGO DB for TANGO server
740
if [ "${TANGO_DB}" -eq "1" ]
741
then
742
  echo
743 744
  info "installation of TANGO_DB"

745
  #tango-db depends on tango-common
746 747
  echo "tango-common tango-common/tango-host string ${TANGOSERVER}:20000" | sudo debconf-set-selections

748 749 750
  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
751

752
  sudo apt install --assume-yes tango-db
753 754 755 756 757
fi




758

759
### Installation of TANGO base tools
760
if [ "${TANGO}" -eq "1" ]
761
then
762
  echo
763 764
  info "installation of TANGO base tools"
### Installation of Java
765
  sudo apt install --assume-yes oracle-java8-installer oracle-java8-set-default
766
  ## needed to replace OpenJDK by Oracle Java
767
  sudo apt install --assume-yes libxrender1 libxtst6
768

769

gauron's avatar
gauron committed
770
### configuration of TANGO
771

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

gauron's avatar
gauron committed
775
## configuration into /etc/tangorc
776 777
sudo sh -c 'echo "source /etc/tangorc" >> /etc/bash.bashrc'
sudo sh -c 'echo "export TANGO_HOST" >> /etc/bash.bashrc'
778

779
## installation of TANGO
780
  info "installation TANGO Debian 9+"
781

782 783 784
  ## 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
785

786 787 788
  ## Development packages
  sudo apt --assume-yes install python-pip
  sudo apt --assume-yes install gcc g++ make xemacs21 man
789

790 791 792
  ## 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
793

794 795
  ## 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
796

797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
  ## 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
825
  fi
826 827 828 829 830 831 832 833 834 835 836
  export PKG_CONFIG_PATH=/usr/lib/pkgconfig
  cd "${REPO_DIR}/tmp/YAT-1.14.5"