script-install.sh 34.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
## 6 configure the INSTALLATION PARAMETERS in the script including 
##   ARCHIVING_DIR
34
## 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
## 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) 
43
##     should work : this is automatically checked at the end of installation.
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
##     `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)`
##     
80 81 82 83 84 85 86 87 88
##   * 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
89
##   * TANGO: 
90 91
##     + yat & yat4tango installation : check presence of /usr/include/yat &
##       /usr/include/yat4tango directories and libraries /usr/lib/libyat.so &
92 93
##       /usr/lib/libyat4tango.so : this is automatically checked at the end of 
##       installation
94
##     + `java -version` should not return openjdk
95
##     + test GUI:
96
##       - get IHM repo : `hg clone https://gitlab.in2p3.fr/CCThomX/IHM.git`
97 98 99 100 101 102 103 104 105
##       - 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 
106
##       the repo `hg clone git@gitlab.in2p3.fr:CCThomX/DS-LAL.git`
107 108
##       Then build a DS.
##   * ARCHIVING: to complete by JCM
109 110 111
##
## If any issue occurs, you can check installation parameters are well 
## spelled with command debconf-get-selections from package debconf-utils.
112 113 114



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

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

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

136 137
#############################################################

138 139


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

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

153 154
E_ABORT_SCRIPT=21

155
E_ALREADY_INSTALLED=31
156

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

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

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

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

181
## Other variables
182
UID_ROOT=0
183 184
REPO_DIR=${PWD}
HOME_DIR="/home/${SUDO_USER}"
185 186


187 188
#############################################################

189
### Printing functions
190

191 192
## error
## Prints a error message and exit from the script with given error code.
193
##
194
## parameters :
195
##   msg : message printed in ${RED}
196
##   code : error code
197

198
function error
199
{
200
  if [ "$#" -eq "2" ]
201
  then
202
    echo -e "${BOLD}${RED}Error: $1!${END_FORMATING}"
203
    exit "$2"
204
  else
205
    echo -e "${BOLD}${RED}Error : incorrect number of parameters $# for function 'error'!${END_FORMATING}"
206
    exit ${E_PARAM_ERROR}
207 208 209 210
  fi
}


211 212
## alerte
## Prints a warning message.
213 214
##
## paramètres :
215
##   msg : message printed in ${YELLOW}
216

217
function warning
218
{
219
  if [ "$#" -eq "1" ]
220
  then
221
    echo -e "${BOLD}${YELLOW}Warning : $1.${END_FORMATING}"
222
  else
223
    error "Incorrect number of parameters $#  for function 'warning'" ${E_PARAM_WARNING}
224 225 226
  fi
}

227 228
## info
## Prints an information message.
229
##
230
## parameters :
231
##   msg : message printed in ${GREEN}
232 233 234

function info
{
235
  if [ "$#" -eq "1" ]
236
  then
237
    echo -e "${BOLD}${GREEN}Information : $1.${END_FORMATING}"
238
  else
239
    error "Incorrect number of parameters $# for function 'info'" ${E_PARAM_INFO}
240 241 242 243
  fi
}


244
### EXECUTION ###
245
## 
246
## This script must be launched with sudo (or type password when asked)
247

248
## Stop this script at first error
249 250 251
set -e


252
#############################################################
253 254


255
### Checking parameters
256

257
## To launch as root of course
258
if [ "${EUID}" -ne "${UID_ROOT}" ]
259
then
260
  error "You must be root to launch this script" ${E_NONROOT}
261 262
fi  

263
## To launch with 1 parameter maximum
264
if [ "$#" -gt "1" ]
265
then
266
  error "To much parameters.\n\nUsage: $(basename "$0") [TANGOSERVER_name]" ${E_INCORRECT_ARGS}
267 268 269
fi


270
## Debian version
271
if [ "$(/usr/bin/lsb_release -is)" == "Debian" ]
272 273 274 275 276 277 278 279 280 281 282
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
283

284 285
## Definition of the hostname (also used as user's group name)
SERVERNAME=${HOSTNAME}
286

287
info "server will be installed with name '${SERVERNAME}'"
288

289
## Definition of user's group
290
SUDO_GROUP=$(id -g -n "${SUDO_USER}")
291 292 293 294




295
## Definition of TANGOSERVER name:
296
## - "${HOSTNAME}" as default
297
## - from given parameter
298
TANGOSERVER=${1-${DEFAULTTANGOSERVER}}
299 300


301
if [ "${TANGOSERVER}" != "${SERVERNAME}" ] && [ "${TANGO_DB}" -eq "1" ]
302
then
303
  error "installation of TANGO_DB is asked but TANGOSERVER (='${TANGOSERVER}') has another name than SERVERNAME (='${SERVERNAME}')" ${E_INCORRECT_TANGOSERVER}
304 305
fi

306
info "server will be installed with TANGOSERVER '${TANGOSERVER}'"
307 308


309

310 311 312

### Checking and correcting of initial configuration

313
## ${SERVERNAME} == ${TANGOSERVER} -> TANGO-DB=1
314 315
if [ "${DEPENDENCIES}" == "1" ] \
   && [ "${SERVERNAME}" == "${TANGOSERVER}" ] \
316
   && [ "${TANGO_DB}" -eq "0" ]
317
then
318
  warning "${SERVERNAME} == ${TANGOSERVER}, TANGO_DB will be installed."
319 320 321
  TANGO_DB=1
fi

322
## ARCHIVING=1 -> DATABASE=1
323
if [ "${DEPENDENCIES}" == "1" ] && [ "${DATABASE}" -eq "0" ] && [ "${ARCHIVING}" -eq "1" ]
324
then
325 326
  warning "installation of ARCHIVING asked, DATABASE will be installed."
  DATABASE=1
327 328 329
fi


330
## TANGO_DB=1 -> TANGO=1 & DATABASE=1
331
if [ "${DEPENDENCIES}" == "1" ] && [ "${TANGO_DB}" -eq "1" ]
332
then
333
  ##warning "installation of TANGO_DB asked, TANGO will be installed."
334
  TANGO=1
335
  DATABASE=1
336 337 338
fi


339
## Prints final corrected configuration
340
echo ""
341
echo "Final configuration  to install: "
342
if [ "${VIRTUALBOX}" -eq "1" ]
343
then
344
  echo "VIRTUALBOX"
345
fi
346
if [ "${DATABASE}" -eq "1" ]
347
then
348
  echo "Database server and PHPMyAdmin"
349
fi
350
if [ "${TANGO}" -eq "1" ]
351 352 353
then
  echo "TANGO base tools"
fi
354
if [ "${TANGO_DB}" -eq "1" ]
355 356 357
then
  echo "TANGO DB"
fi
358
if [ "${ARCHIVING}" -eq "1" ]
359 360 361 362
then
  echo "ArchivingRoot"
fi

363

364 365


366
if [ "${DOWNLOAD_ONLY}" -eq "1" ]
367
then
368 369 370
  warning "installation will only download software and will not install anything"
else
  ## Exit if user does not confirm configuration
371 372
  read -p "Do you want to install this configuration? ([Yy]Nn) " CHOICE
  case "${CHOICE}" in
373
    y|Y ) info "Begining installation...";;
374 375
    n|N ) info "Abort installation"; exit ${E_ABORT_SCRIPT};;
    * ) info "Abort installation (invalid answer)"; exit ${E_ABORT_SCRIPT};;
376 377
  esac

378
  if [ "${DATABASE}" -eq "1" ] || [ "${TANGO_DB}" -eq "1" ] || [ "${ARCHIVING}" -eq "1" ]
379 380 381
  then
    ## Get Database root password
    echo "Please enter root password for DATABASE: "
382
    read -s DB_ROOT_PASSWORD
383 384 385 386 387 388 389 390 391 392 393
    echo "Please confirm root password for DATABASE: "
    read -s DB_ROOT_PASSWORD2
    while test "${DB_ROOT_PASSWORD}" != "${DB_ROOT_PASSWORD2}"
    do info "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

394 395
    echo "Please enter tango password for DATABASE: "
    read -s DB_TANGO_PASSWORD
396 397 398 399 400 401 402 403 404
    echo "Please confirm tango password for DATABASE: "
    read -s DB_TANGO_PASSWORD2
    while test "${DB_TANGO_PASSWORD}" != "${DB_TANGO_PASSWORD2}"
    do info "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
405
    MYSQL_USER=tango
406
    MYSQL_PASSWORD=${DB_TANGO_PASSWORD}
407
  fi
408

409
fi
410

411

412
## configuration AZERTY (equivalent of
gauron's avatar
gauron committed
413
## "dpkg-reconfigure keyboard-configuration", but in non-interactive mode)
414
## for PC-tower keyboard
415
#sudo setxkbmap -model pc105 -layout fr -variant latin9
416
## for flat USB Mac
417
#setxkbmap -model macintosh -layout fr
418 419
## for DELL latitude laptop
#sudo setxkbmap -model latitude -layout us
420 421 422 423




424
### Preparation of installation tools ###
425

426
## temporarly unactivate of listchanges
427
APT_LISTCHANGES_FRONTEND=none
428 429

## update of packages before installation
430
sudo apt-get update
431

432
## to install packages in non-interactive mode
433
DEBIAN_FRONTEND=noninteractive
434 435 436 437
sudo apt-get install --assume-yes debconf 

## to install keys for additionnal packages repository
sudo apt-get install --assume-yes dirmngr
438

439 440
# creating temporary directory for installation
mkdir -p "${REPO_DIR}/tmp"
441 442


443 444 445
#############################################################

### Downloading packages
446

Philippe Gauron's avatar
Philippe Gauron committed
447
## Common tools for all installations
448
# host, to find offline IP hosts
Philippe Gauron's avatar
Philippe Gauron committed
449
sudo apt install -d host
450 451
# git mercurial
sudo apt install --assume-yes git mercurial
Philippe Gauron's avatar
Philippe Gauron committed
452

453
if [ "${VIRTUALBOX}" -eq "1" ]
454
then
455
  info "downloading software for VIRTUALBOX"
456

457 458 459 460 461 462
  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
    ## Debian 9+/MariaDB
    sudo apt-get install -d modules-assistant
  else
    ## Debian 8-/MySQL
463
    sudo apt-get install -d --assume-yes xserver-xorg-core virtualbox-guest-x11
464
  fi
465 466
fi

467
if [ "${DATABASE}" -eq "1" ]
468
then
Philippe Gauron's avatar
Philippe Gauron committed
469
  info "downloading software for Database server and PHPMyAdmin"
470 471 472 473

  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
    ## Debian 9+/MariaDB
474
    sudo apt-get install -d --assume-yes mariadb-client mariadb-server phpmyadmin expect
475 476
  else
    ## Debian 8-/MySQL
477
    sudo apt-get install -d --assume-yes --force-yes mysql-client mysql-server phpmyadmin
478 479 480
  fi
fi

481
if [ "${TANGO_DB}" -eq "1" ]
482
then
Philippe Gauron's avatar
Philippe Gauron committed
483
  info "downloading software for TANGO DB"
484

485
  sudo apt-get install -d --assume-yes tango-db
486 487
fi

488
if [ "${ARCHIVING}" -eq "1" ]
489
then
Philippe Gauron's avatar
Philippe Gauron committed
490
  info "downloading software for ArchivingRoot"
491

492
  sudo apt-get install -d --assume-yes unzip
493 494
  cd "${REPO_DIR}/tmp"
  if [ ! -f "${REPO_DIR}/tmp/ArchivingRoot-last.zip" ]
495
    then
496
      wget -c "https://owncloud.lal.in2p3.fr/public.php?service=files&t=47ceb87fca676922732a3f5d34d4306d&download" -P "${REPO_DIR}/tmp" -O ArchivingRoot-last.zip
497 498
  fi
  cd ..
499 500
fi

501
if [ "${TANGO}" -eq "1" ] 
502
then
Philippe Gauron's avatar
Philippe Gauron committed
503
  info "downloading software for TANGO base tools"
504 505 506 507

  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
  ## Debian 9
508
    ## Install Oracle Java 8
509
    if ! [ -f /etc/apt/sources.list.d/webupd8team-java.list ] \
510 511
       || [[ "$(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" ]]
512 513 514 515 516 517 518 519 520
    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
521 522
    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
523
    ## needed to replace OpenJDK by Oracle Java
524
    sudo apt-get install -d --assume-yes libxrender1 libxtst6
525 526

    ## TANGO packages
527
    sudo apt-get install -d --assume-yes tango-common tango-starter tango-test python-pytango libtango-doc libtango-dev liblog4j1.2-java
528
    LIBTANGO_JAVA=libtango-java_9.2.5a-1_all.deb
529 530

    ## Development packages
531
    sudo apt install --assume-yes python-dev python-pip
532
    sudo apt install -d --assume-yes gcc g++ make xemacs21 man
533 534

    ## GUI packages
Philippe Gauron's avatar
Philippe Gauron committed
535 536
    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
537 538

    ## GUI pip packages
539
    if [ ! -d "${REPO_DIR}/tmp" ]
540
    then
541
      mkdir "${REPO_DIR}/tmp"
542
    fi
543 544 545 546 547 548 549 550 551
    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
    pip ${PIP_OPTION} download -d ${REPO_DIR}/tmp fandango==13.9.0 taurus==4.4.0 PyYAML==3.13 QtPy==1.2.1
552

553
    ## Hggit configuration
554 555
    pip ${PIP_OPTION} download -d ${REPO_DIR}/tmp dulwich>=0.19.0

556 557 558 559 560
    mkdir -p "${REPO_DIR}/tmp/hgext"
    if [ ! -d "${REPO_DIR}/tmp/hgext/hg-git" ]
    then
      hg clone https://bitbucket.org/durin42/hg-git tmp/hgext/hg-git
    fi
561

562
    ## yat & yat4tango libraries
563
    cd tmp
564 565
    sudo apt install --assume-yes subversion 
    sudo apt install --assume-yes -d pkg-config cmake
566 567 568 569 570 571 572 573 574 575
    
    if [ ! -d "${REPO_DIR}/tmp/yat" ]
    then
      svn checkout https://svn.code.sf.net/p/tango-cs/code/share/yat/trunk yat
    fi
    if [ ! -d "${REPO_DIR}/tmp/yat4tango" ]
    then
      svn checkout https://svn.code.sf.net/p/tango-cs/code/share/yat4tango/trunk yat4tango
    fi
    cd ..
576

577 578
  else
  ## Debian 8
579
    ## Install Oracle Java 8
580
    if ! [ -f /etc/apt/sources.list.d/webupd8team-java.list ] \
581 582
         || [[ "$(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" ]]
583 584 585 586 587 588 589 590 591
    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
592 593
    sudo apt-get install --assume-yes --force-yes oracle-java8-installer
    sudo apt-get install -d --assume-yes --force-yes oracle-java8-set-default
594
    ## needed to replace OpenJDK by Oracle Java
595
    sudo apt-get install -d --assume-yes libxrender1 libxtst6
596 597

    ## TANGO packages
598
    sudo apt-get install -d --assume-yes --force-yes tango-common tango-starter tango-test python-pytango libtango8-doc libtango8-dev liblog4j1.2-java
599 600 601 602
    LIBTANGO_JAVA=libtango-java_8.1.2.c-1_all.deb
  fi
  if ! ( sudo apt-get install -f libtango-java )
  then
603
    if [ ! -f "${REPO_DIR}/tmp/${LIBTANGO_JAVA}" ]
604
    then
605
      wget -c "https://people.debian.org/~picca/${LIBTANGO_JAVA}" -P "${REPO_DIR}/tmp"
606 607 608
    fi
  fi
fi
609

610 611 612

info "downloading software for offline installation finished with success"

613
if [ "${DOWNLOAD_ONLY}" -eq "1" ]
614 615 616 617 618 619 620 621 622
then
  exit 0
fi





#############################################################
623

Philippe Gauron's avatar
Philippe Gauron committed
624 625 626 627 628
## Common tools for all installations
# host, to find 
sudo apt install --assume-yes host


629
### Specific installation for virtual machines (big screen and copy/paste) 
630
if [ "${VIRTUALBOX}" -eq "1" ]
631
then
632
  info "installation of VIRTUALBOX options"
633

634
## Disable screensaver which can block VIRTUALBOX
635 636 637
  sudo apt-get remove --assume-yes light-locker


638
## Installation of VirtualBox addons for bigger resolutions
639 640 641 642 643 644 645 646 647 648 649
  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
650

651 652 653
fi


654
### Installation of DATABASE DB server ###
655
if [ "${DATABASE}" -eq "1" ]
656
then
657 658 659
  info "installation of Database"

  ## check if Database is already installed
660 661
  DATABASE_INSTALLED=0
  dpkg -l mysql-server &> /dev/null && DATABASE_INSTALLED=1
662 663 664 665 666 667 668 669 670 671

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

    ## configuration of Database server
    if [ "${DEBIAN_VERSION}" -gt "8" ]
    then
      ## Debian 9+/MariaDB
672 673
      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
674 675

      sudo apt-get install --assume-yes mariadb-client mariadb-server
676 677 678 679 680 681 682 683
      ## 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):\"
684
          send \"${DB_ROOT_PASSWORD}\r\"
685 686 687 688 689 690 691 692 693 694 695 696
          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
          ")
697
      echo "${SECURE_MYSQL}"
698
      sudo apt-get purge --assume-yes expect
699 700
    else
      ## Debian 8-/MySQL
701 702
      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
703

704
      sudo apt-get install --assume-yes --force-yes mysql-server mysql-client
705 706 707
    fi

  fi
708

709
  ### Installation of PHPMyAdmin
710

711 712 713 714 715 716
  ## 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
717
    ## Access to PHPMyAdmin for user tango
718 719
    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
720

721
    #echo "phpmyadmin phpmyadmin/mysql/admin-pass string ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections
722 723 724 725 726 727 728 729

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

731
    ## root password for Database
732 733
    #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
734 735

    ## password for phpmyadmin application
736 737
    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
738 739

    ## root password for Database
740 741
    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
742

743
#    echo "phpmyadmin phpmyadmin/password-confirm password ${DB_ROOT_PASSWORD}" | sudo debconf-set-selections
744 745

    ## installation of PHPMyAdmin server
746
    sudo apt-get install --assume-yes --force-yes --quiet phpmyadmin
747
  fi
748 749


750
## creation of shortcut
751 752 753 754 755
  ## if file exists
  if [ -e /var/www/phpmyadmin ]
  then
    error "file '/var/www/phpmyadmin' already exists!" ${E_ALREADY_INSTALLED}
  fi
756

757
  sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin
758 759 760 761 762
fi




763

764
## configuration of network names if no DNS
765 766
#sudo sh -c "echo "192.168.1.101   ${TANGOSERVER}"  >> /etc/hosts"
#sudo sh -c 'echo "192.168.1.110   ${SERVERNAME}" >> /etc/hosts'
767 768 769 770 771





772
### installation of TANGO DB for TANGO server
773
if [ "${TANGO_DB}" -eq "1" ]
774 775 776
then
  info "installation of TANGO_DB"

777
  #tango-db depends on tango-common
778 779
  echo "tango-common tango-common/tango-host string ${TANGOSERVER}:20000" | sudo debconf-set-selections

780 781 782 783
  if [ "${DEBIAN_VERSION}" -gt "8" ]
  then
  ## Debian 9+/MariaDB
    echo 'tango-db tango-db/dbconfig-install boolean true' | sudo debconf-set-selections
784 785
    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
786 787 788 789
  else
    ## Debian 8-/MySQL

    echo 'tango-db tango-db/dbconfig-install boolean true' | sudo debconf-set-selections
790 791
    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
792 793
  fi

794
  sudo apt-get install --assume-yes tango-db
795 796 797 798 799 800

fi




801

802
### Installation of TANGO base tools
803
if [ "${TANGO}" -eq "1" ]
804
then
805 806
  info "installation of TANGO base tools"
### Installation of Java
807
  sudo apt-get --assume-yes install oracle-java8-installer oracle-java8-set-default
808
  ## needed to replace OpenJDK by Oracle Java
809
  sudo apt-get install --assume-yes libxrender1 libxtst6
810

811

gauron's avatar
gauron committed
812
### configuration of TANGO
813