1

Basic setup: I'm running an Ubuntu VM which is joined to MS AD. SSSD handles user creation when people log in using their AD credentials. The only login method for the users is via xrdp.

When a new user logs in, I want a script to run. The script creates a symlink on their desktop to another script in /usr/share. I tried setting up a service to handle this, but the script does not run when an SSSD user logs in.

[Unit]
Description=Create symlink on user desktop for TY script.

[Service]
Type=oneshot
User=root
Group=root
RemainAfterExit=yes
ExecStart=/usr/share/create_ty_link.sh

[Install]
[email protected]

The create_ty_link.sh script is as follows:

#!/bin/bash
LOG_FILE="/var/log/create_ty_symlink.log"
PAM_USER=$(whoami)
echo "$(date +%Y%m%d%H%M%S) Running script for user: $PAM_USER" >> "$LOG_FILE"

if [ ! -L "/home/$PAM_USER/Desktop/LinuxLaunch.sh" ]; then
        echo "$(date +%Y%m%d%H%M%S) Symlink doesn't exist - /home/$PAM_USER/Desktop/LinuxLaunch.sh" >> "$LOG_FILE"
        ln -s "/usr/share/TY/LinuxLaunch.sh" "/home/$PAM_USER/Desktop/LinuxLaunch.sh"
        chown $PAM_USER: "/home/$PAM_USER/Desktop/LinuxLaunch.sh"
        echo "$(date +%Y%m%d%H%M%S) Symlink created for $PAM_USER" >> "$LOG_FILE"
else
        echo "$(date +%Y%m%d%H%M%S) Symlink found for $PAM_USER, no need to create it." >> "$LOG_FILE"
fi

When I log in as myself via ssh, the log shows the following:

20240328111448 Running script for user: root
20240328111448 Symlink doesn't exist - /home/root/Desktop/LinuxLaunch.sh
20240328111448 Symlink created for root

However, when I log in as a test AD user via xrdp, nothing appears in the log.

Thanks in advance for any help.

1
  • im not sure, but it took me 5 seconds to get "this answer" which will imho solve your issue.
    – djdomi
    Commented Apr 8 at 7:19

0

You must log in to answer this question.

Browse other questions tagged .