Jey10 Jey10 - 25 days ago 6
Linux Question

Bash not executed after the user logging

I'm trying to execute a script after the user is logged in but it's not working.

I have created a script which is executing a docker with the command "docker exec" and a shell bash. After this, some commands are executed into the shell to launch a specific application.

I have put this script into the folder /etc/profile.d/ but nothing happens after the user is logged in.

I have also tested a simple script with a simple command "mkdir" on the user home directory and this is working so I think that the problem is caused of the shell bash into the docker.

Here is the script :

#!/bin/bash
xhost +local:of_v1606_plus
docker start of_v1606_plus
docker exec -it of_v1606_plus bash --rcfile '/opt/application/setImage_v1606+' -c 'cd /home/user/application/run/ ; application'

Answer

I had the same problem and I used xdg. You have just to create a .desktop with this format :

[Desktop Entry]
Type=Application
Name=Application Name
Comment=Application Comment
Exec= your program or path

You can add other options if you need.

After this, put your .desktop file into /etc/xdg/autostart/

Your program should run after the user logon.