Frox' Tech Blog

Aller au contenu | Aller au menu | Aller à la recherche

lundi, 4 mai 2015

Ubuntu sur Virtualbox : ajout d'une interface hôte

1/ dans Virtualbox, machine virtuelle arrêtée, il faut :
- aller dans Configuration > Réseau
- activer la carte 2, Mode d'accès : Réseau privé hôte

2/ lancer la machine virtuelle
- Editer le fichier de configuration : sudo vi /etc/network/interfaces
- rajouter ces lignes (on suppose que l'hôte a comme IP 192.168.56.1 :
# Reseau hote
auto eth1
iface eth1 inet static
address 192.168.56.103
netmask 255.255.255.0
gateway 192.168.56.1
Pour Debian :
# Reseau hote
auto eth1
iface eth1 inet static
address 192.168.56.103
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255
La machine virtuelle aura donc comme IP fixe 192.168.56.103
- Relancer l'interface réseau : sudo /etc/init.d/networking restart

3/ on peut alors utiliser Putty pour accéder au serveur.

mercredi, 12 mars 2014

.htaccess : ajout automatique du www devant le nom de domaine

Parfois on peut accéder à une page du site via le lien http://monsite.fr/lapage.html ou http://www.monsite.fr/lapage.html
Voici comment rajouter automatiquement les www quand on y accède via http://monsite.fr/lapage.html :

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^monsite.fr$
RewriteRule ^(.*) http://www.monsite.fr/$1 [QSA,L,R]

vendredi, 6 septembre 2013

Installation de PostgreSQL

sudo apt-get install postgresql php5-pgsql
sudo /etc/init.d/apache2 restart

sudo -i -u postgres
psql
postgres=# CREATE USER <nom_utilisateur>;
postgres=# ALTER USER <nom_utilisateur> WITH ENCRYPTED PASSWORD 'mon_mot_de_passe';
postgres=# ALTER ROLE <nom_utilisateur> WITH CREATEDB;
postgres=# CREATE DATABASE <nom_base> OWNER <nom_utilisateur>;

mardi, 20 mars 2012

SVN : dump puis restaure

Connexion en root
svnadmin dump /path/to/repositoryname > /tmp/repositoryname.dump
svnadmin create /path/to/new/repository
svnadmin load /path/to/new/repository < /path/to/repositoryname.dump

dimanche, 6 novembre 2011

Installer uploadprogress via PECL

Installation de quelques paquets :
sudo apt-get install php5-dev php-pear make

Utilisation de PECL pour installer uploadprogress :
sudo pecl install uploadprogress

Edition du fichier php.ini :
sudo vi /etc/php5/apache2/php.ini pour rajouter cette ligne :
extension=uploadprogress.so

Redémarrage d'Apache :
sudo /etc/init.d/apache2 restart

lundi, 14 février 2011

MySQL : décompression puis restauration d'une base

On suppose que l'on a sauvé notre base dans le fichier labase.tar.gz (cf billet précédent sur MySQL).
On décompresse la base :
tar -xzf labase.tar.gz
On suppose que l'utilisateur ayant les droits sur la base est "leuser" et qu'il a le mot de passe "mdp" :
mysql -u leuser -pmdp labase < labase.sql

mercredi, 9 février 2011

Logs Apache non mises à jour

Un jour, les logs du site n'ont plus été mises à jour, pour cela il suffit de faire un reload Apache :
sudo /etc/init.d/apache2 reload

lundi, 27 septembre 2010

Ajouter un utilisateur à un groupe

usermod -a -G legroupe leuser

jeudi, 15 avril 2010

FOP : Installer de quoi créer des PDF

Le but est de créer des fichiers PDF sous Linux, en lignes de commandes, et avec FOP.

- téléchargement des sources :
http://apache.crihan.fr/dist/xmlgraphics/fop/source/fop-0.95-src.tar.gz
http://archive.apache.org/dist/xmlgraphics/fop/source/fop-1.0-src.tar.gz
Ou un des snapshots.

- décompression :
tar -xzf fop-0.95-src.tar.gz

- si ce n'est pas déjà fait, installation de java :
sudo apt-get install openjdk-6-jdk

- si ce n'est pas déjà fait, installation de ant :
apt-get install ant
apt-get install ant-optional

- aller dans le répertoire fop-0.95 et rentrer la commande ant


Voici la commande à utiliser pour construire un pdf :

  • A partir d'un fichier XML et d'un fichier XSL :

./fop -xml hello.xml -xsl hello.xsl -pdf hello.pdf

  • A partir d'un fichier FO :

./fop -fo hello.fo -pdf hello.pdf


Ensuite le plus délicat est de fabriquer ou de trouver des fichiers à convertir...

Exemples de fichiers FO.
Dont celui-ci (NB : utf-8 est à changer selon le système utilisé) :

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
 
	<fo:layout-master-set>
		<fo:simple-page-master page-height="29.7cm" page-width="21cm" master-name="only">
		<fo:region-body region-name="xsl-region-body" margin="2cm" /> <!-- Corps de page -->
		<fo:region-before region-name="xsl-region-before" extent="1cm" /> <!-- En-tete de page -->
		<fo:region-after region-name="xsl-region-after" extent="1cm" /> <!-- Pied de page -->
		</fo:simple-page-master>
	</fo:layout-master-set>
 
 
	<fo:page-sequence master-reference="only" format="A4"  initial-page-number="1">
 
<!-- En-tete de page -->
<fo:static-content flow-name="xsl-region-before">
<fo:block margin="1cm">Page <fo:page-number/> sur <fo:page-number-citation ref-id="last-page"/> <!-- Récupération du numéro de la page du block last-page -->
</fo:block>      
</fo:static-content>
 
<!-- Pied de page -->
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="right" margin-right="1cm">Page <fo:page-number/> sur <fo:page-number-citation ref-id="last-page"/>
</fo:block>      
</fo:static-content>
 
<!-- Corps de page -->
<fo:flow flow-name="xsl-region-body">
 
<!-- Texte justifié -->
<fo:block text-align="justify">Some base content, containing an inline warning, 
<fo:inline >Warning: </fo:inline>Do not touch blue paper,
a fairly straightforward piece requiring emphasis
<fo:inline font-weight="bold">TEXT</fo:inline>, and 
some instructions which  require presenting in a different 
way, such as <fo:inline font-style="italic">Now light 
the blue paper</fo:inline>.
</fo:block>
 
<!-- Une image entourée de texte, alignée à droite -->
<fo:block text-align="right">
Un texte avant l'image
<fo:external-graphic content-height="2.6cm" content-width="8cm" src='url(images/example12.png)'/>
Un texte après l'image
</fo:block>
 
<!-- Une image centrée -->
<fo:block text-align="center" space-before="1em" space-after="1em" >
        <fo:external-graphic content-height="1cm" content-width="2cm" src="url(images/logo-hover.jpg)"/>
		<fo:block/> <!-- Un saut de ligne -->
		Du texte sous l'image
</fo:block>
 
 
<fo:block >A block containing the graphic wrapped in an inline container,
        <fo:external-graphic height="3cm" width="3cm" content-width="scale-to-fit" content-height="scale-to-fit" src="url(images/example8.png)"/>
</fo:block>
 
<!-- Sauts de lines -->
<fo:block space-before="1em" space-after="1em" background-color="grey" margin-left="1cm" padding-left="1cm" color="blue" >
Une ligne de texte.<fo:block/>
Puis un saut de ligne.<fo:block space-before="1em"/>
Et un double saut de ligne.
</fo:block>
 
<fo:block>Some base content, containing an inline warning, 
<fo:inline >Warning: </fo:inline>Do not touch blue paper,
a fairly straightforward piece requiring emphasis
<fo:inline font-weight="bold">TEXT</fo:inline>, and 
some instructions which  require presenting in a different 
way, such as <fo:inline font-style="italic">Now light 
the blue paper</fo:inline>.
</fo:block>
 
<!-- Saut de page -->
<fo:block break-after="page"/>
 
 
<fo:block font-weight="bold" font-size="18pt">
Un titre de paragraphe
</fo:block>
<fo:block font-weight="bold" font-size="18pt" text-align="center">
Un titre de paragraphe centré
</fo:block>
 
<fo:block>Some base content, containing an inline warning, 
<fo:inline >Warning: </fo:inline>Do not touch blue paper,
a fairly straightforward piece requiring emphasis
<fo:inline font-weight="bold">TEXT</fo:inline>, and 
some instructions which  require presenting in a different 
way, such as <fo:inline font-style="italic">Now light 
the blue paper</fo:inline>.
</fo:block>
 
<!-- Pour récupérer le nombre total de pages -->
<fo:block id="last-page"/>
 
<!-- Fin de Corps de page -->
</fo:flow>
 
	</fo:page-sequence>
 
</fo:root>

jeudi, 8 avril 2010

.htaccess : rediriger un .com vers un .fr

On suppose que l'on a les deux noms de domaine suivants :
www.monsite.fr
www.monsite.com
et qu'ils pointent sur le même hébergement.

On veut faire en sorte que :
http://www.monsite.com/une/page.html
devienne :
http://www.monsite.fr/une/page.html

On crée alors un fichier .htaccess à la racine du site contenant :
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.monsite.com$
RewriteRule ^(.*) http://www.monsite.fr/$1 [QSA,L,R=301]



[Plus compliqué]

On suppose que dans le répertoire http://www.monsite.fr/rep/ on a déjà un fichier .htaccess qui écrase les règles. La redirection ne fonctionne donc plus à partir de ce répertoire.

Il faut donc modifier ce fichier et insérer la règle suivante avant celles déjà présentes :
RewriteCond %{HTTP_HOST} ^www.monsite.com$
RewriteRule ^(.*) http://www.monsite.fr/rep/$1 [QSA,L,R]


[Encore plus compliqué !!]

Rediriger le .com vers le .fr, et en même temps rajouter le www devant le nom de domaine :
RewriteCond %{HTTP_HOST} ^www.monsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^monsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^monsite.fr$
RewriteRule ^(.*) http://www.monsite.fr/$1 [QSA,L,R]

lundi, 5 avril 2010

MySQL : dump puis archivage d'une base

Exemple de dump de la base toto, ensuite elle est compressée en tar.gz
On crée le script suivant :
BASE_NAME="toto"
NOM_FICHIER="/home/user/saves/bdd_"${BASE_NAME}"_"`date +"%Y-%m-%d_%H-%M"`
mysqldump --user=le_user_mysql --password=le_password ${BASE_NAME} > ${NOM_FICHIER}.sql && tar cfz ${NOM_FICHIER}.tar.gz ${NOM_FICHIER}.sql && rm ${NOM_FICHIER}.sql

Exemple de fichier obtenu :
bdd_toto_2010-04-05_23-36.tar.gz

dimanche, 13 décembre 2009

Apache : activer/désactiver des mods

Exemple avec le mod rewrite :
sudo a2enmod rewrite
sudo /etc/init.d/apache2 force-reload

Pour le désactiver :
sudo a2dismod rewrite

samedi, 15 août 2009

Installer MumbleViewer

En root :
apt-get install libzeroc-ice32 php-zeroc-ice icecpp
su murmur
cd ~/murmur
vi murmur.ini => commenter dbus=..., décommenter ice=...
exit

vi /etc/php5/apache2/php.ini
dans la section :
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
on rajoute :
;PHP-ICE
extension=icephp.so
ice.slice=/home/murmur/murmur/Murmur.ice

/etc/init.d/apache2 restart

cd /var/www/
wget http://mumbleviewer.mine.nu/publish/mumbleviewer-1.0-php.tar.gz
tar -xzf mumbleviewer-1.0-php.tar.gz

Puis redémarrage de murmur : su murmur
ps -eaf|grep murmur => kill du processus
cd ~/murmur
./murmur.x86

Et enfin aller voir ici : http://ip/mumbleviewer/viewer.php
MumbleViewer

mercredi, 12 août 2009

.htaccess : restreindre l'accès à 2 fichiers à 2 IPs

<Files fichier1.ext>
Deny from all
Allow from ip1.ip1.ip1.ip1
Allow from ip2.ip2.ip2.ip2
</Files>
<Files fichier2.ext>
Deny from all
Allow from ip1.ip1.ip1.ip1
Allow from ip2.ip2.ip2.ip2
</Files>

vendredi, 31 juillet 2009

GHost++ : installation sur Ubuntu

(en cours de rédaction)

Système : Ubuntu Server 8.04 LTS 32 bits
(installation toute fraîche)

Version de GHost ++ : 13.3


Compilation du programme


. Connexion en root

. Installation de quelques paquets :

root:$ apt-get install build-essential m4 libgmp3-dev zlib1g-dev libbz2-dev libmysql++-dev make gcc g++ zip unzip sqlite3 screen
root:$


. Téléchargement de Boost version 1.38 dans le home de root :

root:$ cd
root:$ wget http://freefr.dl.sourceforge.net/project/boost/boost/1.38.0/boost_1_38_0.tar.gz


. On décompresse l'archive et on retire les droits d'écriture pour le groupe et les autres :

root:$ tar -xvzf boost_1_38_0.tar.gz
root:$ chmod -R go-w boost_1_38_0


. On crée le Makefile :

root:$ cd boost_1_38_0/
root:$ ./configure --prefix=/usr --with-libraries=date_time,thread,system,filesystem,regex


. On modifie le Makefile pour remplacer la ligne BJAM_CONFIG= par BJAM_CONFIG= --layout=system :
root:$ vi Makefile

. On compile :
root:$ make install

. Vérifier qu'il y a bien de nouvelles bibliothèques dans /usr/lib :
root:$ ls -rtlF /usr/lib
=> fichiers libboost_*

. On rajoute le user wc3bot, on se connecte avec, et on va dans son home :

root:$ adduser wc3bot
...
...
root:$ su wc3bot
wc3bot:$ cd


. Téléchargement des sources de GHost++ et décompression :

wc3bot:$ wget http://ghostplusplus.googlecode.com/files/ghostplusplus_13.3.zip
wc3bot:$ unzip ghostplusplus_13.3.zip


. Compilation de bncsutil et stormlib :

wc3bot:$ cd ~/ghost/bncsutil/src/bncsutil
wc3bot:$ make
wc3bot:$ cd ~/ghost/StormLib/stormlib
wc3bot:$ make


. Compilation de GHost++ (peut être un peu long) :

wc3bot:$ cd ~/ghost/ghost/
wc3bot:$ make


. Copie de l'exécutable généré dans le répertoire parent :

wc3bot:$ cp ghost++ ..


. On se remet en root pour copier les 2 bibliothèques précédemment compilées dans /usr/lib (nécessaires au lancement du programme) :

wc3bot:$ exit
root:$ cp /home/wc3bot/ghost/bncsutil/src/bncsutil/libbncsutil.so /usr/lib
root:$ cp /home/wc3bot/ghost/StormLib/stormlib/libStorm.so /usr/lib



Paramétrage



  • Créer le fichier ~/ghost/motd.txt qui contiendra le texte qui s'affiche lorsque quelqu'un se connecte à la salle d'attente (lobby). Exemple de contenu :


##############################################################
This game is hosted by GHost++ version 13.3
on a Linux Ubuntu 8.04 LTS dedicated server
    . Do not ask for slot reservation
    . Map download allowed if not too slow
    . Auto-kick if ping > 90 ms
    . Stay till the end when the game starts, OR GET BANNED
##############################################################



  • Dans ~/ghost/mapcfgs se trouvent les fichiers de configuration des maps.

En 13.3 il y a entre autres fichiers dota6.59d.cfg, si on veut utiliser une version plus récente, 6.61b par exemple, il faut donc créer le fichier dota6.61b.cfg qui contiendra :

#####################################
# map file for DotA Allstars v6.61b #
#####################################
 
# the map path tells Warcraft III clients where to find the map on their system
# it is NOT the path to the map on the GHost++ system, in fact GHost++ doesn't need the map at all
 
map_path = Maps\Download\DotA Allstars v6.61b.w3x
#map_size = 157 189 52 0
#map_info = 34 117 108 107
#map_crc = 79 37 133 166
 
# map speed
#  1 = slow
#  2 = normal
#  3 = fast
 
map_speed = 3
 
# map visibility
#  1 = hide terrain
#  2 = explored
#  3 = always visible
#  4 = default
 
map_visibility = 4
 
# map observers
#  1 = none
#  2 = on defeat
#  3 = allowed
#  4 = referees
 
map_observers = 1
 
# map flags
#  - you can combine these flags by adding together all the options you want to use
#  - for example to have teams together and fixed teams you would use "3"
#  1 = teams together
#  2 = fixed teams
#  4 = unit share
#  8 = random hero
#  16 = random races
 
map_flags = 3
 
# map game type
#  1 = custom
 
map_gametype = 1
 
# map dimensions
 
#map_width = 52 0
#map_height = 52 0
 
# map players and teams
 
map_numplayers = 10
map_numteams = 2
 
#
# slot structure
#  [PID] [Download Status] [Slot Status] [Computer] [Team] [Colour] [Race] [Skill] [Handicap]
#  - PID is always 0
#  - Download Status is always 255
#  - Slot Status is 0 for open, 1 for closed, 2 for occupied
#  - Computer is 0 for no, 1 for yes
#  - Team
#  - Colour
#  - Race is 1 for human, 2 for orc, 4 for night elf, 8 for undead, 32 for random (add 64 to any of these for fixed)
#  - Skill is 0 for easy computer, 1 for normal computer or human, 2 for hard computer
#  - Handicap is 50/60/70/80/90/100
#
 
map_slot1 = 0 255 0 0 0 1 4 1 100
map_slot2 = 0 255 0 0 0 2 4 1 100
map_slot3 = 0 255 0 0 0 3 4 1 100
map_slot4 = 0 255 0 0 0 4 4 1 100
map_slot5 = 0 255 0 0 0 5 4 1 100
map_slot6 = 0 255 0 0 1 7 8 1 100
map_slot7 = 0 255 0 0 1 8 8 1 100
map_slot8 = 0 255 0 0 1 9 8 1 100
map_slot9 = 0 255 0 0 1 10 8 1 100
map_slot10 = 0 255 0 0 1 11 8 1 100
 
# map type (for map specific stats)
 
map_type = dota
 
# map categories
# the match making category is used to select score data from the database when matchmaking is enabled
# the stats w3mmd category is used to insert data to the database when using map_type = w3mmd
# these are used to allow stats and scores to persist across multiple version of the same map
 
map_matchmakingcategory = dota_elo
map_statsw3mmdcategory =
 
 
# map local path (for map downloads)
#  GHost++ doesn't require map files but if it has access to them it can send them to players
#  GHost++ will search bot_mappath + map_localpath for the map file (bot_mappath is set in the main config file)
 
map_localpath = DotA Allstars v6.61b.w3x



  • Dans ~/ghost/maps il faut uploader la map ("DotA Allstars v6.61b.w3x" dans notre exemple).



  • Créer le répertoire ~/wc3files et y uploader les 4 fichiers suivants qui se trouvent dans le répertoire du jeu (C:\Program Files\WarCraft3) :

game.dll
storm.dll
war3.exe
War3Patch.mpq


  • Il faut ensuite éditer le fichier ~/ghost/ghost.cfg où sont importants les paramètres suivants :

- remplacer tous les \ (faits pour Windows) par des /
- bot_war3path (mettre le chemin où se trouvent les fichiers game.dll, etc.)
- bot_spoofchecks = 0 (ça évite des problèmes)
- bot_allowdownloads = 1 (téléchargments autorisés puisqu'on est sur un serveur dédié)
- bot_maxdownloadspeed = 5000 (gros débit puisqu'on est sur un serveur dédié)
- bot_autokickping = 90 (ping bas puisqu'on est sur un serveur dédié)
- bot_defaultmap = dota6.61b (dans notre exemple)
- bnet_server = europe.battle.net
- bnet_cdkeyroc = XXXXXXXXXXXXXXXXXXXXXXXXXX (clé Reign of Chaos sans -)
- bnet_cdkeytft = XXXXXXXXXXXXXXXXXXXXXXXXXX (clé Frozen Throne sans -)
- bnet_username = nom_du_compte_bnet_du_bot
- bnet_password = password_du_compte
- bnet_firstchannel = chan_ou_le_bot_doit_se_connecter
- bnet_rootadmin = nom_du_compte_bnet_qui_sera_admin_du_bot
- bnet_bnlsserver = hehoe.de (ip ou adresse d'un serveur BNLS public)
- bnet_bnlsport = 9367 (port du serveur BNLS public)
- bnet_bnlswardencookie = 1 (en général)

NB : pour plus de renseignements sur les serveurs BNLS et avoir des adresses de serveurs publics, voir le forum codelain.


Au final voici un exemple de fichier de ghost.cfg :

#####################
# BOT CONFIGURATION #
#####################
 
### the log file
 
bot_log = ghost.log
 
### the language file
 
bot_language = language.cfg
 
### the path to your local Warcraft III directory
###  this path must contain war3.exe, storm.dll, and game.dll
###  this path must end in your system's path seperator (i.e. "\" on Windows or "/" on Linux)
###  if this path contains War3Patch.mpq the bot will attempt to extract "Scripts\common.j" and "Scripts\blizzard.j" on startup and write them to bot_mapcfgpath (which is defined later in this file)
###  common.j and blizzard.j are only required for automatically calculating map_crc, you do not need them if your map config files already contain map_crc
 
bot_war3path = /home/wc3bot/wc3files/
 
### the address GHost++ will bind to when hosting games (leave it blank to bind to all available addresses)
###  if you don't know what this is just leave it blank
 
bot_bindaddress =
 
### the port GHost++ will host battle.net games on (this must be different from your admingame_port)
 
bot_hostport = 6112
 
### maximum number of games to host at once
 
bot_maxgames = 5
 
### command trigger for ingame only (battle.net command triggers are defined later)
 
bot_commandtrigger = !
 
### the path to the directory where you keep your map config files (must end in your system's path seperator)
###  this directory can also contain common.j and blizzard.j (extracted from War3Patch.mpq)
###  common.j and blizzard.j are only required for automatically calculating map_crc, you do not need them if your map config files already contain map_crc
 
bot_mapcfgpath = mapcfgs/
 
### the path to the directory where you keep your savegame files (must end in your system's path seperator)
 
bot_savegamepath = savegames/
 
### the path to the directory where you keep your map files (must end in your system's path seperator)
###  GHost++ doesn't require map files but if it has access to them it can send them to players and automatically calculate most map config values
###  GHost++ will search [bot_mappath + map_localpath] for the map file (map_localpath is set in each map's config file)
 
bot_mappath = maps/
 
### whether to save replays or not
 
bot_savereplays = 1
 
### the path to the directory where you want GHost++ to save replays (must end in your system's path seperator)
 
bot_replaypath = replays/
 
### the bot's virtual host name as it appears in the game lobby
###  colour codes are defined by the sequence "|cFF" followed by a six character hexadecimal colour in RRGGBB format (e.g. 0000FF for pure blue)
###  the virtual host name cannot be longer than 15 characters including the colour code, if you try to go over this limit GHost++ will use the default virtual host name
 
bot_virtualhostname = |cFF4080C0GHost
 
### whether to hide each player's IP address from other players or not
 
bot_hideipaddresses = 0
 
### whether to check for multiple IP address usage or not
 
bot_checkmultipleipusage = 1
 
### whether to require spoof checks or not
###  disabling spoof checks just turns off automatic spoof checks and requiring players to be spoof checked before starting the game
###  spoof checks need to be enabled if you want GHost++ to detect which realm each player came from (use the !check command to see the realm)
###  you can always manually spoof check by whispering the bot (and in fact is required before running admin commands)
 
bot_spoofchecks = 0
 
### whether to display game refresh messages by default
###  this can always be changed for a particular game with the !refresh command
 
bot_refreshmessages = 0
 
### whether to automatically lock games when the owner joins
 
bot_autolock = 0
 
### whether to automatically save games when a player disconnects
###  this can always be changed for a particular game with the !autosave command
 
bot_autosave = 0
 
### whether to allow map downloads or not
###  set to 0 to disable map downloads
###  set to 1 to enable map downloads
###  set to 2 to enable conditional map downloads (an admin must start each map download with the !download or !dl command)
 
bot_allowdownloads = 1
 
### whether to ping players during map downloads or not
###  GHost++ will always stop pinging any players who are downloading the map
###  this config value determines whether GHost++ should stop pinging *all* players when at least one player is downloading the map
 
bot_pingduringdownloads = 0
 
### the maximum number of players allowed to download the map at the same time
 
bot_maxdownloaders = 5
 
### the maximum combined download speed of all players downloading the map (in KB/sec)
 
bot_maxdownloadspeed = 5000
 
### use LC style pings (divide actual pings by two)
 
bot_lcpings = 1
 
### auto kick players with ping higher than this
 
bot_autokickping = 90
 
### the ban method
###  if bot_banmethod = 1, GHost++ will automatically reject players using a banned name
###  if bot_banmethod = 2, GHost++ will automatically reject players using a banned IP address
###  if bot_banmethod = 3, GHost++ will automatically reject players using a banned name or IP address
###  if bot_banmethod is anything else GHost++ will print a message when a banned player joins but will not automatically reject them
 
bot_banmethod = 1
 
### the IP blacklist file
 
bot_ipblacklistfile = ipblacklist.txt
 
### automatically close the game lobby if a reserved player (or admin) doesn't join it for this many minutes
###  games which are set to automatically start when enough players join are exempt from this limit (e.g. autohosted games)
 
bot_lobbytimelimit = 10
 
### the game latency
###  this can always be changed for a particular game with the !latency command (which enforces a minimum of 50 and a maximum of 500)
 
bot_latency = 100
 
### the maximum number of packets a player is allowed to get out of sync by before starting the lag screen
###  before version 8.0 GHost++ did not have a lag screen which is the same as setting this to a very high number
###  this can always be changed for a particular game with the !synclimit command (which enforces a minimum of 10 and a maximum of 10000)
 
bot_synclimit = 50
 
### whether votekicks are allowed or not
 
bot_votekickallowed = 1
 
### the percentage of players required to vote yes for a votekick to pass
###  the player starting the votekick is assumed to have voted yes and the player the votekick is started against is assumed to have voted no
###  the formula for calculating the number of votes needed is votes_needed = ceil( ( num_players - 1 ) * bot_votekickpercentage / 100 )
###  this means it will round UP the number of votes required
###  if you set it to 100 it will require 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, 10/11, and 11/12 votes to pass
###  if you set it to 90 it will require 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, 9/11, and 10/12 votes to pass
###  if you set it to 80 it will require 2/3, 3/4, 4/5, 4/6, 5/7, 6/8, 7/9, 8/10, 8/11, and 9/12 votes to pass
###  if you set it to 70 it will require 2/3, 3/4, 3/5, 4/6, 5/7, 5/8, 6/9, 7/10, 7/11, and 8/12 votes to pass
###  if you set it to 60 it will require 2/3, 2/4, 3/5, 3/6, 4/7, 5/8, 5/9, 6/10, 6/11, and 7/12 votes to pass
 
bot_votekickpercentage = 80
 
### the default map (the .cfg is added automatically)
 
bot_defaultmap = dota6.61b
 
### the MOTD file
###  the first 8 lines of this file will be displayed when a player joins the game
###  if this file doesn't exist a default MOTD will be used
 
bot_motdfile = motd.txt
 
### the gameloaded file
###  the first 8 lines of this file will be displayed when the game finished loading (after the player loading times are displayed)
 
bot_gameloadedfile = gameloaded.txt
 
### the gameover file
###  the first 8 lines of this file will be displayed when the game is over
###  this only works when using a stats class - note: at the time of this writing the only stats class is for DotA maps
 
bot_gameoverfile = gameover.txt
 
### whether to use regular expressions when loading map configs and maps or not
 
bot_useregexes = 0
 
############################
# ADMIN GAME CONFIGURATION #
############################
 
### whether to create the admin game or not (see readme.txt for more information)
 
admingame_create = 0
 
### the port GHost++ will host the admin game on (this must be different from your bot_hostport)
 
admingame_port = 6113
 
### the admin game password
 
admingame_password =
 
##########################
# DATABASE CONFIGURATION #
##########################
 
### database type
###  use "sqlite3" for a local SQLite database
###  use "mysql" for any MySQL database
 
db_type = sqlite3
 
### sqlite3 database configuration
###  this is only used if your database type is SQLite
 
db_sqlite3_file = ghost.dbs
 
### mysql database configuration
###  this is only used if your database type is MySQL
 
db_mysql_server = localhost
db_mysql_database = ghost
db_mysql_user = YOUR_USERNAME
db_mysql_password = YOUR_PASSWORD
db_mysql_port = 0
 
############################
# BATTLE.NET CONFIGURATION #
############################
 
### which battle.net server to connect to
###  1.) useast.battle.net
###  2.) uswest.battle.net
###  3.) asia.battle.net
###  4.) europe.battle.net
### note that each banned player is tied to the realm it was created on and the realm is case sensitive
### so if you change your realm from useast.battle.net to USEAST.BATTLE.NET it'll still connect but anyone previously banned will not be counted as banned until you change it back
 
bnet_server = europe.battle.net
 
### your Warcraft III: Reign of Chaos CD key
 
bnet_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF
 
### your Warcraft III: The Frozen Throne CD key
 
bnet_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF
 
### your battle.net username
 
bnet_username = thebot
 
### your battle.net password
 
bnet_password = thebotpass
 
### the first channel to join upon entering battle.net
 
bnet_firstchannel = thechan
 
### the root admin on this battle.net server only
 
bnet_rootadmin = theadmin
 
### command trigger for this battle.net server only
 
bnet_commandtrigger = !
 
### whether to automatically add your friends list to each game's reserved list
 
bnet_holdfriends = 1
 
### whether to automatically add your clan members list to each game's reserved list
 
bnet_holdclan = 1
 
### BNLS server information for Warden handling (see readme.txt for more information)
###  you will need to use a valid BNLS server here if you are connecting to an official battle.net realm or you will be disconnected every two minutes
 
#bnet_bnlsserver = bnls.hikato.com
#bnet_bnlsport = 19283
#bnet_bnlsserver = bnls.pingblazer.com
#bnet_bnlsport = 9367
#bnet_bnlsserver = ragetrain.com
#bnet_bnlsport = 9367
bnet_bnlsserver = hehoe.de
bnet_bnlsport = 9367
bnet_bnlswardencookie = 1
 
### you will need to edit this section of the config file if you're connecting to a PVPGN server
###  your PVPGN server operator will tell you what to put here
 
bnet_custom_war3version = 23
bnet_custom_exeversion =
bnet_custom_exeversionhash =
bnet_custom_passwordhashtype =
 
###
### example configuration for connecting to a second official battle.net server
###
 
# bnet2_server = uswest.battle.net
# bnet2_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF
# bnet2_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF
# bnet2_username =
# bnet2_password =
# bnet2_firstchannel = The Void
# bnet2_rootadmin =
# bnet2_commandtrigger = !
# bnet2_holdfriends = 1
# bnet2_holdclan = 1
# bnet2_bnlsserver = localhost
# bnet2_bnlsport = 9367
# bnet2_bnlswardencookie = 2
 
###
### example configuration for connecting to a third PVPGN battle.net server
###
 
# bnet3_server = server.eurobattle.net
# bnet3_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF
# bnet3_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF
# bnet3_username =
# bnet3_password =
# bnet3_firstchannel = The Void
# bnet3_rootadmin =
# bnet3_commandtrigger = !
# bnet3_holdfriends = 1
# bnet3_holdclan = 1
# bnet3_custom_war3version = 23
# bnet3_custom_exeversion = 184 0 22 1
# bnet3_custom_exeversionhash = 219 152 153 144
# bnet3_custom_passwordhashtype = pvpgn



Lancement


  • Voici un script tout simple pour lancer le bot, créer le fichier ~/startbot.sh contenant ceci :


cd ~/ghost
screen -dmS ghostpp /home/wc3bot/ghost/ghost++


  • Aller voir dans la log (fichier ~/ghost/ghost.log) pour voir si le bot est bien connecté.

Il faut notamment être attentif à la connexion au serveur BNLS.
Si l'authentification BNLS échoue alors le bot sera déconnecté de Battle.Net au bout de 2-3 minutes et essaiera de se reconnecter 90 secondes plus tard.
Si c'est le cas rien ne sert de le laisser tourner en boucle, il faut changer de serveur BNLS, sinon votre IP risque d'être bannie de Battle.Net pour deux semaines.
Si la log n'a pas bougé pendant 5 minutes c'est gagné !

  • Pour arrêter GHost++ :

- rentrer la commande screen -r et faire CTRL+C
- ou, si ça ne fonctionne pas, repérer le processus et le tuer (ps -eaf|grep ghostpp puis kill xxxxx)


Personnalisations


L'avantage de compiler un programme à partir des sources, c'est qu'on peut modifier l'application à notre sauce. Voici une liste des modifications que j'ai mises en place : lien

mercredi, 20 mai 2009

GHost++ : ajout de quelques fonctions intéressantes

Démarrer le compte à rebours de 10 au lieu de 5

Fichier : game_base.cpp
Fonction : void CBaseGame :: StartCountDown( bool force )
Modification :
2 fois dans la fonction, au début et à la fin, on remplace :

m_CountDownCounter = 5;

par :

m_CountDownCounter = 10;



Empêcher le compte à rebours si tous les slots ne sont pas remplis

Fichier : game_base.cpp
Fonction : void CBaseGame :: StartCountDown( bool force )
Modification :
Le début de la fonction est modifié de :

{
	if( !m_CountDownStarted )
	{
		if( force )
		{
			m_CountDownStarted = true;
			m_CountDownCounter = 5;
		}
		else
		{
			// check if everyone has the map
			string StillDownloading;

en :

{
	if( !m_CountDownStarted )
	{
		if( force )
		{
			m_CountDownStarted = true;
			m_CountDownCounter = 10;
		}
		else
		{
                        // ajout pir
	        	// verifie qu'il n'y a pas de slot ouvert
		        if( GetSlotsOpen( ) > 0 )
		        {
		                SendAllChat( "Slot(s) open, fill them" );
		                return;
		        }
			// check if everyone has the map
			string StillDownloading;



Avoir une liste des pays bannis

Fichier : ghost.cfg
Modification : par exemple pour bannir l'Espagne, l'Italie et l'Allemagne on rajoute la ligne :

bannedcountries = ESITDE


Fichier : ghost.h
Modification : après la ligne suivante :

string m_AdminGamePassword;	// config value: the admin game password

On rajoute ceci :

string m_BannedCountries;	// custom value: banned countries


Fichier : ghost.cpp
Modification : après la ligne suivante :

m_AdminGamePassword = CFG->GetString( "admingame_password", string( ) );

On rajoute ceci :

m_BannedCountries = CFG->GetString( "bannedcountries", string( ));


Fichier : game_base.cpp
Modification : après le bloc suivant :

// check if the new player's name is banned
 
	for( vector<CBNET *> :: iterator i = m_GHost->m_BNETs.begin( ); i != m_GHost->m_BNETs.end( ); i++ )
	{
		CDBBan *Ban = (*i)->IsBanned( joinPlayer->GetName( ) );
 
		if( Ban )
		{
			CONSOLE_Print( "[GAME: " + m_GameName + "] player [" + joinPlayer->GetName( ) + "] is trying to join the game but is banned" );
			SendAllChat( m_GHost->m_Language->TryingToJoinTheGameButBanned( joinPlayer->GetName( ) ) );
			potential->SetDeleteMe( true );
			return;
		}
	}

Mais avant celui-ci :

// try to find an empty slot
 
	unsigned char SID = GetEmptySlot( false );
 
	// check if the player is an admin or root admin on any connected realm for determining reserved status
	// we can't just use the spoof checked realm like in EventPlayerBotCommand because the player hasn't spoof checked yet
 
	bool AnyAdminCheck = false;

On rajoute ceci :

// [FROMENFORCER]
	//Make sure from checking is enabled and config values are clean
	if(!m_GHost->m_BannedCountries.empty( ) || m_GHost->m_BannedCountries.length() % 2 != 0)
	{
		int num;
		vector<string> BannedLocations;
		string PlayerLocation;
		bool playerIsApproved;
 
		if(m_GHost->m_BannedCountries.length() == 2)
			num = 1;
		else
			num = m_GHost->m_BannedCountries.length() / 2;
 
		//Loop through banned countries and construct an array
		for(int i = 0; i < m_GHost->m_BannedCountries.length(); i += 2)
			BannedLocations.push_back(m_GHost->m_BannedCountries.substr(i,2));
 
		//Get their location
		PlayerLocation = m_GHost->m_DBLocal->FromCheck( UTIL_ByteArrayToUInt32( potential->GetExternalIP( ), true ));
 
		//Kick if not from an allowed location, ignore if their location is approved or cannot be found "??"
		playerIsApproved = true;
 
		//Try to make a match
		for(int x = 0; x < num; x++)
		{
			//Ban the player if their country is banned
			if(PlayerLocation == BannedLocations[x])
				playerIsApproved = false;
		}
 
		if(!playerIsApproved && PlayerLocation != "??")
		{
			//Player location has been found and is invalid, deny them entry
			CONSOLE_Print("[FROMENFORCER] Player [" + joinPlayer->GetName() + "] tried to join the game but is not from an approved location (" + PlayerLocation + ")");
			SendAllChat("[" + joinPlayer->GetName() + "] tried to join the game but is not from an approved location (" + PlayerLocation + ")");
			potential->SetDeleteMe(true);
			return;
		}
	}


vendredi, 1 mai 2009

La coloration syntaxique avec SyntaxeHl

SyntaxeHl est un plugin bien sympatique.

Un petit exemple avec Java :

/*un commentaire*/
class Product{
    String nom;
    int ref;
    int qte;
    void print(){
        System.out.print(nom+" "+ref+" "+qte);
    }
    Product(String n, int r, int q){
        nom = n;
        ref = r;
        qte = q;
    }
    Product stocker(int delta){
        qte = qte + delta;
        return this;
    }
    Product destocker(int delta){
        qte = qte - delta;
        return this;
    }
}


Un autre avec Bash :

#!/bin/bash
if [ $# -lt 1 ]; then
        echo "$0 : Utilisation du script : $0 MMJJ (mois jour)"
        exit 10
fi
 
LISTE=`ls -l /usr/games/srcds/css/cstrike/logs/L${1}*.log|awk '{print $8}'`
LOGFILE="/root/logs_admins_${1}.log"
if [ ! -w $LOGFILE ]; then
   touch $LOGFILE
fi
 
for FICHIER in $LISTE
do
   cat $FICHIER|grep "MANI_ADMIN_PLUGIN] Admin" >> $LOGFILE
done


Et du TCL :

# client e/s
 
  proc input {channel} \
  {
    if {[eof $channel]} \
    {
      # client closed -> log & close
      log $channel <closed>
      catch { close $channel }
    } \
    else \
    {
      # receiving
      set rc [catch { set count [gets $channel data] } msg]
      if {$rc == 1} \
      {
        # i/o error -> log & close
        log $channel ***$msg
        catch { close $channel }
      } \
      elseif {$count == -1} \
      {
        # client closed -> log & close
        log $channel <closed>
        catch { close $channel }
      } \
      else \
      {
        # got data -> do some thing
        log $channel $data
      }
    }
  }

mercredi, 29 avril 2009

Migration chez Free

Voilà, blog migré chez Free, du coup on est passé à la version 2 de Dotclear, qui est pas mal du tout ;-)

vendredi, 17 octobre 2008

Glftdp : fichiers de configuration des utilisateurs

Les caractéristiques d'un compte glftpd peuvent être modifiées en éditant le fichier correspondant dans /glftpd/ftp-data/users.
Bien pratique, par exemple, pour rajouter une IP.

Attention toutefois à ne pas corrompre la structure du fichier, car aucun contrôle n'est fait, ça reste donc du dépannage.
De plus créer un tel fichier ne suffira pas à créer un nouvel utilisateur.

jeudi, 16 octobre 2008

Fichier motd

Juste une petite note pour dire que le fichier /etc/motd contient le texte d'accueil qui est affiché à la connexion via SSH.
(Et maintenant je ne sais plus pourquoi je voulais le trouver...)

- page 1 de 3