From 47489169a1b482b14ff0efe0f6aa5d143ffca391 Mon Sep 17 00:00:00 2001 From: xrogaan Date: Sun, 30 Dec 2007 12:43:56 +0000 Subject: [PATCH] 24 "adding some tools for releases. more extended recognition of options passed by the command line (help need to be write). adding a config file." --- config.php | 35 +++++++++++++++++++ main.php | 99 ++++++++++++++++++++++++++++++++++++------------------ makebuild.sh | 20 +++++++++++ release-cleanup.sh | 16 +++++++++ 4 files changed, 137 insertions(+), 33 deletions(-) create mode 100644 config.php create mode 100755 makebuild.sh create mode 100755 release-cleanup.sh diff --git a/config.php b/config.php new file mode 100644 index 0000000..50ef5bc --- /dev/null +++ b/config.php @@ -0,0 +1,35 @@ +. + * + * $Id: config.php 24 2007-12-30 12:43:56Z xrogaan $ + */ + +error_reporting(E_ALL); + +date_default_timezone_set('Europe/Brussels'); + + +define('IRC_SERVER','irc.oh-my-songs.com'); +define('IRC_PORT',6667); +define('IRC_CHANNEL','#irbot'); +define('IRC_PSEUDO','irbot'); +define('IRC_IP',''); +define('IRC_DOMAIN',''); +define('IRC_PASSWORD',false); + +?> \ No newline at end of file diff --git a/main.php b/main.php index 061e8fd..ffce771 100755 --- a/main.php +++ b/main.php @@ -16,58 +16,91 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * $Id: main.php 24 2007-12-30 12:43:56Z xrogaan $ */ - -// This page need to be rewrited - -error_reporting(E_ALL); - -date_default_timezone_set('Europe/Brussels'); - +require_once('./config.php'); require_once('./sources/functions.inc.php'); debug(true); //set_error_handler('myErrorHandler'); -// Arguments passés à la ligne de commande -if ( isset($argv[1], $argv[2], $argv[3], $argv[4]) ) { - $server = $argv[1] ; - $port = (int) $argv[2] ; - $chan = '#' . $argv[3] ; - $name = $argv[4] ; -} else { - $server = 'irc.tty2.org'; - $port = 6667; - $chan = '#sharesource'; - $name = 'IrBot'; -} - require_once('./sources/main-class.inc.php'); require_once('./sources/irc-class.inc.php'); require_once('./sources/plugin-class.inc.php'); require_once('./sources/tick-class.inc.php'); require_once('./sources/TextFormat-class.inc.php'); -// Nouvelle instance de la classe IRCMain -bot::$server = $server; -bot::$port = $port; -bot::$channel = $chan; -bot::$myBotName = $name; -bot::$ip = ''; -bot::$domain = ''; -bot::$connection_password = false; - echo <<. + IrBot Copyright (C) 2007 Bellière Ludovic + This program comes with ABSOLUTELY NO WARRANTY; + This is free software, and you are welcome to redistribute it + under certain conditions; for details see . EOF; +// searching for command line option +if (isset($argv[1])) { + $i=1; + while (isset($argv[$i])) { + $val = false; + $option = $argv[$i]; + if (substr_count($option,'=') === 1) { + list($option,$val) = explode('=',$option); + } + + if (!$val) { + $i++; + $val = $argv[$i]; + } + + switch ($option) { + case '-h':case '--help': + echo "help content need to be write\n"; + break 2; + case '-s':case '--server': + bot::$server = $val; + break; + case '-p':case '--port': + bot::$port = (int) $val; + break; + case '-c':case '--channel': + bot::$channel = $val; + break; + case '-n':case '--pseudo': + bot::$myBotName = $val; + break; + case '-i':case '--ip': + if (ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$val)) { + bot::$ip = $val; + } else { + echo "The ip adress entered is wrong.\nUsing default ip instead : ".IRC_IP."\n"; + } + break; + case '-d':case '--domain': + bot::$domain = $val; + break; + case '-a':case '--password': + bot::$connection_password = $val; + break; + default: + break; + } + $i++; + } +} + +if (!isset(bot::$server)) bot::$server = IRC_SERVER; +if (!isset(bot::$port)) bot::$port = (int) IRC_PORT; +if (!isset(bot::$channel)) bot::$channel = IRC_CHANNEL; +if (!isset(bot::$myBotName)) bot::$myBotName = IRC_PSEUDO; +if (!isset(bot::$ip)) bot::$ip = IRC_IP; +if (!isset(bot::$domain)) bot::$domain = IRC_DOMAIN; +if (!isset(bot::$connection_password)) bot::$connection_password = IRC_PASSWORD; + $MainProc = bot::GetInstance(); while (1) { diff --git a/makebuild.sh b/makebuild.sh new file mode 100755 index 0000000..16644c0 --- /dev/null +++ b/makebuild.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +version=$1 + +if [ "$version" = "" ]; then + echo "No version given" + exit 1 +fi + +svn export http://svn2.assembla.com/svn/irbot/trunk/ irbot-${version} +cd irbot-${version} +sh release-cleanup.sh +svn import http://svn2.assembla.com/svn/irbot/tags/version-${version} -m "-- Release ${version} --" --no-auto-props +cd .. + +tar zcf irbot-${version}.tar.gz irbot-${version} +mv irbot-${version} irbot +zip -r irbot-${version}.zip irbot +md5sum irbot-${version}.* +rm -rf irbot diff --git a/release-cleanup.sh b/release-cleanup.sh new file mode 100755 index 0000000..1268bc9 --- /dev/null +++ b/release-cleanup.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo ------------------------------------ +echo Running Cleanup Script +echo ------------------------------------ + +find . -depth -type d -name .svn -exec rm -fr {} \; +find . -type d -exec chmod 775 {} \; +find . -type f -name "*.php" -exec chmod -x {} \; +find . -type f -name "main.php" -exec chmod +x {} \; + +rm -fr release-cleanup.sh + +echo ------------------------------------ +echo Done! +echo ------------------------------------ -- 2.11.4.GIT