summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-09-25 04:19:15 -0400
committerAdam <Adam@anope.org>2011-09-25 04:19:15 -0400
commit1f2399de364c09adcce4193895cd362d80ffdfc5 (patch)
tree5f40fc531f22c174b6e10bb7bc12842a4a21d30b /src/bin
parent43201ead9575a74e350710bc191f4ac67366aca7 (diff)
Added a new database format and sqlite support. Also moved db-convert to a module.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/CMakeLists.txt2
-rwxr-xr-xsrc/bin/cp-recursive21
-rwxr-xr-xsrc/bin/langtool239
-rwxr-xr-xsrc/bin/mydbgen148
4 files changed, 1 insertions, 409 deletions
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
index 7c6fe514b..cb110edb5 100644
--- a/src/bin/CMakeLists.txt
+++ b/src/bin/CMakeLists.txt
@@ -1,7 +1,7 @@
# If not on Windows, generate anoperc and install it along with mydbgen
if(NOT WIN32)
configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.in ${Anope_BINARY_DIR}/src/bin/anoperc)
- install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc ${CMAKE_CURRENT_SOURCE_DIR}/mydbgen
+ install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc
DESTINATION bin
)
diff --git a/src/bin/cp-recursive b/src/bin/cp-recursive
deleted file mode 100755
index e51230db7..000000000
--- a/src/bin/cp-recursive
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/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
deleted file mode 100755
index c1072760c..000000000
--- a/src/bin/langtool
+++ /dev/null
@@ -1,239 +0,0 @@
-#!/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
deleted file mode 100755
index 12bee8063..000000000
--- a/src/bin/mydbgen
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/bin/sh
-#
-
-# Location of the .sql file with the schema
-DBSQL="tables.sql"
-
-# Schema Version
-SVER="2"
-
-# Local Version, defaults to 0
-LVER="0"
-
-TFILE="/tmp/.anopedb.$$"
-
-if [ "`eval echo -n 'a'`" = "-n a" ] ; then
- c="\c"
-else
- n="-n"
-fi
-
-DBFILE=../data/$DBSQL
-
-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
-SQLPASS_PREFIX=""
-if [ ! -z "$cc" ] ; then
- SQLPASS_PREFIX="-p"
- SQLPASS=$cc
-fi
-stty $OLD_TTY
-
-mysqlshow -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$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 $SQLPASS_PREFIX$SQLPASS $SQLDB"
-MYSQLSHOW="mysqlshow -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS $SQLDB"
-MYSQL="mysql -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS $SQLDB"
-
-echo ""
-
-$MYSQLSHOW | grep -q $SQLDB
-if test "$?" = "1" ; then
- echo -n "Unable to find databse, creating... "
- mysql -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$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
- echo "done!"
-fi
-
-echo ""
-
-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
- SQLPORT="$(mysql_config --port 2> /dev/null)"
- if test "$SQLPORT" = "0" ; then
- SQLPORT=3306
- fi
- 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."
- echo ""
-else
- echo "The following operations failed:"
- echo "$FAILED"
-fi
-
-exit