Hi there,
I’m trying to get a script working that will start a timer once a user logs in and will countdown 1 hour. At 5 minutes and 1 minute I would like to be able to pop up a window with a warning that the session will be ending soon and any unsaved work will be lost. At the end of the timer I would like the computer to reboot.
I already have a login script that is working very well to wipe and restore the profile to it’s original settings after each session. I just don’t know where to start or how to go about writing this script. I don’t think it will be that hard for some of you experts so I appreciate your patience and your help.
If you have any questions about my request I should be checking this thread fairly often.
It’s actually for a public library. Users need to be able to download files, take pictures off flash drives and cameras, print, compose word documents and such.
They are currently using Userful. It works but it uses Epiphany and support for saving and printing is spotty to say the best. Trying to replace it with SuSE. I looked at Ubuntu and Fedora as well but SuSE has the best tools for managing users. I just need to fix the auto-logoff issue and the system will be perfect for all intents and purposes.
I’m looking into those links and will let you know if they help. Thanks for your reply!
Yea, I looked at all of those links and they are all Kiosk systems. There is no infrastructure to implement a server side kiosk solution, especially to fix just this one small problem.
Does anyone know of a script that will reboot a computer a set time after the user logs in? Or a client side program that will accomplish this task?
How about something like this, but you’ll probably have to write it yourself.
Hook into the xdm login scripts while still root (Xstartup) and not yet switched to the user identity. Schedule two at jobs, one to issue the warning and another to reboot the machine.
You’ll also have to cancel the jobs if the user has logged out before time is up, using the Xreset hook.
man xdm explains the order of the script execution.
If you have kde4 installed, You can put a script in the .kde4/Autostart/ folder of every user that has to logout. Lookup the skeleton to make this default
Sorry, using Gnome! That looks like it would accomplish what I need though. Anyone have any insight into a Gnome solution? I’m very new to scripting so basic help is appreciated. I can read scripts but usually have to research the commands. This script would go in /etc/gdm/PreSession/Default correct?
Thanks for your reply ken_yap but most of your terminology is above my head for now. Can you maybe bring it down a level or show me a basic example to try and tie in with what you’re saying?
Ok so I had some success and some failure and I hope you guys can get me back on track. I added this code
sleep 60
sudo /sbin/reboot
to /etc/gdm/PreSession/Default
and it worked! It automatically rebooted the system after 60 seconds!
One problem. It just sat at a green screen without anything loading. I couldn’t get the script to not run in any failsafe mode or terminal login so I just reinstalled.
What did I do wrong? Is there a different place I can put this script that will keep it from making the system hang?
P.S. I know 60 is only a minute but this was just for testing purposes.
When xdm gives a user a session, the script /etc/X11/xdm/Xstartup is run while still as root, before changing uid to that of the user. Symmetrically, when the user logs out, the script /etc/X11/xdm/Xreset is run as root. So you can edit these scripts, to schedule a timer, etc, or however you implement the forced shutdown.
Just be careful when editing those scripts since they affect all X logins. Make sure you are able to undo any changes from a CLI console. Maybe save a pristine copy of the scripts so that you can move them back in place if things go pear-shaped.
Whatever command you run in Xstartup or Xreset must not block because these scripts are in the login and logout path. You could do something like schedule a command using the at batch system.
The amp (&) at the end of the line means execute this or in this case these statements but continue the script or routine you were in. The double amp makes sure the 2 statement get executed in sequence as one.
Ok so I’ve been trying several different things with several diffrent results. None of them were terrible encouraging.
I put “sudo /sbin/shutdown -r +5” into /etc/gdm/PreSession/Default. Now this works about 1 in 5 times, seems to usually work after a normal shutdown. But usually when I try and log in it throws an error about the session lasting less than 10 seconds and it will take me back to the login screen. Loging into failsafe mode lets me edit the script but to no avail.
I also tried putting this script into the /etc/X11/xdm/Xstartup. It didn’t do anything, no errors but no reboot either.
Help. If you guys need more specific data just ask and how to get it and I will try to give you what you need. I’m so close I can tell.
I’ll keep trying in the mean time. Thanks for the incredibly helpful posts.
Using shutdown with its delay is tempting, but if you read the man page, you will find it has some deficiencies. One serious problem is that it creates /etc/nologin which prevents any more logins.
Rather I would suggest the use of the “at” service to schedule a job in the future. You could call it like this in Xstartup:
echo “shutdown -fr now” | at now + 60 minutes
Since in Xstartup the process is running as root, the at job will be executed at root. You might want to give warning 5 minutes before:
echo “some command that pops up a warning” | at now + 55 minutes
The other thing you would have to do is to remove any scheduled shutdown jobs on logout (using Xreset) or on machine shutdown, otherwise the next user will get a surprise.
I tried putting your example code into the Xstartup script with no visible results. No errors but no shutdown. This is similar to the last time I tried using the Xstartup approach to my solution. Is there any special way to edit the script or a certain syntax that is escaping me?