summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2004-07-19 14:08:30 +0000
committerrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2004-07-19 14:08:30 +0000
commita1479a87757fb5e9b48f3c8bb5dd9cc247406f1a (patch)
tree06d23a51082a398c512ed8f1e39bdac60d4dd658 /src/bin
parent7fffea77edbe72cd66f7a55f41a3966204f9cf86 (diff)
BUILD : 1.7.4 (264) BUGS : N/A NOTES : Switched to autoconf - try to commit part 1
git-svn-id: svn://svn.anope.org/anope/trunk@264 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@169 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/bin')
-rwxr-xr-xsrc/bin/am420
-rwxr-xr-xsrc/bin/anoperc136
-rwxr-xr-xsrc/bin/cp-recursive21
-rwxr-xr-xsrc/bin/langtool239
-rwxr-xr-xsrc/bin/mydbgen207
-rwxr-xr-xsrc/bin/register101
6 files changed, 1124 insertions, 0 deletions
diff --git a/src/bin/am b/src/bin/am
new file mode 100755
index 000000000..14b6d8638
--- /dev/null
+++ b/src/bin/am
@@ -0,0 +1,420 @@
+#!/usr/bin/env perl
+
+# ====================================================================
+# anomgr: Anope Manager. Used to manage anope revision on SubVersion.
+#
+# For usage, see the usage subroutine or run the script with no
+# command line arguments.
+#
+# $Id$
+#
+# ====================================================================
+require 5.6.0;
+use strict;
+use Getopt::Std;
+use Net::FTP;
+use Cwd;
+
+######################################################################
+# Configuration section.
+my $myver="1.0";
+my $svnrev="http://www.zero.org/anosvn.php";
+my $fhint="version.log";
+
+# Default values, change or use environment variables instead.
+my $copy="anope";
+my $svnuser="";
+my $svnpath="/usr/bin";
+my $svnroot="svn://zero.org/repos/$copy";
+my $editor="/usr/bin/vi";
+
+# Environment variables SVNBINDIR and SVNROOT override the above
+# hardcoded values.
+$svnuser="$ENV{SVNUSER}" if ($ENV{SVNUSER});
+$svnpath="$ENV{SVNBINDIR}" if ($ENV{SVNBINDIR});
+$svnroot="$ENV{SVNROOT}" if ($ENV{SVNROOT});
+$editor="$ENV{EDITOR}" if ($ENV{EDITOR});
+
+# Svnlook path.
+my $svnlook = "$svnpath/svnlook";
+
+# Svn path.
+my $svn = "$svnpath/svn";
+
+# wget path. Need to change to a perl module instead...
+my $wget = "$svnpath/wget";
+
+my (
+ $rev,
+ $branch,
+ $tag,
+ $ftp,
+ $dst,
+ $ver_major,
+ $ver_minor,
+ $ver_patch,
+ $ver_build,
+ $ver_revision,
+ $ver_comment,
+ $svn_comment,
+ $cver,
+ $nver,
+ $ctrlfile,
+ $tmpfile,
+ @source,
+ %opt
+);
+
+{
+ my $ok = 1;
+ foreach my $program ($svnlook, $svn, $editor)
+ {
+ if (-e $program)
+ {
+ unless (-x $program)
+ {
+ warn "$0: required program `$program' is not executable, ",
+ "edit $0.\n";
+ $ok = 0;
+ }
+ }
+ else
+ {
+ warn "$0: required program `$program' does not exist, edit $0.\n";
+ $ok = 0;
+ }
+ }
+ exit 1 unless $ok;
+}
+
+sub usage()
+{
+ # More features to add:
+ # --diff N:M to produce a diff between revisions
+ # --bugs CLI method to add bug number to the commit message
+ # --mesg CLI methos to add the commit message
+ # --create-branch to create a branch
+ # --create-tag to create a tag
+ # --switch to switch between branches/tags
+ print "Usage: $0 <-g | -p | -f> [-r revision | -b branch | -t tag] <destination>\n";
+ print " Operations:\n";
+ print " -g Get Operation\n";
+ print " -p Put Operation\n";
+ print " -f[tar|diff] FTP Operation, retrieve latest tar or diff\n";
+ print " Selector:\n";
+ print " -r revision Retrieve by revision number\n";
+ print " -b branch Retrieve by branch name\n";
+ print " -t tag Retrieve by tag name\n";
+ print " Destination:\n";
+ print " The working copy to perform the operation in or to. The script will \n";
+ print " try to guess where that is, unless you provide a specific path.\n";
+ exit;
+}
+
+sub banner() {
+
+ print "Anope Source Managemnt Utility - Version $myver\n\n";
+
+}
+
+sub getans {
+ my $ans;
+ while (! (($ans =~ /y/) || ($ans =~ /n/))) {
+ print "*** Ready to continue? (y/n): ";
+ $ans = <STDIN>;
+ chomp($ans);
+ $ans = lc($ans);
+ # $ans = &getans();
+ }
+
+ # return $ans;
+ return ($ans eq "y") ? 1 : 0
+}
+
+sub find_conflict() {
+
+ my $filename=shift;
+ my $retval=0;
+ open (IN2, "$filename") || die "Can't open $filename\n";
+ while (<IN2>) {
+ if (/^<<<<<<</) {
+ $retval=1;
+ }
+ }
+ close(IN2);
+
+ return $retval;
+}
+
+sub do_ftp() {
+
+ my $ftpc;
+ $ftpc = Net::FTP->new("ftp.zero.org");
+ $ftpc->login("ftp","-anonymou@");
+ $ftpc->cwd("/incoming");
+
+ if ( lc($ftp) eq "tar" ) {
+ print "Retrieving latest tar ball...\n";
+ $ftpc->get("anope.tgz");
+ } elsif ( lc($ftp) eq "diff" ) {
+ print "Retrieving latest patch file...\n";
+ $ftpc->get("anope.diff");
+ } else {
+ print "Unknown type $ftp, aborting...\n";
+ }
+ $ftpc->quit();
+}
+
+sub do_get() {
+
+ my $options = "" ; # Options to be passed to the svn command
+ my $selector = "" ; # Selector to be passed to the svn command
+
+ if ($rev) {
+ $options .= "-r $rev";
+ $selector = "trunk";
+ $copy = $copy . "-$rev";
+ } elsif ($tag) {
+ $selector = "tags/$tag";
+ $copy = $copy . "-$tag";
+ } elsif ($branch) {
+ $selector = "branches/$branch";
+ $copy = $copy . "-$branch";
+ } else {
+ $selector = "trunk";
+ }
+
+ if ($dst eq undef) {
+ my $cwd = &Cwd::cwd();
+ if (-f "$cwd/$fhint") {
+ system("$svn update $options $cwd");
+ } elsif (-f "$cwd/$copy/$fhint") {
+ system("$svn update $options $cwd/$copy");
+ } else {
+ system("$svn checkout $svnroot/$selector $options $cwd/$copy");
+ }
+ } else {
+ $dst = &Cwd::cwd() if ($dst eq "\.") ;
+ if (-f "$dst/$fhint") {
+ system("$svn update $options $dst");
+ } else {
+ system("$svn checkout $svnroot/$selector $options $dst");
+ }
+ }
+}
+
+sub do_put() {
+
+ if ($dst eq undef) {
+ my $cwd = &Cwd::cwd();
+ if (-f "$cwd/$fhint") {
+ $dst = "$cwd";
+ } elsif (-f "$cwd/$copy/$fhint") {
+ $dst .= "$cwd/$copy";
+ } else {
+ print "Error: Unable to determine your working copy location.\n";
+ exit;
+ }
+ } else {
+ $dst = &Cwd::cwd() if ($dst eq "\.") ;
+ if (! -f "$dst/$fhint") {
+ print "Error: Unable to determine your working copy location.\n";
+ exit;
+ }
+ }
+
+ # Check to see if we need to update our working copy first.
+ my $nupdate;
+ open (IN, "$svn status --show-updates --verbose $dst|");
+ while (<IN>) {
+ if (/\*/) {
+ $nupdate .= "$_";
+ }
+ }
+ close(IN);
+
+ if ($nupdate ne undef) {
+ print "*** Warning: There are files modified in the repository that need\n";
+ print "*** to be merged back to your working copy before the commit can\n";
+ print "*** take place. These files are:\n";
+ print $nupdate;
+ print "Please use: $0 -g $dst\n";
+ exit;
+ }
+
+ # Get a prelim diff of the changes...
+ my $dcount=0;
+ my $conflict;
+ # open (IN, "$svn diff $dst|");
+ open (IN, "$svn status $dst|");
+ while (<IN>) {
+ if (!/^\?/) {
+ $dcount++;
+ }
+
+ if (/^C/) {
+ $_ =~ s/^C\s+//;
+ chomp($_);
+ # I don't want to use grep. But my find_conflict sub
+ # does not seem to work :( Too bad
+ if (`grep "^<<<<<<<" $_`) {
+ $conflict .= "$_\n" ;
+ } else {
+ system("$svn resolved $_");
+ }
+ }
+ }
+ close(IN);
+
+ if ($dcount == 0) {
+ print "*** Warning: There are no modified files to be commited. Are you\n";
+ print "*** sure you are in the right working copy? Verify changes with:\n";
+ print "*** $svn diff $dst\n";
+ exit;
+ }
+
+ if ($conflict ne undef) {
+ print "*** Warning: There are merge conflicts to be resolved! Please take\n";
+ print "*** a look at the following files and resolve them manually:\n\n";
+ print "$conflict\n";
+ exit;
+ }
+
+ $ctrlfile = "$dst/$fhint";
+ # Grab the current revision number. Clunky way, I know!
+ $ver_revision=`$wget -qO - $svnrev`;
+ chomp($ver_revision);
+
+ unless ($ver_revision =~ /^\d+/ and $ver_revision > 0)
+ {
+ print "*** Error: Got bogus result $ver_revision from $svnrev.\n";
+ exit;
+ }
+
+ $ver_revision++;
+ open (REV, "$ctrlfile") || die "Can't open $ctrlfile\n";
+ while (<REV>) {
+ push (@source, $_);
+ $ver_major = $_ if (/VERSION_MAJOR/);
+ $ver_minor = $_ if (/VERSION_MINOR/);
+ $ver_patch = $_ if (/VERSION_PATCH/);
+ $ver_build = $_ if (/VERSION_BUILD/);
+ }
+ close(REV);
+
+ my $junk;
+ ($junk, $ver_major) = split('"', $ver_major);
+ ($junk, $ver_minor) = split('"', $ver_minor);
+ ($junk, $ver_patch) = split('"', $ver_patch);
+ ($junk, $ver_build) = split('"', $ver_build);
+
+ $cver = "$ver_major.$ver_minor.$ver_patch ($ver_build)";
+ $nver = "$ver_major.$ver_minor.$ver_patch ($ver_revision)";
+
+ # Greet the developer
+ banner();
+ print "*** Repository : $svnroot \n";
+ print "*** Working copy : $dst \n" ;
+ print "*** Current ver. : $cver \n";
+ print "*** Updated ver. : $nver \n";
+ print "*** Files Changed: $dcount (before indent and version change)\n";
+ die ("Aborting...\n") unless &getans();
+
+ # Need to add a clause for -c "comment" and -b "buglist"
+
+ # Get developers input for commit
+ $tmpfile=".commit";
+ open (OUT, ">$tmpfile") or die ("*** Error! Unable to open $tmpfile file\n");
+ print OUT "# Anope commit utility. Please use this template for your commits.
+# Add Bugzilla bugs separated by spaces. The note part is free form.
+BUILD : $nver
+BUGS :
+NOTES : ";
+ close(OUT);
+
+ system("$editor $tmpfile");
+
+ my $tmp_comment="";
+ $ver_comment="#\n";
+ $svn_comment="";
+ open (IN, "$tmpfile") or die ("*** Error! Unable to open $tmpfile file\n");
+ while (<IN>) {
+ if ( !/^#/) {
+ $tmp_comment.="$_";
+ chomp($_);
+ $_ =~ s/\t/ /g;
+ $ver_comment.="# $_\n";
+ $svn_comment.="$_ ";
+ }
+ }
+ close(IN);
+
+ $svn_comment =~ s/\s\s+/ /g;
+ # Confirm the commit one last time...
+ print "*** Ready to commit, please verify:\n";
+ print "\n$tmp_comment\n";
+
+ die ("Aborting...\n") unless &getans();
+
+ print "*** Running Indent...\n";
+ system("indent -kr -nut *.c");
+ system("rm -f *~");
+
+ print "*** Bumping the revision number...\n";
+ # Re-write the control file
+ open(OUT, ">$ctrlfile") or die ("*** Error! Unable to open $ctrlfile ... aborting");
+ foreach (@source) {
+ if (/^VERSION_BUILD/) {
+ $_ =~ s/\"\d+\"/\"$ver_revision\"/;
+ } elsif (/# \$Log\$/) {
+ $_ .= "$ver_comment";
+ }
+ print OUT $_;
+ }
+ close(OUT);
+
+ print "*** Starting the upload...\n\n";
+ my $rval=system("$svn commit $dst --username='$svnuser' --message '$svn_comment'");
+ if ( $rval ) {
+ print "*** Error: Unable to complete commit. Rolling back....\n\n";
+ system("$svn revert $ctrlfile");
+ }
+
+}
+
+{
+ usage() if (! @ARGV);
+
+ my $opt = 'hgpf:r:b:t:';
+ getopts ("$opt", \%opt) or usage();
+ usage() if $opt{h};
+
+ usage() if ($opt{g} && $opt{p});
+ usage() if ($opt{g} && $opt{f});
+ usage() if ($opt{p} && $opt{f});
+ usage() if ($opt{r} && $opt{b});
+ usage() if ($opt{r} && $opt{t});
+ usage() if ($opt{b} && $opt{t});
+
+ $rev = $opt{r} ;
+ $branch = $opt{b} ;
+ $tag = $opt{t} ;
+ $ftp = $opt{f} ;
+ $dst = shift;
+
+ if ($rev ne undef) {
+ unless ($rev =~ /^\d+/ and $rev > 0)
+ {
+ print "*** Error: Revision number '$rev' must be an integer > 0.\n";
+ exit;
+ }
+ }
+
+ do_ftp() if $opt{f};
+ do_get() if $opt{g};
+ do_put() if $opt{p};
+ print "*** Done!\n";
+
+}
+
+
diff --git a/src/bin/anoperc b/src/bin/anoperc
new file mode 100755
index 000000000..bc0704f12
--- /dev/null
+++ b/src/bin/anoperc
@@ -0,0 +1,136 @@
+#!/bin/sh
+
+###############################################
+# Set Variables
+###############################################
+
+# PID FILE NAME (e.g. services.pid)
+PIDFILE="services.pid"
+
+# FULL PATH TO ANOPE DIRECTORY e.g. /home/ribosome/services/
+# YOU MUST INCLUDE TRAILING SLASH
+ANOPEBIN=""
+
+# SERVICES EXECUTABLE NAME (e.g. services)
+ANOPROG="services"
+
+# SCRIPT VERSION NUMBER (DO NOT ALTER)
+ARCVERSION="1.1"
+
+
+################################################
+# END OF CONFIGURATION
+# YOU ARE NOT REQUIRED TO CHANGE ANYTHING BELOW
+################################################
+
+isAnopeRunning () {
+if [ ! -f $ANOPEBIN$PIDFILE ] ; then
+ echo "Warning: Anope is not currently running"
+ exit 1
+fi
+
+PID=`cat $ANOPEBIN$PIDFILE`
+
+if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then
+ echo "Warning: Anope is not currently running"
+ exit 1
+fi
+}
+
+if [ "$ANOPEBIN" = "" ] ; then
+ echo "Error: Please open this file set the variables correctly";
+ exit 1
+fi
+
+if [ ! -f $ANOPEBIN$ANOPROG ] ; then
+ echo "Error: $ANOPEBIN$ANOPROG cannot be accessed"
+ exit 1
+fi
+
+if [ "$1" = "start" ] ; then
+
+if [ -f $ANOPEBIN$PIDFILE ] ; then
+ PID=`cat $ANOPEBIN$PIDFILE`
+ if [ `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` = 1 ] ; then
+ echo "Warning! Anope is already running"
+ exit 1
+ fi
+fi
+ echo "Starting Anope"
+ shift
+ $ANOPEBIN$ANOPROG $*
+ sleep 1
+ if [ ! -f $ANOPEBIN$PIDFILE ] ; then
+ echo "Unfortunately it seems Anope did not start successfully"
+ echo "This error has been logged in your Anope Log file"
+ echo "Located in "$ANOPEBIN"logs/"
+ echo "This may help you diagnose the problem"
+ echo "Further help may be available from http://www.anope.org"
+ exit 1
+ fi
+ PID=`cat $ANOPEBIN$PIDFILE`
+ if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then
+ echo "Unfortunately it seems Anope did not start successfully"
+ echo "This error has been logged in your Anope Log file"
+ echo "Located in "$ANOPEBIN"logs/"
+ echo "This may help you diagnose the problem"
+ echo "Further help may be available from http://www.anope.org"
+ exit 1
+ fi
+elif [ "$1" = "stop" ] ; then
+ isAnopeRunning
+ echo "Terminating Anope"
+ PID=`cat $ANOPEBIN$PIDFILE`
+ kill -SIGTERM $PID
+
+elif [ "$1" = "status" ] ; then
+ if [ -f $ANOPEBIN$PIDFILE ] ; then
+ PID=`cat $ANOPEBIN$PIDFILE`
+ if [ `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` = 1 ] ; then
+ echo "Anope is currently running"
+ exit 1
+ fi
+ fi
+
+ echo "Anope is not currently running"
+
+elif [ "$1" = "restart" ] ; then
+ isAnopeRunning
+ echo "Restarting Anope"
+ PID=`cat $ANOPEBIN$PIDFILE`
+ kill -SIGHUP $PID
+
+elif [ "$1" = "rehash" ] ; then
+ isAnopeRunning
+ echo "Saving Databases and Rehashing Configuration"
+ PID=`cat $ANOPEBIN$PIDFILE`
+ kill -SIGUSR2 $PID
+
+elif [ "$1" = "version" ] ; then
+ $ANOPEBIN$ANOPROG -version
+
+elif [ "$1" = "help" ] ; then
+ if [ "$2" = "paramlist" ] ; then
+ $ANOPEBIN$ANOPROG -help
+ else
+ echo "AnopeRC is a remote control script for easy"
+ echo "controlling of Anope from the command console"
+ echo "$0 start Start Anope"
+ echo " Additional parameters may be passed"
+ echo " (e.g. $0 start -nofork)"
+ echo " For a list of type $0 $1 paramlist"
+ echo "$0 stop Shutdown Anope"
+ echo "$0 status Show Anope's Status"
+ echo "$0 restart Restart Anope (Databases will be saved)"
+ echo "$0 rehash Rehash Configuration and Save Databases"
+ echo "$0 version Return Anope Version and Build Information"
+ echo "$0 help Show this help menu"
+ echo "If you need further help please check the /docs/"
+ echo "folder or make use of our extensive online support at"
+ echo "http://www.anope.org"
+ fi
+
+else
+ echo "Anope Remote Control ($ARCVERSION)"
+ echo "Usage: $0 [start|stop|status|restart|rehash|version|help]"
+fi
diff --git a/src/bin/cp-recursive b/src/bin/cp-recursive
new file mode 100755
index 000000000..e51230db7
--- /dev/null
+++ b/src/bin/cp-recursive
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ $1 = "-t" ] ; then
+ shift
+fi
+if [ ! "$2" ] ; then
+ echo >&2 Usage: $0 '<sourcedir> <targetdir>'
+ exit 1
+fi
+if [ -d "$1" ] ; then
+ dir="$1"
+else
+ dir="`echo $1 | sed 's#\(.*\)/.*#\1#'`"
+fi
+while [ "$2" ] ; do
+ shift
+done
+if [ ! -d $1 ] ; then
+ mkdir -p $1 || exit 1
+fi
+/bin/tar -Ccf $dir - . | /bin/tar -Cxf $1 -
diff --git a/src/bin/langtool b/src/bin/langtool
new file mode 100755
index 000000000..c1072760c
--- /dev/null
+++ b/src/bin/langtool
@@ -0,0 +1,239 @@
+#!/usr/bin/perl
+#
+# Ribosome's all in one language tool
+# 1) Compares to check for missing lines
+# 2) Compares to check for equal lines
+# 3) Fixes (on request) missing lines
+# 4) Checks for errors in lines
+# 5) Checks for long lines (>60 characters)
+#
+
+# Check to see if we have received arguments
+if (!$ARGV[0]) {
+print "Usage: $0 [language file]\n";
+exit;
+}
+
+# If yes, set $sourcefile to the language filename
+$testagainst = $ARGV[0];
+
+# Set $sourcefile to en_us language file
+$sourcefile = "en_us.l";
+
+# Number of Keys in File, Number of Equal Lines, Number of Missing Lines
+# Fixed Lines (optional) and Number of Format Error Lines, Number of Long Lines
+my $numberlines = 0;
+my $equallines = 0;
+my $missinglines = 0;
+my $fixedlines = 0;
+my $errorline = 0;
+my $longlines = 0;
+
+# Array to hold the lines from the source file and explosion array for long line check
+
+my @sourcearray;
+my @explosion;
+
+# Create associative arrays which will contain keys and definitions
+# One for the control source and one for what is being tested against
+
+my %sourcehash= ();
+my %testhash= ();
+
+# Check if Files Exist
+
+if (! -f $sourcefile) {
+print "Critical Error: The source file does not exist or is unreadable.\nNote: This tool must be run from the language directory.\n";
+exit;
+}
+
+if (! -f $testagainst) {
+print "Critical Error: The language file does not exist or is unreadable\n";
+exit;
+}
+###########################################
+# Function to load sourcefile into memory #
+###########################################
+
+sub load_sourcefile {
+
+ my $_key; # This variable will hold the key
+ my $_def; # This variable will hold the definition
+ my $line; # This variable will hold the current line
+
+ open (SOURCEFILE, "< $sourcefile"); # Open the source file
+ while (<SOURCEFILE>) { # For each line the source file
+ $line = $_; # $line is set to the line in the source file
+
+ # Skip comments
+ if (/^#/) { # This checks for # which indicates comment
+ next; # If detected, the next line is skipped to
+ }
+
+ # Start of a key
+ if (/^[A-Z]/) { # Checks to see if the line is a key
+ chomp($line); # Removes things that shouldn't be at the end
+ push (@sourcearray, $line); # Puts the line into the source array
+ # If a key is defined, load definition into the hash
+ if ($_key ne undef) { # If the key is defined
+ $sourcehash{$_key} = $_def; # Add the definition to the associative array
+ }
+ $_key=$line; # Set the key to the line
+ $_def=""; # Reset the definition
+ next; # Move onto the next line
+ }
+
+ if ($_key ne undef) { # If the key is set already
+ $_def.=$line; # The definition is the current line
+ }
+
+ $sourcehash{$_key} = $_def; # Load the definition into the associative array
+ } # End of while which reads lines
+
+ close (SOURCEFILE); # Close the source file
+
+} # End of load_sourcefile function
+
+#################################################
+# Function to load testagainst file into memory #
+#################################################
+
+sub load_testagainst {
+
+ my $_key; # This variable will hold the key
+ my $_def; # This variable will hold the definition
+ my $line; # This variable will hold the current line
+
+ open (TESTAGAINSTFILE, "< $testagainst"); # Open the file containing the control lines
+ while (<TESTAGAINSTFILE>) { # For each line in the file
+ $line = $_; # $line is set to the lines value
+
+
+ # Skip comments
+ if (/^#/) { # This checks for # which indicates comment
+ next; # If detected, the next line is skipped to
+ }
+
+ # Start of a key
+ if (/^[A-Z]/) { # Checks to see if the line is a key
+ chomp($line); # Removes things that shouldn't be at the end
+
+
+ if ($_key ne undef) { # If the key is defined
+ $testhash{$_key} = $_def; # Add the definition to the associative array
+ }
+ $_key=$line; # Set the key to the line
+ $_def=""; # Reset the definition
+ next; # Move onto the next line
+ }
+
+ if ($_key ne undef) { # If the key is set already
+ $_def.=$line; # The definition is the current line
+ }
+
+ $testhash{$_key} = $_def; # Load the definition into the associative array
+ } # End of while which reads lines
+ close (TESTAGAINSTFILE); # Close the source file
+
+}
+
+
+sub get_format { # Function to get the formatting from a string
+ my $fmt="";
+ my $str=shift; # Get the input
+
+ while ($str =~ m/%\w/g) {
+ $fmt .= $&;
+ }
+
+ return $fmt; # Return the formatting
+}
+
+
+load_sourcefile; # Call function to load the source file
+load_testagainst; # Call function to load the test file
+
+if (!grep(/^LANG_NAME/,%testhash)) {
+print "Critical Error: $ARGV[0] is not a valid language file!\n";
+exit;
+}
+
+open (LOG,"> langcheck.log"); # Open logfile for writing
+
+foreach $sourcearray (@sourcearray) { # For each key stored in the source array
+ my $_key=$_; # Store key from source array in $_key
+
+ if ((get_format($sourcehash{$sourcearray})) ne (get_format($testhash{$sourcearray}))) {
+ if ($sourcearray !~ STRFTIME ) {
+ $errorline++;
+ print LOG "FORMAT: $sourcearray - (expecting '".get_format($sourcehash{$sourcearray})."' and got '".get_format($testhash{$sourcearray})."')\n";
+ } }
+
+ if ($testhash{$sourcearray} eq $sourcehash{$sourcearray} ) {
+ # If the definitions between the source and the test are equal
+ $equallines++; # Number of equal lines increases
+ print LOG "EQUAL: $sourcearray\n"; # Line is written to logfile
+ }
+
+ if (!grep(/^$sourcearray/,%testhash)) { # If the key is found in the testhash associative array
+ $missinglines++; # Increase missing lines
+ print LOG "MISSING: $sourcearray\n"; # Line is written to logfile
+ }
+
+ @explosion = split(/\n/, $testhash{$sourcearray});
+ foreach $explosion (@explosion) {
+ $explosion =~ s/\002//g;
+ $explosion =~ s/\037//g;
+ if (length($explosion) > 61) {
+ print LOG "LONGLINE: $sourcearray (".substr($explosion,1,30)."...)\n";
+ $longlines++;
+ }
+ }
+
+$numberlines++; # Increase the number of lines tested by 1
+}
+close (LOG); # Close the logfile
+
+
+#########################
+# Show the test results #
+#########################
+
+print "Calculation Results:\n";
+print "----------------------------------\n";
+print "[$numberlines] line(s) were compared\n";
+print "[$equallines] line(s) were found to equal their $sourcefile counterpart(s)\n";
+print "[$missinglines] line(s) were found to be missing\n";
+print "[$longlines] line(s) were found to be long (>60 chars)\n";
+print "[$errorline] line(s) were found to have formatting errors\n";
+print "The specific details of the test have been saved in langcheck.log\n";
+
+if ($missinglines) { # If missing lines exist
+print "----------------------------------\n";
+print "Missing line(s) have been detected in this test, would you like to fix the file?\n";
+print "This automatically inserts values from the control file ($sourcefile) for the missing values\n";
+print "y/N? (Default: No) ";
+
+my $input = <STDIN>; # Ask if the file should be fixed
+if ((substr($input,0,1) eq "y") || (substr($input,0,1) eq "Y")) { # If Yes...
+
+open (FIX, ">> $testagainst"); # Open the file and append changes
+
+foreach $sourcearray (@sourcearray) { # For each key stored in the source array
+ my $_key=$_; # Store key from source array in $_key
+
+ if (!grep(/^$sourcearray/,%testhash)) { # If the key is not found in the testhash associative array
+ print FIX "$sourcearray\n$sourcehash{$sourcearray}"; # Add the line(s) to the language file
+ $fixedlines++; # Increase the fixed line count
+ }
+}
+
+close (FIX); # Close file after fixing
+
+print "Fixing Compete. [$fixedlines] line(s) fixed.\n";
+exit; # And Exit!
+}
+ # Otherwise, quit without fixing
+print "Exiting. The language file has NOT been fixed.\n";
+
+}
diff --git a/src/bin/mydbgen b/src/bin/mydbgen
new file mode 100755
index 000000000..dcff99407
--- /dev/null
+++ b/src/bin/mydbgen
@@ -0,0 +1,207 @@
+#!/bin/sh
+#
+# $Id$
+
+# Location of the .sql file with the schema
+DBSQL="tables.sql"
+
+# Schema Version
+SVER="1"
+
+# Local Version, defaults to 0
+LVER="0"
+
+TFILE="/tmp/.anopedb.$$"
+
+if [ "`eval echo -n 'a'`" = "-n a" ] ; then
+ c="\c"
+else
+ n="-n"
+fi
+
+# Fix for bug 10
+for try in HOME/services anope/data ../data data .. .
+do
+ if [ -f "$try/$DBSQL" ]; then
+ DBFILE="$try/$DBSQL"
+ fi
+done
+
+if [ ! -f "./$DBFILE" ] ; then
+ echo "Error: Required file $DBSQL was not found!";
+ exit
+fi
+
+echo ""
+echo "This script will guide you through the process of configuring your Anope"
+echo "installation to make use of MySQL support. This script must be used for both"
+echo "new installs as well as for upgrading for users who have a previous version"
+echo "of Anope installed"
+
+while [ -z "$SQLHOST" ] ; do
+ echo ""
+ echo "What is the hostname of your MySQL server?"
+ echo $n "-> $c"
+ read cc
+ if [ ! -z "$cc" ] ; then
+ SQLHOST=$cc
+ fi
+done
+
+while [ -z "$SQLUSER" ] ; do
+ echo ""
+ echo "What is your MySQL username?"
+ echo $n "-> $c"
+ read cc
+ if [ ! -z "$cc" ] ; then
+ SQLUSER=$cc
+ fi
+done
+
+OLD_TTY=`stty -g`
+
+echo ""
+echo "What is your MySQL password?"
+echo $n "-> $c"
+stty -echo echonl
+read cc
+if [ ! -z "$cc" ] ; then
+ SQLPASS=$cc
+fi
+stty $OLD_TTY
+
+mysqlshow -h$SQLHOST -u$SQLUSER -p$SQLPASS >/dev/null 2>&1
+if test "$?" = "1" ; then
+ echo "Error: Unable to login, verify your login/password and hostname"
+ exit
+fi
+
+while [ -z "$SQLDB" ] ; do
+ echo ""
+ echo "What is the name of the Anope SQL database?"
+ echo $n "-> $c"
+ read cc
+ if [ ! -z "$cc" ] ; then
+ SQLDB=$cc
+ fi
+done
+
+MYSQLDUMP="mysqldump -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB"
+MYSQLSHOW="mysqlshow -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB"
+MYSQL="mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB"
+
+echo ""
+
+$MYSQLSHOW | grep -q $SQLDB
+if test "$?" = "1" ; then
+ echo -n "Unable to find databse, creating... "
+ mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS -Bs -e "create database $SQLDB" >/dev/null 2>&1
+ if test "$?" = "0" ; then
+ echo "done!"
+ else
+ echo "failed!"
+ FAILED="$FAILED 'database creation'"
+ fi
+fi
+
+$MYSQL -Bs -e "show tables like 'anope_os_core'" | grep -q anope_os_core
+if test "$?" = "1" ; then
+ echo -n "Unable to find Anope schema, creating... "
+ $MYSQL < $DBFILE
+ if test "$?" = "0" ; then
+ echo "done!"
+ else
+ echo "failed!"
+ FAILED="$FAILED 'schema creation'"
+ fi
+else
+ # Introduced on Anope 1.6.0 -> Table anope_info
+ $MYSQL -Bs -e "show tables like 'anope_info'" | grep -q anope_info
+ if test "$?" = "1" ; then
+ echo -n "Unable to find Anope info table, creating... "
+ echo "CREATE TABLE anope_info (version int, date datetime) TYPE=MyISAM" > $TFILE
+ mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1
+ if test "$?" = "0" ; then
+ echo "done!"
+
+ else
+ echo "failed!"
+ FAILED="$FAILED 'anope_info table'"
+ fi
+ else
+ LVER="$($MYSQL -sB -e "select version from anope_info")"
+ if test "x$LVER" = "x" ; then
+ LVER=0
+ fi
+ fi
+
+ # Introduced on Anope 1.5.14.5 -> anope_cs_info.memomax
+ $MYSQL -Bs -e "describe anope_cs_info memomax" 2> /dev/null | grep -q memomax
+ if test "$?" = "1" ; then
+ echo -n "Unable to find anope_cs_info.memomax, altering... "
+ echo "ALTER TABLE anope_cs_info ADD memomax smallint unsigned NOT NULL default 0" > $TFILE
+ mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1
+ if test "$?" = "0" ; then
+ echo "done!"
+
+ else
+ echo "failed!"
+ FAILED="$FAILED 'anope_cs_info.memomax alter'"
+ fi
+ fi
+
+ # Introduced on Anope 1.5.14.5 -> anope_cs_info.ttb
+ $MYSQL -Bs -e "describe anope_cs_info ttb" 2> /dev/null | grep -q ttb
+ if test "$?" = "1" ; then
+ echo -n "Unable to find anope_cs_info.ttb, altering... "
+ echo "ALTER TABLE anope_cs_info ADD ttb smallint NOT NULL default 0" > $TFILE
+ mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1
+ if test "$?" = "0" ; then
+ echo "done!"
+
+ else
+ echo "failed!"
+ FAILED="$FAILED 'anope_cs_info.ttb alter'"
+ fi
+ fi
+
+
+fi
+
+# Insert initial version number. This will have to be redesigned for 1.7
+if [ $LVER -ne $SVER ]; then
+echo -n "Inserting initial version number... "
+$MYSQL -Bs -e "delete from anope_info"
+echo "INSERT INTO anope_info (version, date) VALUES ($SVER, now())" > $TFILE
+$MYSQL < $TFILE >/dev/null 2>&1
+if test "$?" = "0" ; then
+ echo "done!"
+else
+ echo "failed!"
+ FAILED="$FAILED 'version insert'"
+fi
+fi
+
+rm -f $TFILE
+if test "x$FAILED" = "x" ; then
+ # Try to find out more about this installation
+ SQLSOCK="$(mysql_config --socket 2> /dev/null)"
+ SQLPORT="$(mysql_config --port 2> /dev/null)"
+ echo ""
+ echo "Your MySQL setup is complete and your Anope schema is up to date. Make"
+ echo "sure you configure MySQL on your services.conf file prior to launching"
+ echo "Anope with MySQL support. Your configuration values are:"
+ echo ""
+ echo "MysqlHost \"$SQLHOST\""
+ echo "MysqlUser \"$SQLUSER\""
+ echo "MysqlPass \"$SQLPASS\""
+ echo "MysqlName \"$SQLDB\""
+ echo "MysqlSock \"$SQLSOCK\""
+ echo "MysqlPort \"$SQLPORT\""
+ echo ""
+else
+ echo "The following operations failed:"
+ echo "$FAILED"
+fi
+
+exit
diff --git a/src/bin/register b/src/bin/register
new file mode 100755
index 000000000..5162e44e4
--- /dev/null
+++ b/src/bin/register
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+###############################################
+# Set Variables
+###############################################
+
+# CONFIGURATION CACHE (e.g. ../config.cache)
+CACHEFILE="../config.cache"
+
+# REGISTRATION INFORMATION CACHE FILE (no need to alter this)
+REGCACHE="register.cache"
+
+# SENDMAIL PATH
+SENDMAIL="/usr/sbin/sendmail"
+
+# SCRIPT VERSION NUMBER (DO NOT ALTER)
+REGISTERVERSION="1.2"
+
+# DO NOT CHANGE IF YOU WANT TO REGISTER WITH ANOPE
+REGISTRYADDRESS="register@anope.org"
+
+################################################
+# END OF CONFIGURATION
+# YOU ARE NOT REQUIRED TO CHANGE ANYTHING BELOW
+################################################
+
+if [ $0 != "./register" ] ; then
+ echo "Warning: Run this file while in the /bin/ directory (e.g. ./register)"
+ exit 1
+fi
+
+if [ ! -f $CACHEFILE ] ; then
+ echo "Warning: Configuration cache file missing. Run ./configure"
+ exit 1
+fi
+
+if [ ! -f $SENDMAIL ] ; then
+ echo "Warning: Sendmail cannot be found. Please open this file and set variable correctly"
+ exit 1;
+fi
+
+clear
+
+if [ -f $REGCACHE ] ; then
+ echo "Previous registration cache file found. Removing..."
+ rm $REGCACHE
+fi
+
+ echo "##################################################"
+ echo "Anope registration script (v$REGISTERVERSION)"
+ echo "##################################################"
+ echo "This script allows you to register your network"
+ echo "with the Anope central registry. This gives us"
+ echo "an idea of how many networks use Anope and what options"
+ echo "they compile with so we can spend more time developing"
+ echo "options that are more widely used. Note: The options"
+ echo "you selected in ./configure will be sent."
+ echo "You will be asked a series of questions, if you wish"
+ echo "to be listed in the public network database all the"
+ echo "information will be required."
+ echo "NOTE: NO PRIVATE OR SENSITIVE INFORMATION WILL BE SENT"
+ echo "##################################################"
+ echo "Would you like to register? [Type YES to continue]"
+ read answer
+
+if [ $answer = "YES" ] ; then
+
+ echo "Beginning registration..."
+ echo "1. What is your network name? (e.g. Anope IRC Network)"
+ read NETWORKNAME
+ echo CONNECTADDRESS=\"$NETWORKNAME\" >> $REGCACHE
+ echo "2. What is your network's connection address (e.g. irc.anope.org)"
+ read CONNECTADDRESS
+ echo CONNECTADDRESS=\"$CONNECTADDRESS\" >> $REGCACHE
+ echo "3. Primary contact email address? (e.g. irc-admin@anope.org)"
+ read CONTACTEMAIL
+ echo CONTACTEMAIL=\"$CONTACTEMAIL\" >> $REGCACHE
+ echo "4. What is your network's website address (e.g. http://www.anope.org)"
+ read WEBSITEADDRESS
+ echo WEBSITEADDRESS=\"$WEBSITEADDRESS\" >> $REGCACHE
+ echo "5. Would you like your network to be listed in a public database?"
+ echo "[Please type YES if you would like to be listed]"
+ read LISTED
+ echo LISTED=\"$LISTED\" >> $REGCACHE
+ echo "6. (Bonus Devel-Only Question) Why did the chicken cross the road?!"
+ read BONUS
+ echo BONUS=\"$BONUS\" >> $REGCACHE
+ echo >> $REGCACHE
+ echo "Processing registration..."
+ cat $CACHEFILE >> $REGCACHE
+ $SENDMAIL $REGISTRYADDRESS < $REGCACHE
+ if [ -f $REGCACHE ] ; then
+ echo "Cleaning up..."
+ rm $REGCACHE
+ fi
+ echo "Registration Competed. Thank you for registering Anope."
+ exit 0;
+
+fi
+
+echo "Registration Cancelled"