<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://daq00.triumf.ca/DaqWiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dfujimoto</id>
	<title>DaqWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://daq00.triumf.ca/DaqWiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dfujimoto"/>
	<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php/Special:Contributions/Dfujimoto"/>
	<updated>2026-09-10T15:21:08Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9258</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9258"/>
		<updated>2026-08-19T18:57:55Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Machines */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| ucnsrv1-vm&lt;br /&gt;
| Elog Host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/epics2midas.git&lt;br /&gt;
cd epics2midas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, edit &amp;lt;code&amp;gt;epics_fe.h&amp;lt;/code&amp;gt; to have the following equipment list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// bank names - length must match length of equipment array below&lt;br /&gt;
std::vector&amp;lt;std::string&amp;gt; bank_names = { &amp;quot;EBML&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ECRY&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE3&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE4&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EISO&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ELD2&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESCM&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESER&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EUGD&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EVAC&amp;quot;,&lt;br /&gt;
                                    }; &lt;br /&gt;
&lt;br /&gt;
// equipment settings&lt;br /&gt;
EQUIPMENT equipment[] = {&lt;br /&gt;
   &lt;br /&gt;
    // EQUIPMENT template. Name needs to be changed in two places, the next line and in the readout routine&lt;br /&gt;
    {&amp;quot;EpicsBEAMLINE&amp;quot;,              /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1000, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsBEAMLINE&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsCRY&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1001, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsCRY&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE3&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1002, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE3&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE4&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1003, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE4&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsISO&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1004, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsISO&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsLD2&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1005, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsLD2&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSCM&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1006, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSCM&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSER&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1007, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSER&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsUGD&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1008, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsUGD&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsVAC&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1009, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsVAC&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
   {&amp;quot;&amp;quot;} // to tell mfe about the end of the array&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then make and run the frontend to populate the equipments&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
./epics_fe&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we populate with the variables&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tuncn01&lt;br /&gt;
git clone git@github.com:ucn-triumf/epics_pvs.git&lt;br /&gt;
cd epics_pvs&lt;br /&gt;
python3 -c &amp;quot;import pv_equipments; pv_equipments.set_odb()&amp;quot;  # push to the ODB&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before anything can be read, one needs to contact controls group to give read permissions to the machine.&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/shiftschedule.git&lt;br /&gt;
cd shiftschedule&lt;br /&gt;
./setup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then navigate to the shift scheduler page and add users as needed&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9248</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9248"/>
		<updated>2026-08-10T18:28:18Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* EPICS2MIDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/epics2midas.git&lt;br /&gt;
cd epics2midas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, edit &amp;lt;code&amp;gt;epics_fe.h&amp;lt;/code&amp;gt; to have the following equipment list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// bank names - length must match length of equipment array below&lt;br /&gt;
std::vector&amp;lt;std::string&amp;gt; bank_names = { &amp;quot;EBML&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ECRY&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE3&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE4&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EISO&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ELD2&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESCM&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESER&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EUGD&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EVAC&amp;quot;,&lt;br /&gt;
                                    }; &lt;br /&gt;
&lt;br /&gt;
// equipment settings&lt;br /&gt;
EQUIPMENT equipment[] = {&lt;br /&gt;
   &lt;br /&gt;
    // EQUIPMENT template. Name needs to be changed in two places, the next line and in the readout routine&lt;br /&gt;
    {&amp;quot;EpicsBEAMLINE&amp;quot;,              /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1000, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsBEAMLINE&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsCRY&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1001, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsCRY&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE3&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1002, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE3&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE4&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1003, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE4&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsISO&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1004, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsISO&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsLD2&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1005, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsLD2&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSCM&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1006, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSCM&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSER&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1007, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSER&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsUGD&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1008, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsUGD&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsVAC&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1009, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsVAC&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
   {&amp;quot;&amp;quot;} // to tell mfe about the end of the array&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then make and run the frontend to populate the equipments&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
./epics_fe&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we populate with the variables&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tuncn01&lt;br /&gt;
git clone git@github.com:ucn-triumf/epics_pvs.git&lt;br /&gt;
cd epics_pvs&lt;br /&gt;
python3 -c &amp;quot;import pv_equipments; pv_equipments.set_odb()&amp;quot;  # push to the ODB&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before anything can be read, one needs to contact controls group to give read permissions to the machine.&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/shiftschedule.git&lt;br /&gt;
cd shiftschedule&lt;br /&gt;
./setup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then navigate to the shift scheduler page and add users as needed&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9247</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9247"/>
		<updated>2026-08-10T17:26:21Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* EPICS2MIDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/epics2midas.git&lt;br /&gt;
cd epics2midas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, edit &amp;lt;code&amp;gt;epics_fe.h&amp;lt;/code&amp;gt; to have the following equipment list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// bank names - length must match length of equipment array below&lt;br /&gt;
std::vector&amp;lt;std::string&amp;gt; bank_names = { &amp;quot;EBML&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ECRY&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE3&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE4&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EISO&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ELD2&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESCM&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESER&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EUGD&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EVAC&amp;quot;,&lt;br /&gt;
                                    }; &lt;br /&gt;
&lt;br /&gt;
// equipment settings&lt;br /&gt;
EQUIPMENT equipment[] = {&lt;br /&gt;
   &lt;br /&gt;
    // EQUIPMENT template. Name needs to be changed in two places, the next line and in the readout routine&lt;br /&gt;
    {&amp;quot;EpicsBEAMLINE&amp;quot;,              /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1000, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsBEAMLINE&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsCRY&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1001, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsCRY&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE3&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1002, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE3&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE4&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1003, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE4&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsISO&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1004, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsISO&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsLD2&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1005, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsLD2&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSCM&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1006, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSCM&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSER&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1007, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSER&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsUGD&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1008, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsUGD&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsVAC&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1009, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsVAC&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
   {&amp;quot;&amp;quot;} // to tell mfe about the end of the array&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then make and run the frontend to populate the equipments&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
./epics_fe&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we populate with the variables&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tuncn01&lt;br /&gt;
git clone git@github.com:ucn-triumf/epics_pvs.git&lt;br /&gt;
cd epics_pvs&lt;br /&gt;
python3 -c &amp;quot;import pv_equipments; pv_equipments.set_odb()&amp;quot;  # push to the ODB&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/shiftschedule.git&lt;br /&gt;
cd shiftschedule&lt;br /&gt;
./setup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then navigate to the shift scheduler page and add users as needed&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9246</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9246"/>
		<updated>2026-08-08T02:07:02Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* EPICS2MIDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/epics2midas.git&lt;br /&gt;
cd epics2midas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, edit &amp;lt;code&amp;gt;epics_fe.h&amp;lt;/code&amp;gt; to have the following equipment list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// bank names - length must match length of equipment array below&lt;br /&gt;
std::vector&amp;lt;std::string&amp;gt; bank_names = { &amp;quot;EBML&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ECRY&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE3&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE4&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EISO&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ELD2&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESCM&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESER&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EUDG&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EVAC&amp;quot;,&lt;br /&gt;
                                    }; &lt;br /&gt;
&lt;br /&gt;
// equipment settings&lt;br /&gt;
EQUIPMENT equipment[] = {&lt;br /&gt;
   &lt;br /&gt;
    // EQUIPMENT template. Name needs to be changed in two places, the next line and in the readout routine&lt;br /&gt;
    {&amp;quot;EpicsBEAMLINE&amp;quot;,              /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1000, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsBEAMLINE&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsCRY&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1001, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsCRY&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE3&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1002, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE3&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE4&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1003, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE4&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsISO&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1004, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsISO&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsLD2&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1005, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsLD2&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSCM&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1006, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSCM&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSER&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1007, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSER&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsUDG&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1008, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsUDG&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsVAC&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1009, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsVAC&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
   {&amp;quot;&amp;quot;} // to tell mfe about the end of the array&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then make and run the frontend to populate the equipments&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
./epics_fe&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we populate with the variables&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tuncn01&lt;br /&gt;
git clone git@github.com:ucn-triumf/epics_pvs.git&lt;br /&gt;
cd epics_pvs&lt;br /&gt;
python3 -c &amp;quot;import pv_equipments; pv_equipments.set_odb()&amp;quot;  # push to the ODB&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/shiftschedule.git&lt;br /&gt;
cd shiftschedule&lt;br /&gt;
./setup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then navigate to the shift scheduler page and add users as needed&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9245</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9245"/>
		<updated>2026-08-08T01:39:55Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* EPICS2MIDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/epics2midas.git&lt;br /&gt;
cd epics2midas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, edit &amp;lt;code&amp;gt;epics_fe.h&amp;lt;/code&amp;gt; to have the following equipment list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// bank names - length must match length of equipment array below&lt;br /&gt;
std::vector&amp;lt;std::string&amp;gt; bank_names = { &amp;quot;EBML&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ECRY&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE3&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE4&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EISO&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ELD2&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESCM&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESER&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EUDG&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EVAC&amp;quot;,&lt;br /&gt;
                                    }; &lt;br /&gt;
&lt;br /&gt;
// equipment settings&lt;br /&gt;
EQUIPMENT equipment[] = {&lt;br /&gt;
   &lt;br /&gt;
    // EQUIPMENT template. Name needs to be changed in two places, the next line and in the readout routine&lt;br /&gt;
    {&amp;quot;EpicsBEAMLINE&amp;quot;,              /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1000, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsBEAMLINE&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsCRY&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1001, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsCRY&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE3&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1002, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE3&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE4&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1003, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE4&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsISO&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1004, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsISO&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsLD2&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1005, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsLD2&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSCM&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1006, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSCM&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSER&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1007, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSER&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsUDG&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1008, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsUDG&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsVAC&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1009, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsVAC&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
   {&amp;quot;&amp;quot;} // to tell mfe about the end of the array&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then make and run the frontend to populate the equipments&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
./epics_fe&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we populate with the variables&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tuncn01&lt;br /&gt;
git clone git@github.com:ucn-triumf/epics_pvs.git&lt;br /&gt;
python -c &amp;quot;import pv_equipments; pv_equipments.set_odb()&amp;quot;  # push to the ODB&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/shiftschedule.git&lt;br /&gt;
cd shiftschedule&lt;br /&gt;
./setup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then navigate to the shift scheduler page and add users as needed&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9243</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9243"/>
		<updated>2026-08-08T00:13:14Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* EPICS2MIDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/epics2midas.git&lt;br /&gt;
cd epics2midas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, edit &amp;lt;code&amp;gt;epics_fe.h&amp;lt;/code&amp;gt; to have the following equipment list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// bank names - length must match length of equipment array below&lt;br /&gt;
std::vector&amp;lt;std::string&amp;gt; bank_names = { &amp;quot;EBML&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ECRY&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE3&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EHE4&amp;quot;, &lt;br /&gt;
                                        &amp;quot;EISO&amp;quot;, &lt;br /&gt;
                                        &amp;quot;ELD2&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESCM&amp;quot;,&lt;br /&gt;
                                        &amp;quot;ESER&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EUDG&amp;quot;,&lt;br /&gt;
                                        &amp;quot;EVAC&amp;quot;,&lt;br /&gt;
                                    }; &lt;br /&gt;
&lt;br /&gt;
// equipment settings&lt;br /&gt;
EQUIPMENT equipment[] = {&lt;br /&gt;
   &lt;br /&gt;
    // EQUIPMENT template. Name needs to be changed in two places, the next line and in the readout routine&lt;br /&gt;
    {&amp;quot;EpicsBEAMLINE&amp;quot;,              /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1000, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsBEAMLINE&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsCRY&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1001, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsCRY&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE3&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1002, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE3&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsHE4&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1003, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsHE4&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsISO&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1004, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsISO&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsLD2&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1005, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsLD2&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSCM&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1006, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSCM&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsSER&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1007, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsSER&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsUDG&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1008, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsUDG&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
    {&amp;quot;EpicsVAC&amp;quot;,                   /* equipment name */&lt;br /&gt;
     // EQUIPMENT_INFO object&lt;br /&gt;
     {  1009, 0,                   /* event ID, trigger mask */&lt;br /&gt;
        &amp;quot;SYSTEM&amp;quot;,                  /* event buffer */&lt;br /&gt;
        EQ_PERIODIC,               /* equipment type */&lt;br /&gt;
        0,                         /* event source */&lt;br /&gt;
        &amp;quot;MIDAS&amp;quot;,                   /* format */&lt;br /&gt;
        TRUE,                      /* enabled */&lt;br /&gt;
        RO_ALWAYS,                 /* run always */&lt;br /&gt;
        1000,                      /* read event every 1 sec */&lt;br /&gt;
        0,                         /* readout pause */&lt;br /&gt;
        0,                         /* number of sub events */&lt;br /&gt;
        10,                        /* log history every 10 seconds */&lt;br /&gt;
    },&lt;br /&gt;
    [](char *pevent, INT off)-&amp;gt;INT{return epics_equipment[&amp;quot;EpicsVAC&amp;quot;]-&amp;gt;read(pevent);}, // readout routine&lt;br /&gt;
   },&lt;br /&gt;
   {&amp;quot;&amp;quot;} // to tell mfe about the end of the array&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/shiftschedule.git&lt;br /&gt;
cd shiftschedule&lt;br /&gt;
./setup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then navigate to the shift scheduler page and add users as needed&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9242</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9242"/>
		<updated>2026-08-07T23:44:23Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* shift scheduler */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@bitbucket.org:ttriumfdaq/shiftschedule.git&lt;br /&gt;
cd shiftschedule&lt;br /&gt;
./setup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then navigate to the shift scheduler page and add users as needed&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9237</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9237"/>
		<updated>2026-07-30T00:36:51Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* ucn_detector_analyzer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn_detector_analyzer.git&lt;br /&gt;
cd ucn_detector_analyzer/&lt;br /&gt;
git checkout 2025&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9236</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9236"/>
		<updated>2026-07-30T00:18:04Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup ODB Basics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&lt;br /&gt;
set /Programs/Logger/Required y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9235</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9235"/>
		<updated>2026-07-30T00:17:02Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* sequencer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_ucnsequencer26/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_ucnsequencer26/Start command&#039; /home/ucn/online_tucan01/sequence-control/start_sequencer.bash&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9234</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9234"/>
		<updated>2026-07-30T00:15:25Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* liquifier production */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/liquid_production.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/liquid_production/ ucn-web-control/liquid_production&lt;br /&gt;
cd liquid_production&lt;br /&gt;
&lt;br /&gt;
mkdir ~/.config/python_keyring/&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; ~/.config/python_keyring/keyringrc.cfg&lt;br /&gt;
[backend]&lt;br /&gt;
default-keyring=keyrings.alt.file.PlaintextKeyring&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# setup keyring&lt;br /&gt;
source .venv/bin/activate&lt;br /&gt;
python3&lt;br /&gt;
import keyring&lt;br /&gt;
keyring.set_password(&amp;quot;ucn_history&amp;quot;, &amp;quot;ucn_reader&amp;quot;, password) # replace password with that in ~/online_tucan01/ucn_reader.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then exit python and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./start_liquidprod.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/liquidprod/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/liquidprod/Start command&#039; /home/ucn/online_tucan01/liquid_production/start_liquidprod.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9233</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9233"/>
		<updated>2026-07-29T22:01:35Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* sequencer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/sequence-control.git&lt;br /&gt;
cd sequence-control&lt;br /&gt;
git checkout 2026 # as of this writing, the new sequencer has yet to be merged into the main branch&lt;br /&gt;
./start_sequencer.bash&lt;br /&gt;
Ctrl-C&lt;br /&gt;
cd /home/ucn/online_tucan01/ucn-web-control/&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control ./sequencer-control&lt;br /&gt;
ln -s /home/ucn/online_tucan01/sequence-control/sequencer26.html ./sequencer26.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9232</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9232"/>
		<updated>2026-07-29T21:49:42Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* ucn_alarm classes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt; to set up the shared virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9231</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9231"/>
		<updated>2026-07-29T21:49:25Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* ucn_alarm classes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Next, execute &amp;lt;code&amp;gt;setup_venv.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9230</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9230"/>
		<updated>2026-07-29T21:47:39Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* ucn_alarms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarm classes ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-alarms-notification.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then write the following file as &amp;lt;code&amp;gt;setup_alarm_classes.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Alarms/Classes&lt;br /&gt;
set &amp;quot;Alarm/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/Alarm.sh&lt;br /&gt;
set &amp;quot;Alarm/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;Warning/Execute command&amp;quot; /home/ucn/online_tucan01/ucn-alarms-notification/bird_schedule.sh&lt;br /&gt;
set &amp;quot;Warning/Execute interval&amp;quot; 180&lt;br /&gt;
&lt;br /&gt;
copy Warning Notification&lt;br /&gt;
set &amp;quot;Notification/Execute command&amp;quot; &amp;quot;&amp;quot;&lt;br /&gt;
set &amp;quot;Notification/Execute interval&amp;quot; 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and execute as &amp;lt;code&amp;gt;obedit -c @setup_alarm_classes.odb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9229</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9229"/>
		<updated>2026-07-29T21:27:26Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install Packages and Custom Pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== liquifier production ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9228</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9228"/>
		<updated>2026-07-29T21:26:26Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install Packages and Custom Pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9227</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9227"/>
		<updated>2026-07-29T21:25:14Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* autostat */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
ln -s /home/ucn/online_tucan01/autostat/web/autostat.html ucn-web-control/autostat.html&lt;br /&gt;
cd autostat/bin&lt;br /&gt;
./start_fe_autostat_pid.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
./start_fe_autostat_script.sh&lt;br /&gt;
Ctrl-C&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_pid/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_pid.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_pid/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set /Programs/fe_autostat_script/Required y&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Start command&#039; /home/ucn/online_tucan01/autostat/bin/start_fe_autostat_script.sh&amp;quot;&lt;br /&gt;
odbedit -c &amp;quot;set &#039;/Programs/fe_autostat_script/Alarm class&#039; Warning&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that one should take care that the PID settings are copied over correctly.&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9226</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9226"/>
		<updated>2026-07-29T19:35:52Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* custom pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
Here we set up the custom pages that don&#039;t require too much backend. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;. Note that not all of the pages exist in the cloned repo, and will be added in the following sections.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd Custom&lt;br /&gt;
create STRING Path[1][256]&lt;br /&gt;
set Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&lt;br /&gt;
create STRING Autostat[1][256]&lt;br /&gt;
set Autostat autostat.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Liquifier Production[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Liquifier Production&amp;quot; liquid_production/liquid_prod_rate.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Online Display[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Online Display&amp;quot; generic_webdisplay_embed.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Phone Notify[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Phone Notify&amp;quot; setonshift.html&lt;br /&gt;
&lt;br /&gt;
create STRING QuickLinks[1][256]&lt;br /&gt;
set QuickLinks quicklinks.html&lt;br /&gt;
&lt;br /&gt;
create STRING Sequencer[1][256]&lt;br /&gt;
set Sequencer sequencer26.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Goals[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Goals&amp;quot; shift_goals.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Shift Schedule[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Shift Schedule&amp;quot; shiftschedule.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;Source Manual[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;Source Manual&amp;quot; manual2_redirect.html&lt;br /&gt;
&lt;br /&gt;
create STRING &amp;quot;UCN Counts[1][256]&amp;quot;&lt;br /&gt;
set &amp;quot;UCN Counts&amp;quot; analyzer.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UNFINISHED&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9225</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9225"/>
		<updated>2026-07-29T18:26:52Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install Packages and Custom Pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/ucn-web-control.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the following file as &amp;lt;code&amp;gt;setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create STRING /Custom/Path[1][256]&lt;br /&gt;
set /Custom/Path /home/ucn/online_tucan01/ucn-web-control&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run it as &amp;lt;code&amp;gt;odbedit -c @setup_custompages.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UNFINISHED&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UNFINISHED&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9224</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9224"/>
		<updated>2026-07-29T18:22:10Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* autostat */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home1/ucn/online_tucan01&lt;br /&gt;
git clone git@github.com:ucn-triumf/autostat.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9223</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9223"/>
		<updated>2026-07-29T18:02:05Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install ubuntu 24 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here], edit &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;, then do &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/ssh reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9222</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9222"/>
		<updated>2026-07-29T17:59:41Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Set up git credential passing === &lt;br /&gt;
&lt;br /&gt;
Follow the instructions [https://daq00.triumf.ca/elog-daq/DAS/1259%7C here]&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9221</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9221"/>
		<updated>2026-07-29T17:58:43Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install Packages and Custom Pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
UCN-specific packages and custom pages&lt;br /&gt;
&lt;br /&gt;
==== autostat ====&lt;br /&gt;
&lt;br /&gt;
==== EPICS2MIDAS ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_detector_analyzer ====&lt;br /&gt;
&lt;br /&gt;
==== ucn_alarms ====&lt;br /&gt;
&lt;br /&gt;
==== custom pages ====&lt;br /&gt;
&lt;br /&gt;
==== shift scheduler ====&lt;br /&gt;
&lt;br /&gt;
==== sequencer ====&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9220</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9220"/>
		<updated>2026-07-29T17:55:09Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Mount /data3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it as a remote drive. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file.&lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9219</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9219"/>
		<updated>2026-07-29T17:54:48Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
mkdir /Custom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mount /data3 ===&lt;br /&gt;
&lt;br /&gt;
Eventually this will have to be a drive directly on this machine, but for now let&#039;s just mount it. &lt;br /&gt;
&lt;br /&gt;
Add the following line to &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
daq01.ucn.triumf.ca:/data3 /data3 nfs async,rw,auto,nouser,nosuid,noexec,_netdev,nofail,noatime,actimeo=120 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then do the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir /data3&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo mount -a # mount everything in fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this will have both versions of midas writing to the same midas log file. &lt;br /&gt;
&lt;br /&gt;
=== Install Packages and Custom Pages ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9217</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9217"/>
		<updated>2026-07-27T21:14:08Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup ODB Basics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/FILE/Active&amp;quot; n&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Writer&amp;quot; ucn_writer.txt&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/MYSQL Reader&amp;quot; ucn_reader.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9216</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9216"/>
		<updated>2026-07-27T21:10:18Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup ODB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB Basics ===&lt;br /&gt;
&lt;br /&gt;
Resize the ODB structure: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
odbedit -c &amp;quot;shutdown all&amp;quot;&lt;br /&gt;
odbinit --cleanup -s 100000000;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the logger for the first time&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mlogger&lt;br /&gt;
Ctrl-C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the following to a file called &amp;quot;odbsetup.odb&amp;quot; and run as &amp;lt;code&amp;gt;odbedit -c @odbsetup.odb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /Experiment&lt;br /&gt;
set &amp;quot;Pause-Resume Buttons&amp;quot; n&lt;br /&gt;
&lt;br /&gt;
cd /Experiment/Menu&lt;br /&gt;
set Status          y&lt;br /&gt;
set Start           n&lt;br /&gt;
set Transition      y&lt;br /&gt;
set ODB             y&lt;br /&gt;
set Messages        y&lt;br /&gt;
set Chat            n&lt;br /&gt;
set Elog            y&lt;br /&gt;
set Alarms          y&lt;br /&gt;
set Programs        y&lt;br /&gt;
set History         y&lt;br /&gt;
set MSCB            n&lt;br /&gt;
set Sequencer       n&lt;br /&gt;
set Config          y&lt;br /&gt;
set Example         n&lt;br /&gt;
set Help            y&lt;br /&gt;
set Buffers         y&lt;br /&gt;
set OldHistory      y&lt;br /&gt;
set &amp;quot;Event Dump&amp;quot;    n&lt;br /&gt;
set OldODB          n&lt;br /&gt;
set PySequencer     n&lt;br /&gt;
&lt;br /&gt;
mkdir &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
cd &amp;quot;/Experiment/Edit on start&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Run Title&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Experiment number&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Shifters&amp;quot;[256]&lt;br /&gt;
create STRING &amp;quot;Comment&amp;quot;[256]&lt;br /&gt;
ln /Logger/Channels/0/Settings/Active &amp;quot;write data&amp;quot;&lt;br /&gt;
create BOOL &amp;quot;run with sequencer&amp;quot;&lt;br /&gt;
create STRING &amp;quot;end_of_run_comment&amp;quot;[256]&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Experiment/Security/Enable non-localhost RPC&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Experiment/Security/RPC hosts&amp;quot;&lt;br /&gt;
rm -f &amp;quot;Allowed hosts&amp;quot;&lt;br /&gt;
create STRING &amp;quot;Allowed hosts&amp;quot;[30][256]&lt;br /&gt;
set &amp;quot;Allowed hosts[0]&amp;quot;  localhost&lt;br /&gt;
set &amp;quot;Allowed hosts[1]&amp;quot;  daq01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[2]&amp;quot;  daq02.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[3]&amp;quot;  daq03.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[4]&amp;quot;  daq12.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[5]&amp;quot;  ucn-ktm01.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[6]&amp;quot;  lxdaq13.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[7]&amp;quot;  lxdaq22.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[8]&amp;quot;  lxdaq27.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[9]&amp;quot;  cb01.ucn.triumf.ca&lt;br /&gt;
set &amp;quot;Allowed hosts[10]&amp;quot; ktm-readout.triumf.ca&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Logger&amp;quot;&lt;br /&gt;
set &amp;quot;Data dir&amp;quot; /data3/ucn/midas_files&lt;br /&gt;
set &amp;quot;ODB Dump&amp;quot; y&lt;br /&gt;
&lt;br /&gt;
set &amp;quot;/Runinfo/Run number&amp;quot; 3320&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;/Elog&amp;quot;&lt;br /&gt;
set URL https://ucnelog.triumf.ca/elog/&lt;br /&gt;
set &amp;quot;External Elog&amp;quot; y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9215</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9215"/>
		<updated>2026-07-27T19:44:53Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
=== Setup ODB ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9214</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9214"/>
		<updated>2026-07-27T19:42:10Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install and Configure APACHE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set web password: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo htpasswd -c /etc/apache2/htpasswd ucn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the same password as the old setup.&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9213</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9213"/>
		<updated>2026-07-24T23:56:23Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install and Configure APACHE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following as root to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as root&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next comment out the line &amp;lt;code&amp;gt;Listen 80&amp;lt;/code&amp;gt; in the file &amp;lt;code&amp;gt;/etc/apache2/ports.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to enable the SSL module and new configurations: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod ssl&lt;br /&gt;
sudo a2enmod headers&lt;br /&gt;
sudo a2enmod proxy&lt;br /&gt;
sudo a2enmod proxy_http&lt;br /&gt;
sudo a2enconf ssl-tucan01&lt;br /&gt;
sudo a2ensite tucan01-ssl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disable default ssl sites: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2dissite default-ssl&lt;br /&gt;
sudo a2dissite 000-default&lt;br /&gt;
ls -l /etc/apache2/sites-enabled/ ### should show only tucan01-ssl.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, setup certificates following the instructions [https://daq00.triumf.ca/DaqWiki/index.php/SSLCertificates_Infoblox here]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01/&lt;br /&gt;
git clone https://gitlab.triumf.ca/ist/util/certbot-infoblox.git&lt;br /&gt;
cd certbot-infoblox&lt;br /&gt;
sudo ./certbot_infoblox_installer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the password and username. This will be the same for any webhost on the ucn subnet, so look at another machine to get the info (e.g. daq06.ucn) or ask IT. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo vim /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the certificate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /opt/certbot/venv/bin/certbot certonly --noninteractive --agree-tos --authenticator dns-infoblox --email letsencrypt@ucn.triumf.ca --domain tucan01.ucn.triumf.ca --renew-hook &#039;systemctl restart apache2&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the password file to have stronger permissions, prevent read from unauthorized persons: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 600 /etc/letsencrypt/infoblox.ini &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check apache syntax is ok&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart apache server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9212</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9212"/>
		<updated>2026-07-24T23:34:22Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install and Configure APACHE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/conf-available/ssl-tucan01.conf&lt;br /&gt;
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)&lt;br /&gt;
SSLSessionCacheTimeout  300&lt;br /&gt;
SSLRandomSeed startup file:/dev/urandom  256&lt;br /&gt;
SSLRandomSeed connect builtin&lt;br /&gt;
SSLCryptoDevice builtin&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create the site: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/apache2/sites-available/tucan01-ssl.conf&lt;br /&gt;
&amp;lt;IfModule mod_ssl.c&amp;gt;&lt;br /&gt;
    &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
        ServerName tucan01.ucn.triumf.ca&lt;br /&gt;
                SSLCertificateFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/cert.pem&lt;br /&gt;
                SSLCertificateKeyFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/privkey.pem&lt;br /&gt;
                SSLCertificateChainFile /etc/letsencrypt/live/tucan01.ucn.triumf.ca/chain.pem&lt;br /&gt;
        DocumentRoot /var/www/html&lt;br /&gt;
        ErrorLog /var/log/apache2/tucan01.ucn.log&lt;br /&gt;
        SSLEngine on&lt;br /&gt;
        # note SSLProtocol, SSLCipherSuite and some other settings are overwritten by /etc/letsencrypt/options-ssl-apache.conf&lt;br /&gt;
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4&lt;br /&gt;
        ## use port specified in elogd.cfg&lt;br /&gt;
        #ProxyPass /elog/ http://localhost:8082/ retry=1 &lt;br /&gt;
        ## use mhttpd port&lt;br /&gt;
        ProxyPass /      http://localhost:8080/ retry=1 &lt;br /&gt;
        Header always set Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        &amp;lt;Location /&amp;gt;&lt;br /&gt;
            SSLRequireSSL&lt;br /&gt;
            AuthType Basic&lt;br /&gt;
            AuthName &amp;quot;DAQ password protected site&amp;quot;&lt;br /&gt;
            Require valid-user&lt;br /&gt;
            # create password file: touch /etc/apache2/htpasswd&lt;br /&gt;
            # to add new user or change password: htpasswd /etc/apache2/htpasswd username&lt;br /&gt;
            AuthUserFile /etc/apache2/htpasswd&lt;br /&gt;
        &amp;lt;/Location&amp;gt;&lt;br /&gt;
    &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9211</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9211"/>
		<updated>2026-07-24T23:29:48Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install and Configure APACHE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions on the MIDAS wiki [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
cd /etc/apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following to create new configuration file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9210</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9210"/>
		<updated>2026-07-24T23:26:19Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* DAQ Software and Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine. The context for this installation is as follows: &lt;br /&gt;
&lt;br /&gt;
* daq01.ucn.triumf.ca is already running midas successfully &lt;br /&gt;
* we want to move operation to tucan01.ucn.triumf.ca&lt;br /&gt;
* both machines are sharing the same mounted home directory&lt;br /&gt;
* we want as little downtime as possible, thus during setup, daq01.ucn should keep running while tucan01 is being set up.  &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9209</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9209"/>
		<updated>2026-07-24T23:24:22Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* DAQ Software and Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
mkdir epics&lt;br /&gt;
cd epics&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install and Configure APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9208</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9208"/>
		<updated>2026-07-24T23:03:30Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install ROOTANA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
Inside &amp;lt;code&amp;gt;~/packages_tucan01&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup online directory ====&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
Many of the UCN analysis codes still rely on ROOTANA.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9207</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9207"/>
		<updated>2026-07-24T23:02:50Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install MIDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
Inside &amp;lt;code&amp;gt;~/packages_tucan01&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set exptab ==== &lt;br /&gt;
&lt;br /&gt;
Run the following: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;ucn /home/ucn/online_tucan01 ucn&amp;quot; &amp;gt; /home/ucn/online_tucan01/exptab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup online directory ====&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
Many of the UCN analysis codes still rely on ROOTANA.&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9206</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9206"/>
		<updated>2026-07-24T22:58:34Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup Environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
Inside &amp;lt;code&amp;gt;~/packages_tucan01&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
cp .bashrc .bashrc_tucan01&lt;br /&gt;
cp .bashrc .bashrc_daq01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then &#039;&#039;&#039;replace&#039;&#039;&#039; .bashrc with the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
# switching for tucan01 development&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
    . ~/.bashrc_tucan01&lt;br /&gt;
else&lt;br /&gt;
    . ~/.bashrc_daq01&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
The new .bashrc_tucan01 file will have the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
packages=/home/ucn/packages_tucan01&lt;br /&gt;
online=/home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# Source global definitions&lt;br /&gt;
if [ -f /etc/bashrc ]; then&lt;br /&gt;
    . /etc/bashrc&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# User specific aliases and functions&lt;br /&gt;
if [ -f ~/.bash_aliases ]; then&lt;br /&gt;
    . ~/.bash_aliases&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# midas server host&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=tucan01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# set a fancy prompt (non-color, unless we know we &amp;quot;want&amp;quot; color)&lt;br /&gt;
case &amp;quot;$TERM&amp;quot; in&lt;br /&gt;
    xterm-color|*-256color) color_prompt=yes;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# pick up executables from $MIDASSYS/linux/bin&lt;br /&gt;
export MIDASSYS=$packages/midas&lt;br /&gt;
export MIDAS_EXPTAB=$online/exptab&lt;br /&gt;
export ROOTANASYS=$packages/rootana&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Setup online directory ==== &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
Many of the UCN analysis codes still rely on ROOTANA.&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9205</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9205"/>
		<updated>2026-07-24T22:50:47Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* DAQ Software and Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
Inside &amp;lt;code&amp;gt;~/packages_tucan01&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setup Environment  ===&lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
   ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
   centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
   *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then make a copy of .bashrc for tucan01 use and one preserved for all other machines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
==== Set environment variables ==== &lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# this later needs changing for the final switch to tucan01&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == daq01.ucn.triumf.ca ] || [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ] ; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=daq01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ] ; then&lt;br /&gt;
   export MIDASSYS=/home/ucn/packages_tucan01/midas&lt;br /&gt;
   export MIDAS_EXPTAB=/home/ucn/online_tucan01/exptab&lt;br /&gt;
   export ROOTANASYS=/home/ucn/packages_tucan01/rootana&lt;br /&gt;
else&lt;br /&gt;
   export MIDASSYS=/home/ucn/packages/midas&lt;br /&gt;
   export MIDAS_EXPTAB=/home/ucn/online/exptab&lt;br /&gt;
   export ROOTANASYS=/home/ucn/packages/rootana&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we add the following lines at the top of .bashrc: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ]; then&lt;br /&gt;
     . ~/.bashrc_tucan01;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus we switch over to the new .bashrc_tucan01 file in the case of the new machine, and the new machine only. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The new file will have the following contents: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Setup online directory ==== &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
Many of the UCN analysis codes still rely on ROOTANA.&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9204</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9204"/>
		<updated>2026-07-24T22:34:57Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Set environment variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
Inside &amp;lt;code&amp;gt;~/packages_tucan01&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Setup online directory ==== &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
Many of the UCN analysis codes still rely on ROOTANA.&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9203</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9203"/>
		<updated>2026-07-24T22:34:41Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install EPICS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
Inside &amp;lt;code&amp;gt;~/packages_tucan01&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz&lt;br /&gt;
tar -xvf base-7.0.8.1.tar.gz&lt;br /&gt;
cd base-7.0.8.1&lt;br /&gt;
make&lt;br /&gt;
rm ../base-7.0.8.1.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set environment variables ==== &lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# this later needs changing for the final switch to tucan01&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == daq01.ucn.triumf.ca ] || [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ] ; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=daq01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ] ; then&lt;br /&gt;
   export MIDASSYS=/home/ucn/packages_tucan01/midas&lt;br /&gt;
   export MIDAS_EXPTAB=/home/ucn/online_tucan01/exptab&lt;br /&gt;
   export ROOTANASYS=/home/ucn/packages_tucan01/rootana&lt;br /&gt;
else&lt;br /&gt;
   export MIDASSYS=/home/ucn/packages/midas&lt;br /&gt;
   export MIDAS_EXPTAB=/home/ucn/online/exptab&lt;br /&gt;
   export ROOTANASYS=/home/ucn/packages/rootana&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Setup online directory ==== &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
Many of the UCN analysis codes still rely on ROOTANA.&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9202</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9202"/>
		<updated>2026-07-24T22:30:58Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* DAQ Software and Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Create online and packages directory ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install EPICS ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
==== Set environment variables ==== &lt;br /&gt;
&lt;br /&gt;
Because we want two midas installs side-by-side for a seamless transition, edit the .bashrc file to ensure the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# this later needs changing for the final switch to tucan01&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == daq01.ucn.triumf.ca ] || [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ] ; then&lt;br /&gt;
  unset MIDAS_SERVER_HOST&lt;br /&gt;
else&lt;br /&gt;
  export MIDAS_SERVER_HOST=daq01.ucn.triumf.ca&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$HOSTNAME&amp;quot; == tucan01.ucn.triumf.ca ] ; then&lt;br /&gt;
   export MIDASSYS=/home/ucn/packages_tucan01/midas&lt;br /&gt;
   export MIDAS_EXPTAB=/home/ucn/online_tucan01/exptab&lt;br /&gt;
   export ROOTANASYS=/home/ucn/packages_tucan01/rootana&lt;br /&gt;
else&lt;br /&gt;
   export MIDASSYS=/home/ucn/packages/midas&lt;br /&gt;
   export MIDAS_EXPTAB=/home/ucn/online/exptab&lt;br /&gt;
   export ROOTANASYS=/home/ucn/packages/rootana&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clone and Make ==== &lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Setup online directory ==== &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
Many of the UCN analysis codes still rely on ROOTANA.&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9201</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9201"/>
		<updated>2026-07-24T22:19:27Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install MIDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. If the directory does not exist, create it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as user &amp;quot;ucn&amp;quot;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT === &lt;br /&gt;
&lt;br /&gt;
We point the installation to the pre-compiled root on daqstore. Edited &amp;lt;code&amp;gt;.bashrc &amp;lt;/code&amp;gt; to the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# setup root version for different distros&lt;br /&gt;
os_id=$(. /etc/os-release &amp;amp;&amp;amp; echo &amp;quot;$ID&amp;quot;)&lt;br /&gt;
case &amp;quot;$os_id&amp;quot; in&lt;br /&gt;
    ubuntu) source /daq/daqshare/olchansk/root/root_v6.36.06.Linux-ubuntu24.04-x86_64-gcc13.3/bin/thisroot.sh ;;&lt;br /&gt;
    centos) source /daq/daqshare/olchansk/root/root_v6.24.08.Linux-centos7-x86_64-gcc4.8/bin/thisroot.sh ;;&lt;br /&gt;
    *)      echo &amp;quot;Need to set a root binary for $os_id&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS ===&lt;br /&gt;
&lt;br /&gt;
Clone the repository as user ucn then make:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /home/ucn/packages_tucan01&lt;br /&gt;
cd /home/ucn/packages_tucan01&lt;br /&gt;
git clone https://dfujimoto1@bitbucket.org/tmidas/midas.git&lt;br /&gt;
cd midas&lt;br /&gt;
git submodule update --init --recursive&lt;br /&gt;
git pull --recurse-submodules&lt;br /&gt;
make cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9200</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9200"/>
		<updated>2026-07-24T21:51:15Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install APACHE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. If the directory does not exist, create it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as user &amp;quot;ucn&amp;quot;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS === &lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9199</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9199"/>
		<updated>2026-07-24T21:49:27Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* DAQ Software and Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. If the directory does not exist, create it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as user &amp;quot;ucn&amp;quot;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install APACHE === &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS === &lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9198</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9198"/>
		<updated>2026-07-24T19:57:39Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup ODB Connection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok and use it in the following. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. If the directory does not exist, create it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as user &amp;quot;ucn&amp;quot;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS === &lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9197</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9197"/>
		<updated>2026-07-24T19:56:53Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup ODB Connection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. If the directory does not exist, create it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as user &amp;quot;ucn&amp;quot;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS === &lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9196</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9196"/>
		<updated>2026-07-24T19:55:18Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install MySQL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup ODB Connection ====&lt;br /&gt;
&lt;br /&gt;
First, we check the socket location: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grep sock /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which should result in something like &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# socket	= /var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
denoting the default location. You can uncomment this line, change it, or leave it as is. We assume that this location is ok. &lt;br /&gt;
&lt;br /&gt;
Now we create the files needed. We do this in &amp;lt;code&amp;gt;/home/ucn/online_tucan01&amp;lt;/code&amp;gt; since we are setting this up in parallel with the already-running instance in &amp;lt;code&amp;gt;/home/ucn/online&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# as user &amp;quot;ucn&amp;quot;&lt;br /&gt;
mkdir /home/ucn/online_tucan01&lt;br /&gt;
&lt;br /&gt;
# create ucn_reader file: copy/paste all the following lines&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_reader.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_reader&lt;br /&gt;
socket=/var/run/mysqld/mysqld.sock&lt;br /&gt;
password=THE PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# create ucn_writer file: copy/paste all the following lines&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /home/ucn/online_tucan01/ucn_writer.txt&lt;br /&gt;
server=localhost&lt;br /&gt;
port=3306&lt;br /&gt;
socket=NULL&lt;br /&gt;
database=ucn_history&lt;br /&gt;
user=ucn_writer&lt;br /&gt;
socket=/datassd/mysql/mysql.sock&lt;br /&gt;
password=THE OTHER PASSWORD FROM EARLIER&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS === &lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9195</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9195"/>
		<updated>2026-07-24T19:44:43Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Uninstall MySQL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL (only if needed!) ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS === &lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9194</id>
		<title>UCN</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/DaqWiki/index.php?title=UCN&amp;diff=9194"/>
		<updated>2026-07-24T19:43:13Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup MySQL Users and Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Ultracold Neutron group, now the TRIUMF Ultracold Advanced Neutron (TUCAN) collaboration was created to measure the [https://en.wikipedia.org/wiki/Neutron_electric_dipole_moment neutron electric dipole moment (nEDM)]. This fundamental property, if non-zero, has serious ramifications for resolving the [https://en.wikipedia.org/wiki/Baryogenesis Baryogenesis problem].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
The project has two main components: (a) the UCN source and (b) the nEDM experiment. &lt;br /&gt;
&lt;br /&gt;
The source was largely completed and shown to be functional in 2026. It is operated primarily though EPICS, with monitoring though MIDAS histories with a MySQL database. It operates on beamline 1U (BL1U), splitting off of 1V (which later becomes BL1A). With a fast kicker magnet, the TUCAN collaboration can kick individual beam buckets to BL1U to take a fraction of beam, while enabling beam to BL1A. Design operating current is 40 uA. The UCN source has two end stations for experiments: one for the nEDM experiment, and the other is planned for PENeLOPE. &lt;br /&gt;
&lt;br /&gt;
The nEDM experiment is the primary experiment for the UCN source and is composed of many subsystems, each with their own controls and DAQ setup. Experiments are generally conducted as follows: &lt;br /&gt;
&lt;br /&gt;
# produce UCNs in the source, &lt;br /&gt;
# open a valve to let the UCNs diffuse to the experimental chamber&lt;br /&gt;
# store the UCNs in the chamber for some time, while applying high voltage, and RF pulses&lt;br /&gt;
# open the chamber valve to let the UCNs diffuse to the detectors&lt;br /&gt;
&lt;br /&gt;
The subsystems with DAQ interfaces are as follows:&lt;br /&gt;
&lt;br /&gt;
== UCN Source == &lt;br /&gt;
&lt;br /&gt;
Produces UCN &lt;br /&gt;
&lt;br /&gt;
Controlled through EPICS, monitored with MIDAS. Some MIDAS controls are implemented, such as the AutoStat page and the UCN sequencer. &lt;br /&gt;
&lt;br /&gt;
== Comagnetometer ==&lt;br /&gt;
&lt;br /&gt;
An atomic gas (&amp;lt;sup&amp;gt;199&amp;lt;/sup&amp;gt;Hg) inhabits the cell the UCNs are stored in. The gas is polarized with a free laser, and that polarization state is also measured with a laser. Measures magnetic field. &lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Cs Magnetometers ==&lt;br /&gt;
An array of glass cells containing Cs gas are distributed inside the magnetically shielded room. The polarization state is also pumped and probed with lasers, this time through fibre optics. Measures magnetic field gradients. &lt;br /&gt;
&lt;br /&gt;
DAQ exists as a set of student python scripts, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
== B0 Coil ==&lt;br /&gt;
A coil which produces a highly stable and uniform static magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== B1 Coil ==&lt;br /&gt;
A coil which produces the oscillating RF fields for spin flips&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Shim Coils ==&lt;br /&gt;
An array of coils inside the MSR to homogenize the field&lt;br /&gt;
&lt;br /&gt;
DAQ exists as a python script which controls an arduino, yet to be integrated into MIDAS&lt;br /&gt;
&lt;br /&gt;
The main repository is [https://github.com/ucn-triumf/ShimCoil_CurrentControl here], with the [https://github.com/ucn-triumf/ShimCoil_SerialArduino arduino code here].&lt;br /&gt;
&lt;br /&gt;
== Guiding coils ==&lt;br /&gt;
An array of coils to maintain UCN polarization in their journey to and from the magnetically shielded room&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient Magnetic Coil (AMC) ==&lt;br /&gt;
A large Helmholtz coil to counteract the cyclotron magnetic field&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== High voltage ==&lt;br /&gt;
A large electric field to tease out the electric dipole moment&lt;br /&gt;
&lt;br /&gt;
DAQ not yet implemented&lt;br /&gt;
&lt;br /&gt;
== Ambient monitoring ==&lt;br /&gt;
Monitoring of ambient temperature and magnetic field&lt;br /&gt;
&lt;br /&gt;
=== Temperature ===&lt;br /&gt;
&lt;br /&gt;
Measured through &amp;quot;canaries&amp;quot;: battery-powered arduinos with a temperature sensor on the TRIUMF IOT network. &lt;br /&gt;
Integrated into MIDAS. [https://github.com/ucn-triumf/fe_canary_env_temp Frontend repo]&lt;br /&gt;
&lt;br /&gt;
=== Magnetic Fields ===&lt;br /&gt;
Measured through fluxgates and a custom DAQ produced by the TRIUMF electronics group. &lt;br /&gt;
[https://github.com/ucn-triumf/fefluxgate Frontend repo]&lt;br /&gt;
&lt;br /&gt;
= Machines = &lt;br /&gt;
&lt;br /&gt;
The below list is incomplete, needs expanding&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DAQ Computers in use by the UCN group (last updated Jul 23, 2026)&lt;br /&gt;
|-&lt;br /&gt;
! Hostname (.triumf.ca)&lt;br /&gt;
! Purpose&lt;br /&gt;
! Location&lt;br /&gt;
! OS&lt;br /&gt;
! Status&lt;br /&gt;
|-&lt;br /&gt;
| daq01.ucn&lt;br /&gt;
| Legacy primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq02.ucn&lt;br /&gt;
| Runs digitizer frontend&lt;br /&gt;
| Meson hall B2&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq04.ucn&lt;br /&gt;
| Multi-monitor EPICS control station&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq06.ucn&lt;br /&gt;
| Test environment&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| daq07.ucn&lt;br /&gt;
| Laser enclosure frontend&lt;br /&gt;
| Laser enclosure, Meson hall B2&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active&lt;br /&gt;
|-&lt;br /&gt;
| tucan01.ucn&lt;br /&gt;
| New primary DAQ machine and MIDAS host&lt;br /&gt;
| UCN counting room&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| In setup&lt;br /&gt;
|-&lt;br /&gt;
| ktm-readout.ucn&lt;br /&gt;
| Kicker timing monitor frontend and web host&lt;br /&gt;
| Cyclotron roof&lt;br /&gt;
| Ubuntu 24&lt;br /&gt;
| Active, untested&lt;br /&gt;
|-&lt;br /&gt;
| ktmserver&lt;br /&gt;
| Legacy KTM web host&lt;br /&gt;
| Virtual machine&lt;br /&gt;
| CentOS7&lt;br /&gt;
| Active&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= DAQ Software and Setup =&lt;br /&gt;
&lt;br /&gt;
== Directory Organization ==&lt;br /&gt;
&lt;br /&gt;
Here we describe the organization and setup of the DAQ computer. While there are many other directories not listed here, they are outside of the core functionality of the main DAQ. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/home/ucn/&amp;lt;/code&amp;gt; (shared home)&lt;br /&gt;
** &amp;lt;code&amp;gt;online/&amp;lt;/code&amp;gt; (daq01 midas main directory)&lt;br /&gt;
*** [https://github.com/ucn-triumf/autostat &amp;lt;code&amp;gt;autostat&amp;lt;/code&amp;gt;] (python script to automate cryostate functions)&lt;br /&gt;
*** [https://github.com/ucn-triumf/epics2midas &amp;lt;code&amp;gt;epics2midas&amp;lt;/code&amp;gt;] (read EPICS variables to midas ODB)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fe_canary_env_temp &amp;lt;code&amp;gt;fe_canary_env_temp&amp;lt;/code&amp;gt;] (canary temperature monitor)&lt;br /&gt;
*** [https://github.com/ucn-triumf/fefluxgate &amp;lt;code&amp;gt;fefluxgate&amp;lt;/code&amp;gt;] (read custom orange DAQ box for fluxgates)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ktm_frontend &amp;lt;code&amp;gt;ktm&amp;lt;/code&amp;gt;] (Legacy KTM frontend)&lt;br /&gt;
*** &amp;lt;code&amp;gt;odb_dumps&amp;lt;/code&amp;gt; (Main repository of regular ODB dumps)&lt;br /&gt;
*** [https://github.com/ucn-triumf/scmfe &amp;lt;code&amp;gt;scmfe&amp;lt;/code&amp;gt;] (SCM frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/sequence-control &amp;lt;code&amp;gt;sequence-control&amp;lt;/code&amp;gt;] (UCN sequencer frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/shiftschedule &amp;lt;code&amp;gt;shift_schedule&amp;lt;/code&amp;gt;] (Scheduler frontend)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-alarms-notification &amp;lt;code&amp;gt;ucn-alarms-notification&amp;lt;/code&amp;gt;] (Alarm actions: phone/email users)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn_detector_analyzer &amp;lt;code&amp;gt;ucn_detector_analyzer&amp;lt;/code&amp;gt;] (Main UCN counting: processing/online analysis - produce root files)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-v1725 &amp;lt;code&amp;gt;ucn-v1725&amp;lt;/code&amp;gt;] (CAEN digitizer frontend, runs on daq02.ucn)&lt;br /&gt;
*** [https://github.com/ucn-triumf/ucn-web-control &amp;lt;code&amp;gt;ucn-web-control&amp;lt;/code&amp;gt;] (Custom pages)&lt;br /&gt;
** &amp;lt;code&amp;gt;packages/&amp;lt;/code&amp;gt; (source and build directories: MIDAS, EPICS, CAEN, ROOTANA, etc)&lt;br /&gt;
* &amp;lt;code&amp;gt;/data3/&amp;lt;/code&amp;gt; (large storage drive)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/midas_files&amp;lt;/code&amp;gt; (.mid.gz files and similar)&lt;br /&gt;
** &amp;lt;code&amp;gt;ucn/root_files&amp;lt;/code&amp;gt; (.root, for analysis, after preprocessing)&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions == &lt;br /&gt;
&lt;br /&gt;
Here&#039;s the general path to setting up the main DAQ machine (steps taken on tucan01.ucn): &lt;br /&gt;
&lt;br /&gt;
=== Install ubuntu 24 ===  &lt;br /&gt;
&lt;br /&gt;
As per the instructions [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu here]&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL ===&lt;br /&gt;
&lt;br /&gt;
==== Create partition on drive for MySQL histories ====&lt;br /&gt;
&lt;br /&gt;
In ZFS you don&#039;t really create fixed-size &amp;quot;partitions&amp;quot; the way you would with fdisk/gparted. Instead a pool (created from disks) is carved into datasets (filesystems) or volumes/zvols (block devices). Space is shared from the pool by default, and you constrain size with quota/reservation (for datasets) or a fixed volume size (for zvols).&lt;br /&gt;
&lt;br /&gt;
See existing pools&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ucn@tucan01:~$ zpool list&lt;br /&gt;
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT&lt;br /&gt;
bpool  1.88G   210M  1.67G        -         -     7%    10%  1.00x    ONLINE  -&lt;br /&gt;
rpool   936G  6.09G   930G        -         -     0%     0%  1.00x    ONLINE  -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly rpool is the main filesystem. We want to allocate about 700 GB from this for the mysql database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo zfs create rpool/sqlstorage # create&lt;br /&gt;
sudo zfs set reservation=700G rpool/sqlstorage # guarantee the size that other datasets can&#039;t eat into&lt;br /&gt;
zfs list # check success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install MySQL ====&lt;br /&gt;
&lt;br /&gt;
We will install mysql and set the data base location to /sqlstorage (following [https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04 this tutorial]). Note that the mysql error log defaults to &amp;lt;code&amp;gt;/var/log/mysql/error.log&amp;lt;/code&amp;gt; in the case of issues.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install mysql-server&lt;br /&gt;
sudo systemctl status mysql-server # should show enabled and active&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we find the default database directory, should likely be &amp;lt;code&amp;gt;/var/lib/mysql&amp;lt;/code&amp;gt;. If not make the substitute in the commands that follow. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this confirmed, we change the data directory: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo systemctl status mysql # confirmed inactive&lt;br /&gt;
sudo rsync -av /var/lib/mysql /sqlstorage # copy database to new location&lt;br /&gt;
sudo mv /var/lib/mysql /var/lib/mysql.bak # rename old database in case of errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the basic settings section of the config file (&amp;lt;code&amp;gt;sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&amp;lt;/code&amp;gt;) to match the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# * Basic Settings&lt;br /&gt;
#&lt;br /&gt;
user            = mysql&lt;br /&gt;
# pid-file      = /var/run/mysqld/mysqld.pid&lt;br /&gt;
# socket        = /var/run/mysqld/mysqld.sock&lt;br /&gt;
port            = 3306&lt;br /&gt;
datadir         = /sqlstorage/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if apparmor is disabled, you still need to change the alias file and re-enable apparmor, otherwise you will get the error &amp;lt;code&amp;gt;Job for mysql.service failed because the control process exited with error code.&amp;lt;/code&amp;gt;. To resolve this, edit the apparmor alias file (&amp;lt;code&amp;gt;sudo vim /etc/apparmor.d/tunables/alias&amp;lt;/code&amp;gt;) and add the following line to the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alias /var/lib/mysql/ -&amp;gt; /sqlstorage/mysql/,&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Apply changes by restarting apparmor, then re-disable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart apparmor&lt;br /&gt;
sudo systemctl stop apparmor&lt;br /&gt;
sudo systemctl disable apparmor&lt;br /&gt;
sudo systemctl status apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then restart the server&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl restart mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirm that it worked by re-checking the data directory inside mysql &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
SELECT @@datadir;&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When finished, delete the original directory&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo rm -rf /var/lib/mysql.bak&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Uninstall MySQL ====&lt;br /&gt;
&lt;br /&gt;
In the case of serious issue, here are steps to completely purge mysql from your system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl stop mysql&lt;br /&gt;
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*&lt;br /&gt;
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql&lt;br /&gt;
sudo apt autoremove&lt;br /&gt;
sudo apt autoclean&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setup MySQL Users and Database ====&lt;br /&gt;
&lt;br /&gt;
By default there should be a root user which can access the database without any password. Use that and the following commands to set up the database, following the steps in the [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MySQL_database_for_MIDAS midas wiki]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mysql -u root&lt;br /&gt;
&lt;br /&gt;
CREATE DATABASE IF NOT EXISTS ucn_history;&lt;br /&gt;
&lt;br /&gt;
CREATE USER &#039;ucn_reader&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password somewhere&lt;br /&gt;
CREATE USER &#039;ucn_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;; # save this password, different from the reader&lt;br /&gt;
&lt;br /&gt;
GRANT SELECT ON ucn_history.* TO ucn_reader@&#039;localhost&#039;; # permissions&lt;br /&gt;
GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON ucn_history.* TO &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
flush privileges;&lt;br /&gt;
&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_reader&#039;@&#039;localhost&#039;; # verify that commands worked&lt;br /&gt;
SHOW GRANTS FOR &#039;ucn_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install MIDAS === &lt;br /&gt;
&lt;br /&gt;
=== Install ROOT ===&lt;br /&gt;
&lt;br /&gt;
=== Install ROOTANA ===&lt;br /&gt;
&lt;br /&gt;
= Contacts =&lt;br /&gt;
&lt;br /&gt;
Some useful contact persons (TRIUMF PIs): &lt;br /&gt;
&lt;br /&gt;
* R. Picker &lt;br /&gt;
* N. Yazdandoost&lt;br /&gt;
&lt;br /&gt;
= Useful Links =&lt;br /&gt;
&lt;br /&gt;
* [https://ucn.triumf.ca UCN Plone]&lt;br /&gt;
* [https://daq01.ucn.triumf.ca/ UCN DAQ (old - daq01)]&lt;br /&gt;
* [https://github.com/ucn-triumf Github]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
</feed>