I have a custom shell script that runs every time a user is supposed to log in or identify a user, they put it in /etc/profile.d and performed some basic operations with env variables. I recently added some code so that if the screen works, it will connect to it again without requiring me to enter anything. However, there are some problems. If I log in as root and su with another user, the code runs a second time. Is there a variable that I can set when the code is run for the first time that will prevent the code from being run the second time?
I was thinking of writing something to disk, but then I do not want the code to not run if I start a new terminal session. Here is the code. First, he tries to try again - if he is unsuccessful because he is already connected (as it may be in an intermittent session), he will "take" the session back.
screen -r if [ -z "$STY" ]; then exec screen -dR fi
Ultimately, this error does not allow me to replace the user with another user, because as soon as I do this, he captures the screen session and returns me to where I started. Pretty frustrating
user124626
source share