Time limit on guest account - help needed [solved]

Forum rules
Before you post please read how to get help

Time limit on guest account - help needed [solved]

Postby MintLover4Ever on Sat Sep 17, 2011 8:11 pm

Hi,
I really need help with the creation of a script to allow access for timed intervals of 30 mins on a Guest account and since I am a complete beginner with scripting I hope the community can lend a generous hand with the development of said script.
Here's the story, I have recently refurbished a computer and installed Linux Mint 11 with very few noticeable issues. I created a Guest account for use by my clients to check email or edit some documents but the only problem that remains is the lack of a time limitation to prevent unnecessary extended use. I've Googled my brains out trying to find a viable option but to no avail, the only one that has what I want is http://u-scripts.blogspot.com/2010/03/automatic-logout-for-kids.html the only dependency is on Conky which is NOT compatible with the new linux mint 11. Here are the minimal parameters for what I'm looking for:

-a simple script that is engaged at login of Guest account
-script logs off only the Guest account after 30 minutes of use
-Does not affect the admin account which will also be engaged for extraneous purposes behind the scenes
-blocks re-login for 5 min (if possible)

For a more advanced version my only hope is for a timer that shows the amount of remaining time.
Last edited by MintLover4Ever on Sat Oct 29, 2011 3:20 pm, edited 1 time in total.
MintLover4Ever
Level 1
Level 1
 
Posts: 1
Joined: Sat Sep 17, 2011 7:29 pm

Linux Mint is funded by ads and donations.
 

Re: Time limit on guest account - help needed

Postby Oscar799 on Sun Sep 18, 2011 3:14 am

Split from another thread and title edited
Image
"Don't fix it if it ain't broken,don't break it if you can't fix it" Husse
Registered Linux User #511789
User avatar
Oscar799
Level 18
Level 18
 
Posts: 8943
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: Time limit on guest account - help needed

Postby Pilosopong Tasyo on Mon Sep 19, 2011 5:02 am

How about a rough algorithm instead, just to give you a head start?

Code: Select all
#!/bin/sh

# Some useful variables
TIME_NOW = current time expressed in seconds
END_TIME = computed ending time (also expressed in seconds)

# Countdown loop
while TIME_NOW < END_TIME
do
  # Display a reminder once per minute
  REMINDER_FLAG = (END_TIME-TIME_NOW) modulus 60
  if REMINDER_FLAG = 0
  then
    REMAINING_TIME = (END_TIME-TIME_NOW) / 60
    display REMAINING_TIME on screen
  fi

  # Update the current time
  TIME_NOW = current time (expressed in seconds)
  sleep 1 # Don't hog the CPU!
done

# Time is up!
force logout user

# EOF

Then you can set the script to run upon login of the guest account (via Startup Applications). The algorithm satisfies all your requirements (including remaining time notification) except the last one (blocks relogin for 5 minutes -- perhaps a future exercise?). Also note the algorithm doesn't take into consideration if the guest user logs out of the account before his/her alloted time is up. No need for conky either, though you might need to download a small package in order to display on-screen notifications.

Try to understand the logic of the above algorithm. It will help you tremendously if you get the idea how it works. Look up the following for hints as well:

    date
    expr
    notify-send
    pkill / gnome-session-save
HTH.
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1190
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines


Return to Scripts & Bash

Who is online

Users browsing this forum: Jamesc359 and 2 guests