Create Post Install Setup authored by William Frischhertz's avatar William Frischhertz
This document will instruct the user on the post install setup of a Debian 10 Front-End computer used in a standalone test stand environment.
\*\*\*For this documentation, our front end computer will be named ‘x2fec’ \*\*\*
# Create 'controls' user and group
Log into the new front end as root. At the command line, type the following:
```plaintext
root@x2fec:/$ groupadd -g 1001 controls
root@x2fec:/$ useradd -u 1001 -s /bin/bash -m -g controls controls
root@x2fec:/$ passwd controls
```
Add 'controls' and 'cdsadmin' user to sudo group. Create /etc/sudoers.d/users with the following:
```plaintext
cdsadmin ALL=(ALL) NOPASSWD: ALL
controls ALL=(ALL) NOPASSWD: ALL
```
**_From this point on, we will be using the ‘controls’ user with sudo privileges to enter the commands. Commands will be entered into the command line and will be denoted with the prefix ‘controls@x2fec’_**
# Create CDS directories
```plaintext
controls@x2fec:/$ sudo mkdir /opt/cdscfg /opt/rtcds /opt/rtapps
controls@x2fec:/$ sudo chown -R controls:controls /opt/cdscfg /opt/rtcds /opt/rtapps
controls@x2fec:/$ sudo mkdir -p /frames/full /frames/trend /frames/trend/minute /frames/trend/minute_raw /frames/trend/second
```
# Setup CDS Repositories for Debian 10
Instructions for CDS repositories setup can be found [here](https://git.ligo.org/cds/software/advligorts/-/wikis/Enabling-Debian-CDS-Software-Repositories)
# Create site, ifo directories
This example is for the site 'tst' and ifo 'x2'. Substitute your own. Note the new directory will be under /opt/rtcds/.
```plaintext
controls@x2fec /opt/rtcds $ mkdir tst controls@x2fec /opt/rtcds $ mkdir tst/x2 controls@x2fec /opt/rtcds $ mkdir tst/x2/target controls@x2fec /opt/rtcds $ mkdir tst/x2/chans controls@x2fec /opt/rtcds $ mkdir tst/x2/chans/daq controls@x2fec /opt/rtcds $ mkdir tst/x2/log controls@x2fec /opt/rtcds $ mkdir tst/x2/scripts controls@x2fec /opt/rtcds $ mkdir tst/x2/chans/tmp controls@x2fec /opt/rtcds $ mkdir tst/x2/chans/ipc controls@x2fec /opt/rtcds $ mkdir tst/x2/rtbuild controls@x2fec /opt/rtcds $ mkdir tst/x2/medm controls@x2fec /opt/rtcds $ mkdir tst/x2/target/gds controls@x2fec /opt/rtcds $ mkdir tst/x2/target/gds/bin controls@x2fec /opt/rtcds $ mkdir tst/x2/target/gds/param
```
# Install Required Software
It is recommended to copy and paste the command below
```plaintext
controls@x2fec:/$ sudo apt-get install nfs-common nfs-kernel-server subversion ntpdate dkms build-essential cmake pkg-config psmisc linux-headers-$(uname -r) flex bison ldas-tools-al-dev ldas-tools-framecpp-dev libboost-all-dev git
```
# Setup NTP
The front-end needs to be synced to an NTP source. You need to know the address of the local NTP server. At the IFOs, this may be the core router.
Define server in /etc/ntp.conf. Examples are server ntp.ligo-la.caltech.edu server lesath.ligo.caltech.edu server ntp.stanford.edu Stop the service, get data initialized with ntpdate, and set it up to start on boot In Debian, stop the service
```plaintext
controls@x2fec $ sudo systemctl stop ntp
```
Now force time with ntpdate. For example
```plaintext
controls@x2fec $ sudo ntpdate ntp.ligo-la.caltech.edu 27 Apr 14:51:00 ntpdate[1445]: step time server 208.69.130.8 offset 291.169637 sec controls@x2fec $ sudo ntpdate ntp.ligo-la.caltech.edu 27 Apr 14:51:08 ntpdate[1446]: adjust time server 208.69.130.8 offset -0.000192 sec
```
Now start ntp back up.
```plaintext
controls@x2fec $ sudo systemctl start ntp
```
# Install CDS Environment
We want to install the CDS Environment (See T1000379 ). There is an installer in the 'cdscfg' repository. The example is for the LLO DAQ test stand. You will have your own site, ifo, network
# Install/Setup CDSCFG
We are now using git for this
```plaintext
controls@x2fec:/$ sudo mkdir -p /lib/local/teststand
controls@x2fec:/$ sudo chown controls:controls /lib/local/teststand
controls@x2fec:/$ cd /lib/local/teststand
controls@x2fec:/$ git clone ``https://git.ligo.org/cds/cdscfg.git`` ./cfg_fe.sh
Install FE CDS config at default: /opt/cdscfg\n
Must be a new install - please enter requested info
Enter 3-letter LIGO site code (i.e. lho, llo, tst): tst
Enter 2-letter LIGO ifo code (i.e. h2, l1, x1): x2
Enter EPICS network mask (i.e. 10.11.12.255, 10.144.0.255): 10.144.0.255
Enter NDS server name (i.e. h2nds0, l1nds0): x2fec
Enter default printer name [x2fec]:
Enter base apps folder [/opt/rtapps]:
Installing front-end config for tst/x2 net 10.144.0.255 nds x2fec
rm: cannot remove "site/`_`": No such file or directory
rm: cannot remove "ifo/`_`": No such file or directory
"/opt/cdscfg/tst/stddir.py.in" -> "/opt/cdscfg/tst/stddir.py"
"/opt/cdscfg/tst/stddir.pl.in" -> "/opt/cdscfg/tst/stddir.pl"
"/opt/cdscfg/tst/x2/stddir.sh.in" -> "/opt/cdscfg/tst/x2/stddir.sh"
"/opt/cdscfg/tst/x2/stddir.csh.in" -> "/opt/cdscfg/tst/x2/stddir.csh"
"/opt/cdscfg/tst/x2/rtrc.sh.in" -> "/opt/cdscfg/tst/x2/rtrc.sh"
"/opt/cdscfg/tst/x2/rtrc.csh.in" -> "/opt/cdscfg/tst/x2/rtrc.csh"
```
# Install advligorts packages, Setup RCG
**Option A** - Install from packages
If you will not be doing RCG code development, but you are using Debian 10 or later, just check out the package
```plaintext
controls@x2fec:/$ sudo apt-get install advligorts-rcg advligorts-cpu-isolator-dkms advligorts-daqd advligorts-transport-common advligorts-transport-pubsub
```
**Option B** - Install master from Git repository If you are going to do development, especially on Debian 8 and newer, use a git checkout Create the 'rtscore' directory for it and go to it
```plaintext
controls@x2fec $ cd /opt/rtcds
controls@x2fec /opt/rtcds $ mkdir rtscore
controls@x2fec /opt/rtcds $ cd rtscore
```
Now clone the repo
```plaintext
controls@x2fec /opt/rtcds/rtscore $ git clone https://git.ligo.org/cds/advligorts
controls@x2fec /opt/rtcds/rtscore $ ln -s advligorts release
```
You will also need to set the RCG_LIB_PATH environment variable for the controls user. This can be set in
```plaintext
/etc/advligorts/env
```
with the follwing addition.
```plaintext
export RCG_LIB_PATH=${USERAPPS_LIB_PATH:-$RCG_LIB_PATH}
```
Add the controls user to the advligorts group and vice versa
```plaintext
controls@x2fec:/ $ sudo usermod -a -G advligorts controls
controls@x2fec:/ $ sudo usermod -a -G controls advligorts
```
# Install userapps
Checkout trunk of cds_user_apps (this will take a long time) using Subversion
```plaintext
controls@x2fec /opt/rtcds/rtscore $ cd /opt/rtcds
controls@x2fec /opt/rtcds $ sudo mkdir userapps
controls@x2fec /opt/rtcds $ cd userapps
controls@x2fec /opt/rtcds/userapps $ svn co https://redoubt.ligo-wa.caltech.edu/svn/cds_user_apps/trunk
controls@x2fec /opt/rtcds/userapps $ sudo ln -s trunk release
```
# Install EPICS Base
We will get the Base and the perl scripts that go with it
```plaintext
controls@x2fec:\~$ sudo apt-get install epics-dev epics-perl epics-seq-dev epics-asyn-dev epics-modbus-dev medm striptool caqtdm epics-extensions-dev python-pyepics python-pcaspy python3-pyepics python3-pcaspy epics-pcas-dev
```
## Install ezca, add soft-links
To build the real-time models, you also need the EPICS ezca package. However, this currently installs a level down at '/usr/lib/epics/extensions', so we need to add soft-links at /usr/lib/epics directories
```plaintext
controls@x2fec:\~$ sudo apt install epics-ezca-dev
controls@x2fec:\~$ cd /usr/lib/epics
controls@x2fec:/usr/lib/epics$ cd include
controls@x2fec:/usr/lib/epics$ sudo ln -s ../extensions/include/ezca.h ezca.h
controls@x2fec:/usr/lib/epics$ cd ../lib/linux-x86_64
controls@x2fec:/usr/lib/epics$ sudo ln -s ../../extensions/lib/x86_64-linux-gnu/libezca.h libezca.h
controls@x2fec:/usr/lib/epics$ sudo ln -s ../../extensions/lib/x86_64-linux-gnu/libezca.so.3.15.3 libezca.so
```
# Install caRepeater service
We want to make sure caRepeater starts on boot. The file 'caRepeater.service' comes with EPICS base 3.15.5 and later. It needs to be customized to location of caRepeater. Create the file `/etc/systemd/system/caRepeater.service` with the following contents
```plaintext
#
# Linux systemd service file for the EPICS CA Repeater
#
# To install this file, as root:
# cp caRepeater.service /etc/systemd/system
# chmod 664 /etc/systemd/system/caRepeater.service
# systemctl daemon-reload
# systemctl enable caRepeater
# systemctl start caRepeater
#
# To check the status:
# systemctl status caRepeater
[Unit]
Description=EPICS CA Repeater
Requires=network.target
After=network.target
[Service]
ExecStart=/usr/bin/caRepeater
Restart=always
User=daemon
[Install]
WantedBy=multi-user.target
```
After creating the file in the above directory, complete the install by enabling the service to start at boot and starting the service now.
```plaintext
controls@x2fec:\~# sudo chmod 664 /etc/systemd/system/caRepeater.service
controls@x2fec:\~# sudo systemctl daemon-reload
controls@x2fec:\~# sudo systemctl enable --now caRepeater
Created symlink from /etc/systemd/system/multi-user.target.wants/caRepeater.service to /etc/systemd/system/caRepeater.service.
```
# CPU isolation
[Instructions](https://git.ligo.org/cds/software/advligorts/-/wikis/CPU-Isolation)
# Final housekeeping
To ensure we have the correct read and write permissions, perform the following commands
```plaintext
controls@x2fec:/$ sudo chown -R advligorts:advligorts /frames/
controls@x2fec:/$ sudo chown -R controls:advligorts /opt/rtcds/tst/
controls@x2fec:/$ sudo chmod -R 0774 /opt/rtcds/tst/x2/
```
\ No newline at end of file