Alma Linux 9.6 - Creating systemctl capability: Difference between revisions

From Network for Advanced NMR
Jump to navigationJump to search
Lmorris (talk | contribs)
Created page with "For Alma Linux 9.6, the standard <pre> service data-transport-daemon status </pre> command doesn't work. Let's make the daemon work with systemctl. === Step 1. Create the service file. === <pre> sudo vi /etc/systemd/system/data-transport-daemon.service </pre> Enter the following lines in the file: <pre> [Unit] Description=Data Transport Daemon After=network.target [Service] Type=forking ExecStart=/opt/nan-dtdaemon/data-transport-daemon TimeoutStopSec=10 KillSign..."
 
Lmorris (talk | contribs)
No edit summary
 
Line 27: Line 27:
KillSignal=SIGINT
KillSignal=SIGINT
Restart=on-failure
Restart=on-failure
User=nandt-gateway
User=root


[Install]
[Install]
Line 33: Line 33:
</pre>
</pre>


=== Step 2. Create the nandt-gateway user ===
=== Step 2. Get the daemon started ===
 
<pre>
sudo useradd --system --no-create-home --shell /sbin/nologin nandt-gateway
</pre>
 
Make sure the binary is executable by the user nandt-gateway:
 
<pre>
sudo chown root:nandt-gateway /opt/nan-dtdaemon/data-transport-daemon
 
sudo chmod 750 /opt/nan-dtdaemon/data-transport-daemon
</pre>
 
=== Step 3. Get the daemon started ===


<pre>
<pre>

Latest revision as of 16:07, 27 June 2025

For Alma Linux 9.6, the standard

service data-transport-daemon status

command doesn't work.

Let's make the daemon work with systemctl.

Step 1. Create the service file.

sudo vi /etc/systemd/system/data-transport-daemon.service

Enter the following lines in the file:

[Unit]
Description=Data Transport Daemon
After=network.target

[Service]
Type=forking
ExecStart=/opt/nan-dtdaemon/data-transport-daemon
TimeoutStopSec=10
KillSignal=SIGINT
Restart=on-failure
User=root

[Install]
WantedBy=multi-user.target

Step 2. Get the daemon started

sudo systemctl daemon-reload

sudo systemctl restart data-transport-daemon

Helpful Commands

systemctl start data-transport-daemon

systemctl stop data-transport-daemon

systemctl restart data-transport-daemon

systemctl status data-transport-daemon

# investigating problems
journalctl -xeu data-transport-daemon

Bonus Material (very optional)

I like to get the status of a few things when I log onto one of the NMR spectrometer workstations remotely.

In my .bash_profile, I added:

# Check if the shell is interactive
if [[ $- == *i* ]]; then
        /home/lmorris/scripts/checkNDTS.sh
fi

Edit the path and filename as appropriate.

My version of checkNDTS.sh is:

#!/usr/bin/bash

# v 1.10 (2025.06jun.19)

# 1. see who's on the system
echo -e "\n\n================================================\n"

# for Alma Linux 9 use
user=$(who | awk '$2 == "seat0" { print $1 }')
# for Centos 7 use
# user=$(who | awk '$2 == ":0" { print $1 }')

if [ -n "$user" ]; then
    echo "User: $user"
else
    echo "No user logged into graphical session."
fi

echo ""

# 2. make sure the daemon is running

NDTS=$(systemctl status data-transport-daemon |grep Active)
CK_NDTS="active"

# Define ANSI color codes
RED="\033[0;31m"
# YELLOW="\033[0;33m" # for reference (not used)
GREEN="\033[0;32m"
# CYAN="\033[0;36m" # for reference (not used)
RESET="\033[0m" # Reset color back to default

# ndts daemon status
if [[ "$NDTS" == *"$CK_NDTS"* ]]; then
    echo -e "${GREEN}NDTS daemon${RESET} status: ${GREEN}running${RESET}" 
else
    echo -e "${RED}NDTS daemon${RESET} status: ${RED}INACTIVE${RESET}"
fi

echo ""

# 3. check the port on gateway computer

HOST="128.192.9.245" # edit for the IP address of your gateway computer
PORT=60195 # port used by ndts to communicate to the gateway computer

if nc -z -w3 $HOST $PORT; then
  echo "✅ Port $PORT is open on $HOST"
else
  echo "❌ Port $PORT is NOT reachable on $HOST"
fi

echo -e "\n================================================\n"