diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/bin/am | 499 | ||||
-rwxr-xr-x | src/bin/mydbgen | 222 | ||||
-rw-r--r-- | src/mypasql.def | 10 |
3 files changed, 0 insertions, 731 deletions
diff --git a/src/bin/am b/src/bin/am deleted file mode 100755 index df9a71a14..000000000 --- a/src/bin/am +++ /dev/null @@ -1,499 +0,0 @@ -#!/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="evil_closet_monkey"; -my $svnpath="/usr/bin"; -my $svnroot="svn://svn.anope.org/$copy"; -my $editor="/usr/bin/mcedit"; - -# 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, - $proto, - $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 | -l> [-r revision | -b branch | -t tag | -P proto] <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 " -l List Operation, for valid selector options\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 " -P proto Retrieve by prototype 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_lst() { - my $out; - print "*** BRANCHES:\n"; - print "trunk (DEFAULT)\n"; - open (IN, "$svn list $svnroot/branches|"); - while (<IN>) { - if (! /proto/) { - $out="$_"; - $out =~ s/\/$//; - print "$out"; - } - } - close(IN); - - print "\n*** PROTOTYPES:\n"; - open (IN, "$svn list $svnroot/branches/proto|"); - while (<IN>) { - $out="$_"; - $out =~ s/\/$//; - chomp($out); - if (/bahamut18/) { - $out .= "\t(OBSOLETE)"; - } elsif (/capab/) { - $out .= "\t(OBSOLETE)"; - } - print "$out\n"; - } - close(IN); - - print "\n*** TAGS:\n"; - open (IN, "$svn list $svnroot/tags|"); - while (<IN>) { - $out="$_"; - $out =~ s/\/$//; - print "$out"; - } - close(IN); - print "\n"; - -} - -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 = "$tag"; - } elsif ($branch) { - $selector = "branches/$branch"; - $copy = $copy . "-$branch"; - } elsif ($proto) { - $selector = "branches/proto/$proto"; - $copy = "$proto"; - } 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`; - $ver_revision=`svnversion . | sed "s/.*:\\\(.*\\\)/\\1/" | cut -d 'M' -f 1 | cut -d 'S' -f 1`; - 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(); - - - # Check to see if we need to update our working copy first. - my $svnrepo; - open (IN, "$svn info|"); - while (<IN>) { - if (/URL/) { - $svnrepo = "$_"; - $svnrepo =~ s/URL: //; - } - } - close(IN); - - 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"; - my $prefix="."; - if (-d "src") { - $prefix="src"; - } - system("indent -kr -nut $prefix/*.c"); - system("rm -f $prefix/*~"); -# if (-d "src/core") { -# system("indent -kr -nut src/core/*.c"); -# system("rm -f src/core/*~"); -# } -# if (-d "src/protocol") { -# system("indent -kr -nut src/protocol/*.c"); -# system("rm -f src/protocol/*~"); -# } - - 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 = 'hgplf:r:b:t:P:'; - getopts ("$opt", \%opt) or usage(); - usage() if $opt{h}; - - usage() if ($opt{g} && $opt{p}); - usage() if ($opt{g} && $opt{f}); - usage() if ($opt{g} && $opt{l}); - usage() if ($opt{p} && $opt{f}); - usage() if ($opt{p} && $opt{l}); - usage() if ($opt{f} && $opt{l}); - usage() if ($opt{r} && $opt{b}); - usage() if ($opt{r} && $opt{t}); - usage() if ($opt{b} && $opt{t}); - usage() if ($opt{b} && $opt{P}); - - $rev = $opt{r} ; - $branch = $opt{b} ; - $tag = $opt{t} ; - $ftp = $opt{f} ; - $proto = $opt{P} ; - $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_lst() if $opt{l}; - do_ftp() if $opt{f}; - do_get() if $opt{g}; - do_put() if $opt{p}; - print "*** Done!\n"; - -} - - diff --git a/src/bin/mydbgen b/src/bin/mydbgen deleted file mode 100755 index e513a4917..000000000 --- a/src/bin/mydbgen +++ /dev/null @@ -1,222 +0,0 @@ -#!/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 -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 - # 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 $SQLPASS_PREFIX$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 $SQLPASS_PREFIX$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 $SQLPASS_PREFIX$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 - - # Introduced on Anope 1.7.7 -> status smallint to inst unsigned. - echo "Blindly altering status for bigger capacity... " - echo "ALTER TABLE anope_ns_alias CHANGE status status int(11) unsigned NOT NULL default 0" > $TFILE - mysql -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 - - # Introduced on Anope 1.7.8 (620) proxy scanner removed. - echo "Removing proxy scanner cache... " - echo "DROP TABLE IF EXISTS anope_os_cache" > $TFILE - mysql -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 - - echo "done!" - -fi - -echo "" - -# 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/mypasql.def b/src/mypasql.def deleted file mode 100644 index f04df9556..000000000 --- a/src/mypasql.def +++ /dev/null @@ -1,10 +0,0 @@ -EXPORTS
-mysql_Connect
-mysql_Error
-mysql_SelectDb
-mysql_Query
-mysql_NumRows
-mysql_NumFields
-mysql_LoadFromFile
-mysql_FetchRow
-mysql_FetchField
|