===================================
BBLinux 0.1 - Bulleting Board Linux
===================================

The following collection of files and text will help converting a Linux
system into a BBS in (almost) no time. Most of it a quick hack but should
serve as a good starting point. Any help or improvements are welcome ...
I will try to collect them, incorporate them and make them available in the
same package.

Everything is under the GPL of course.

Andreas Schiffler, andreas@karlsberg.usask.ca, andreas@milo.usask.ca
1230 11th St. E, Saskatoon, Sask, S7H 0G3, Canada

Files
-----

 README		- this file
 listcheck.c	- kick-out-program
 timecheck	- shows time left
 limitcheck	- shows exceeded quotas
 newuser	- creates an account
 xxx.sample 	- sample file from The Gnu BBS

Listcheck - Login-Time Manager for Linux
----------------------------------------

The purpose of this program is to give certain users only a certain amount
of login time. This would be a common use for Linux as a BBS system. The
program is simple and completely unoptimized but does its job well. 

Check the source code for a quick overview of what it does - all the files
and settings are hardcoded into listcheck.c at the beginning.

How it works:
-------------

The key to the timing checking is a ASCII list in /etc with two number on
each line: the user ID and the number of time intervals left. The listcheck
program is called in regular intervals with a crontab entry. If a user has a
process running, it will decrement his/her interval counter in the list. If 
the counter reaches 0, all processes of that particular user are terminated. 
The list gets reset by copying a backup list onto the current list via cron. 
Crude but effective. A warning message when time is low is currently not 
implemented (I don't care - but it should be a piece of cake to put in).

Installation:
-------------

1.) The current timing interval is 5 minutes. If you want to change that
    listcheck.c, the crontab entry and the timecheck program have to be
    changed. The current guest user ID is 500. Change it or leave it.

2.) Compile the 'listcheck' program:
     gcc -O2 listcheck.c -o listcheck

3.) Move the program 'listcheck' to the desired location i.e.
     cp listcheck /usr/bin/listcheck

4.) Create a file '/etc/usertimes' with the following syntax:
     UID1 TICK1
     UID2 TICK2
     ....
    where GIDn is the user ID for the n-th user and TICKn is the
    corresponding online time as the number of calls to 'listcheck'.
     vi /etc/usertimes

5.) Make a copy of '/etc/usertimes':
     cp /etc/usertimes /etc/usertimes.backup

6.) Add the following two lines to root's crontab:
     0,5,10,15,20,25,30,35,40,45,50,55  * * * * /usr/bin/listcheck
     59 23 * * * cp /etc/usertimes.backup /etc/usertimes

    The first line will check every 5 minutes for users to be
    kicked out (can be any interval). If TICK in /etc/usertimes is zero all
    processes of the user with UID will be terminated and killed using
    the 'kill' command. Thus giving a user a TICK of 12, will give him
    access for 1 hour each day.
    The second line will reset the count at 23:59 every day. Make sure that 
    both processes are not started at the same time as results of this
    are unknown.
    Users not listed in /etc/usertimes are unaffected.

7.) To prevent users from logging in again after their time has expired add
    the following to the '/etc/profile' file:
     
     # check timeout #
     if [ "$UID 0" = "`grep $UID /etc/usertimes`" ]; then
      echo
      echo No more time for today ... 
      echo
      logout
     fi 

     see 'profile.add' for a copy of this

8.) Reboot to activate.


9.) Included is a shell program to tell people when they will be logged out:
    timecheck

    A sensible place for this is again /usr/bin and a call from /etc/profile

10.) Included is a shell program used to create an account
     newuser

    It will attempt to mail 'hello.letter' to the new user and show you 
    'userlevels' to remind you how many minutes per $$$ you give out.

11.) The 'profile' is usually more complicated. I use lynx as the BBS front
     end. A copy of my profile is included in 'profile.sample'.
 

Other considerations for BBS use:
---------------------------------

Just some tips from my BBS (The Gnu BBS, Saskatoon, Canada, 306-652-7849)
which can get you a BBS in a matter of hours.


1. Filespace:

So prevent users from hanging the system by filling up all space (i.e. with
a 'yes >junk &') the quota kernel patches are used. 
The quota system on Linux is crude but works (1.1.8x). Three things make it
run smoothly. Give people a high LIMIT value, so that they can create large
files in /tmp. That is important for editors, downloading with lynx and
general unix power. I clean up the /tmp directory once per day check the
quota limits of all users like that, whenever I log in:

  #!/bin/bash
  echo Checking exceeded quotas of users
  echo --------------------------------------------------
  for i in /home/*; do quota -q ${i##/home/}; done


2. The Interface

As interface I use a httpd server and Lynx. That way users get a cool
hypertext interface to everything. People can download from within Lynx via
the 'D' command and the 'sz' program. The setup to get the filenames right
is as follows:

... in file /usr/lib/lynx/lynx.cfg ...

 DOWNLOADER:Xmodem:i=%s;j=/tmp/%s;mv $i $j;sx -a $j;mv $j $i:TRUE
 DOWNLOADER:Ymodem:i=%s;j=/tmp/%s;mv $i $j;sb -a $j;mv $j $i:TRUE
 DOWNLOADER:Zmodem:i=%s;j=/tmp/%s;mv $i $j;sz -aw 1024 $j;mv $j $i:TRUE


3. News and Mail

Well, mail is already installed (from the Slackware N disk set) and for news
services just install a package and it's done. 


4. Registration

I have a guest account (UID=500) with 10 minutes time. People get a intro
message and are placed into the 'mail' program to leave me their name and
address. (A HTML form would be nicer, but I have no idea about how to make
one.) The account has to be created after that.


5. Login Program

I use mgetty, since I could not get uugetty to work with modems <14.4K. Its
nice since people can use the same line as a Fax. 



What I still don't know
(and need help with !!)
-----------------------

- How to build a fidonet gateway. The program is out there ...

- HTML registration form with automatic user list generation and account
creation

 