:::WARNING::: Do not use these script with darkbot they need updated.

                     Shell Utilities Help

All shell utilities mentioned here with exception to 'configure' must be
in /scripts directory.

For support, malfunctions, suggestions, please visit
http://darkbot.sourceforge.net

----------------------------------------------------------------------

AddServer
AddUser
check-integrity
configure
convertdb (not a shell utility)
dbcron
download-databases
kill.darkbot
live-update
restart.darkbot

----------------------------------------------------------------------
###########
AddServer #
###########

Basically  what  this script does is managing your servers.ini file  by  adding
removing and changing servers and ports.

You have the option of manipulating only your local servers file or downloading
an updated server list from the  International Federation of IRC  and work with
those servers.

On all lists the servers are preceded by a number (which is not in fact part of
the files) to help you better choose or manage each entry.

On  the  remote servers list the ports displayed on the right are only for your
reference and corresponds to all available ports.  It's recommendable to select
option  2  on the menu to load the external servers before changing local ports
so you'll have updated information to deal with.

If  you decide to move all remote list to your local file,  port  6667  will be
used for all servers.  You  can  later  change that port for each server on the
main menu, option 8.

On  all  lists PgUp/Down or arrow keys scrolls the text; Q quits from the list.
CTRL+C aborts at all times.

To launch the utility write ./AddServer. For a quick server entry write:
./AddServer server port (ex:  ./AddServer irc.server.here 6667 )

----------------------------------------------------------------------
#########
AddUser #
#########

Manages user access on Darkbot
This utility displays, adds and removes user entries on your userlist.db file.
Usage: AddUser [-option|s]
 To launch the utility and go to it's menu write $0
 For a quick user entry write:
 ./AddUser userid@host level
    Ex:  ./AddUser *whateverid@*host.domain.net 2
    (It will add an user with access level 2 to all channels).\n
 ./AddUser -h  Shows this help information
 
While displaying file contents all entries are preceded by a number  (which is
not in fact part of the files)  to help you better choose or manage each user.
If  the  entries goes over screen size ( as this help text for sure will ) use
arrow keys or PgUp/Down to scroll and type  Q  to quit,  or scroll the list to
it's very end so it will  automatically exit and proceed to the next function.
CTRL + C aborts at all times.

How userlist.db is composed... How to enter values...
dat/userlist.db is the file where all user access records are stored.

Every entry should have:
<#channel(s)> <userid@host> <seen user> <level> <password> <greeting message>

When entered online the command line should be:
!ADDUSER #channel *userid@host.domain level 0 (where level must be 1,2 or 3)

- Channel field can be:
#*                       - it gives user access to all channels
#channelABC              - it gives user access to #channelABC only
#channel1,#channel2,#etc - it gives user access to #channel1,#channel2,#etc

- On the user id field
   correct          -  *userid (or) *useri*
   not recommended  -  userid (or) *
   incorrect        -  ~userid (or) *!*userid (or the use of ! and ~ anywhere)

- On the host field
   Static IPs (IP never changes) - You should use it as is, i.e.:
    if your IP is like this ...
       myhost.123.mydomain.net
       myhost.mydomain.net
       11.222.12.123
    ... you can leave it as they are.
  Dynamic IPs (IP is different on each connection)
  You must use asterisks (*) and/or question marks (?) on the changeable areas
    Examples:
    on : myhost.123.mydomain.net
       use: myhost.*.mydomain.net (or) myhost.???.mydomain.net
    on : myhost.mydomain.net
       use: *.mydomain.net
    on : 11.222.12.123
       use: 11.222.12.* (or) 11.222.*
 
 Host Masks can NOT have spaces or any other characters or symbols besides the
 ones mentioned above.

- Seen field
Starting as default value of 0 it will increase with the times Darkbot sees
the user accessing it's channels.
This field is automatically generated by Darkbot so no user intervention
is needed when adding an user online.

- Level field
User levels allowed are:
  1 = Database Management commands
  2 = Channel Operation + Database Management commands
  3 = Administrator - All commands

- Password field
When added online trough the !ADDUSER command or entered directly on the file
for the first time while adding an user should be a zero (0).
When the user issues the online command /msg Darkbot pass 0 new_password
the new password will be encrypted on the file (on latest releases).
Be aware however if you have on defines.h LOGS activated, the message issued
by the user to Darkbot will not be encrypted. Turn LOGS off if you don't
want that to happen.

- Setinfo field
It will have a default message like 'I need to use !Setinfo'. When any
value entered could have a 0 (zero), which deactivates the function, or a
greeting message Darkbot displays when the user joins a channel.
You can see a short help online by typing !SETINFO

----------------------------------------------------------------------
#################
check-integrity #
#################

    Checks all dat files for common mistakes/errors
    
    Darkbot must be offline for most of saved information be effective.
	
    Usage: <file|s|all> [-option|s]
	    
Examples:
./check-integrity all
./check-integrity info2 userlist
./check-integrity all -nointro
./check-integrity random perform -nointro -quick
./check-integrity -report

Available command line triggers for files are:
all; info2; servers; setup; perform; userlist; random
(all checks all files; random checks all files with random entries)

Available command line triggers for options are:
 -quick     Speeds up the process bypassing pauses (sleep instances)
 -nointro   Bypasses introductory information *
 -report    Shows report file contents
 -topicsize sets info2.db's topic length (default 50) *1
 -replysize sets info2.db's reply length (default 400) *1
 -default   Returns program to it's default values removing all options
 -h         Shows a brief usage help
 *  The values of these options will be retained unless you use -default
 *1 This setting is only necessary if you are using a different length
    then the one defined on defines.h file
	     
To trigger a parameter write ./check-integrity followed by one or as many
files or options you want.
- All operations are done on a working temporary file, leaving it's original
  intact.
- All removed items/entries from any file are recorded on the report file.
- No files are definitely saved after changes without a prior bakup being made
  on the original directory.

- This is a non interactive utility, i.e., no user intervention is needed.
  However, all steps of the process are paused during up to 5 seconds so
  the user can follow it's progress by reading it's messages. If the user
  wants to speed up the process option '-quick' must be used at command line
  so all sleep/pause instances will be bypassed.

 Main Features
    Line Feed check - verifies if there is a line feed at the end of files
    Empty Lines - Cleans all empty lines wherever they are on the files
    Incomplete Entries - Checks if there are topics with no replies on info2
    Duplicate Entries - Checks for repeated lines on some files
    Duplicate Topics - Checks for duplicate topics on info2
    Topic Length - Checks if topic length on info2 is under the limit
    Data Length - Checks if data length on info2 is under the limit
    RDBs check - verifies if there are RDBs on info2 without links to files
        and files on dat directory wihout RDB links
    Random Files - Checks if total number of random entries is correctly
        posted on the first line on randomstuff.ini, random.ini and all
        RDB files or removes it in case local version is RC4 or later.
    Setup.ini - Checks syntax; misplaced spaces; missing values
    Servers.ini - Checks syntax; missing ports
    Perform.ini - Default checks (empty lines and line feed)
    Userlist.db - Checks for missing '#' on channels field; missing or
        incorrect IPs; incorrect leading '~' and '*!' or missing '*' on userid
        field; user levels; seen field; password field; setinfo field

This utility executes a considerable amount of operations during
file integrity verification. It depends on the size of the files
to be checked and errors to correct the time it takes to perform
all it's functions with accuracy.
All process is done without user intervention, so be patient and
wait until it is done  or  leave it working and check afterwards
it's final results on the  integrity-report  file  or  by typing
./check-integrity -report
If you are in a rush type ./check-integrity -quick
If  you get wrong results on final counts due  to  unpredictable
characters or symbols you might have on your  files please  help
us correct the problem by participating it on the official site.
To abort all operations at any time press CTRL + C

----------------------------------------------------------------------
###########
configure #
###########

Goes over all basic configuration of your Darkbot.
You  must run this script when on first installation of Darkbot.

----------------------------------------------------------------------
###########
convertdb #
###########

(Not a shell utility)

Syntax: ./convertdb -convert

It converts old Darkbot versions userlist.db passwords (prior to series 7.0)
into an encrypted format.
You have copied your pre 7f0 userlist.db in to the dat directory
DO NOT use this utility if You have created a brand new darkbot, and have no
users.

All users added  with  this  script  will  have a password of 0
and should set their new password on IRC by issuing the command
/msg Darkbot pass 0 new_password.\n

Be aware  if  you  are logging private messages  the encryption
will not cover them,  making it  possible  to  see  passwords
on the logs.  So turn logs off on defines.h if you don't want
that to happen.

The file on scripts directory it's already compiled. However, if you
compile it's source on a non cygwin environment it's bin should
be placed on scripts directory and being so userlist relative path
should be "../dat/userlist.db" and "../dat/temp.db".
Under cygwin the executable should be placed on Darkbot's root dir
due to the necessity of cygwin dynamic library.
If that is the case read the instructions and edit source/convertdb.c


----------------------------------------------------------------------
########
dbcron #
########

Utility to auto generate crontab job on Darkbot checking if it is connected
during a cycled period of time.

When you first run it a new file is created overwriting original one and
the actual cron working engine is installed and it will remains active,
providing it's path and Darkbot's path remains the same.

If for any reason you've changed your  Darkbot directory or it's  binary
you'll need to modify the variables DBPATH DBBIN and DBPIDFILE on top of
the newly created file accordingly to the actual values.

Defaulty crontab job is of 10 mins interval. If you wish to change it
edit '0,10,20,30,40,50 * * * *'. If you don't understand it type 'man crontab'

How main engine works:
Changes to darkbot root dir; if pid file exists extracts pid number;
tests it by issuing an inoffensive kill; if pid is active exits, doing
nothing; if not means the file with pid is there but there is no active
process, so removes it. finally cheks if program bin exists then starts it.


----------------------------------------------------------------------
####################
download-databases #
####################

Downloads available pre made database files from Darkbot's site.
After download is made to your computer the pre-made database(s) will be
installed definetely on info2.db file after a series of integrity checks
done in conjunction with check-integrity utility.


----------------------------------------------------------------------
##############
kill.darkbot #
##############

Kills Darkbot pid

----------------------------------------------------------------------
#############
live-update #
#############

Updates local Darkbot files directly from Darkbot site

Program Usage:
    ./live-update [OPTION]
    ./live-update: (with no option) executes the program
    ./live-update -u  Undo last changes
    ./live-update -n  News - (latest news usually related to updates)
    ./live-update -v (v0, v1, v2) Verbose mode.
    ./live-update -h  Help info (this one)
    ./live-update -o  Turns Live Update ON or OFF
    NOTE: - By switching live-update OFF you'll not be able to receive
            live updates!
          - Settings for verbose are 0=Stealth/silent; 1=Minimal messages
            (default - no prompts if no updates present); 2=all available
            program messages.

This script checks if there is any news update, pre-made database
or a most recent code release by comparing the contents  of local
installation with the information obtained from the site.

In practice this utility starts by checking program integrity -
- if it passes goes to Darkbot site and downloads a piece of code
which contains the updates ids - those ids are compared with the
information stored locally - then checks if there is any news you
should read.
At the same time compares the installed code with most recent one -
- if there is necessity of code updates then patches all files with
the most current one, backing up all modified files. The update will
be done file by file on the same installation or by creating a new
directory with the name of the new release id on $HOME/darkbot-Ver
directory. Previous data files on dat directory are transferred to the
new installation. Old dynamic files like defines.h or darkbot.c are
transferred to the newly created source directory, with extensions .OLD.
The utility checks also if there is any new pre-made database in
conjuction with download-databases engine.
If the user wants to reverse (UNDO) the update process could do so with
the command ./live-update -u (not affecting downloaded databases).
A backup of all modified files/dirs is kept on .scriptutils/liveupdate/
working directory for the engine (do not remove it).
When typed ./liveupdate and nothing happens means there are no updates.
To do:
   - automatic update of the new defines.h file;
   - this utility being also integrated on a shell GUI.

Be advised that if you change Darkbot version from source files  this
utility will not work. There is no reason to waste time and bandwidth
on an adultered program.  The same will happen if you move or  remove
source files from their original locations.

For support, check the the site at http://darkbot.sourceforge.net


----------------------------------------------------------------------
#################
restart.darkbot #
#################

Restarts Darkbot
