cybercafe system

Ray Parrish crp at cmc.net
Fri Feb 20 13:44:42 UTC 2009


Mihamina Rakotomandimby (R12y) wrote:
> Hi,
>
> Here in 3rd world countries, internet is still luxury.
> I would like to setup a cybercafe (or cybercoffee?) which is a place 
> with several computers and people can surf and pay the time they use the 
> computer.
> I would like then have the ability to count how much time (minute 
> precision) an account has been logged in.
> Most of the cybercafe I have seen is pre paid, so the real need is a 
> countdown and then a forced logout when expired.
>
> What kind of ubuntu integrated solution can be used?
>
> Dont worry, it wont be expensive for the users ;-) it will just be a 
> symbolic amount.
>   
Hello,

A simple bash script could be ran on the system which will cause it to 
log out after a set timeout. You only need a couple of command to 
accomplish this. The following will cause the machine to shut down to a 
text terminal after a timeout period passed in from the command line.

<start of bash file listing>
#!/usr/bin/env bash
#
# first we set the timeout to the value passed in on the command line
# the m sets the time as minutes, h could be used for hours, or s for 
seconds
tosleep="$1 + m";
# now we call the sleep command  withe the timeout value
sleep $tosleep;
# then we log the user out
telinit 1;
# the teliniit command brings the machine down to user level 1
# to entirely stop the machine use a level number of 0
# to reboot the machine use a level number of 6
exit
<end of bash script listing>

Copy everything there except for the two lines within <> brackets around 
them, and paste it into a text file. Now save it to a file named 
something like "timer.sh"  The file extension must be sh to tell the 
bash shell that it's a script.

After you save it, open File Manager, find the file, right click on it, 
and select Properties from the pop ip menu. On the resulting Properties 
dialog, select the Permissions tab,, and check mark the boxes next to 
the word "Execute" on the line after your user name, and after the group 
name, and after the line that says Others.

This sets the permissions to allow it to run as a program. Now when 
someone wants to use the computer, open the Applications,, Accessories 
menu, and select Terminal. In the terminal type the following command. -

~/timer.sh 60 &

Then hit enter to start the script.

This assumes that you have saved the script in your user folder. If you 
save it somewhere else you must adjust the path shown in the command 
line to the folder path where you saved the file. The 60 will make it 
sleep for an hour and then it will shut the computer down to a login 
prompt on a text console. Make sure you add the "&" to the end of the 
command line, as this allows the script to continue running after you 
close the Terminal window. Without the "&" the script would immediately 
exit as soon as you shut off the Terminal window.

You could alternatively start the script from an entry in the Ubuntu 
menu, but you would need to know how long you want it to sleep for, so 
you can add the proper number on the command line of the menu entry. I 
suppose you could create several menu entries with different timeout 
values specified in each one as well. If you use a menu entry don't 
forget to add the "&" sign to the end of the command line there also.

That should fix you up. 8-)

Later, Ray Parrish

-- 
Human reviewed index of links about the computer
http://www.rayslinks.com
Poetry from the mind of a Schizophrenic
http://www.writingsoftheschizophrenic.com/





More information about the ubuntu-users mailing list