DokuWiki

It's better when it's simple

User Tools

Site Tools


teams:dokubot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
teams:dokubot [2013-08-03 23:55] 2001:4dd0:ff00:809d:76e5:bff:fedb:c1b4teams:dokubot [2015-05-21 02:38] (current) andrwe
Line 1: Line 1:
 ====== DokuBot ====== ====== DokuBot ======
 +
 +===== Features =====
 +
 +  * reconnects after Netsplit or kick
 +  * reloads configuration files
 +  * restarts itself on changes for database or irc configuration
 +  * supports MSS (Message Storage System)
 +  * implements test function for proper monitoring
 +  * implements proper logging (inlc. debug mode)
 +  * supports different configuration files (e.g. for testing)
 +
 +==== MSS (Message Storage System) ====
 +
 +This system is designed by Andrwe.
 +
 +It stores messages addressed to someone in the channel who isn't online anymore in a database.\\
 +After reconnecting of the addressed user the message is send to him as private message including the link to irc log website.
 +
 +It is activated by starting the message with '@Nickname' e.g. @Andrwe.
 +
 +Currently the messages are only deleted after there were successfully send to the target.
  
 ===== Usage ===== ===== Usage =====
Line 14: Line 35:
 </code> </code>
  
-On the server of dokuwiki an init-script exists:+On the server of dokuwiki a [[#systemd-file]] exists:
 <code> <code>
-# start +# start bot 
-service irclog start +systemctl start irclog 
-# stop +# stop bot 
-service irclog stop +systemctl stop irclog 
-# restart +# restart bot 
-service irclog restart +systemctl restart irclog 
-# reload +# reload bot 
-service irclog reload+systemctl reload irclog 
 +# checks running bot 
 +systemctl status irclog
 </code> </code>
  
-===== Functions =====+For testing purpose there is irclog-test init-script. It starts a bot using /var/www/irclog/htdocs/test.conf.php as configuration file.
  
-  * reconnects after Netsplit or kick +===== Configuration =====
-  * reloads configuration files +
-  * restarts itself on changes for database or irc configuration +
-  * supports MSS (Message Storage System) +
-  * implements test function for proper monitoring +
-  * implements proper logging (inlc. debug mode) +
-  * supports different configuration files (e.g. for testing)+
  
-==== MSS (Message Storage System) ====+==== Main ====
  
-This system is designed by Andrwe.+There is an example configuration file in the git.\\ 
 +Move that to irclog.config.php within the directory of the bot-script (irclog.pl) and adapt it.
  
-It stores messages addressed to someone in the channel who isn't online anymore in a database.\\ +The parameters you have to change are: 
-After reconnecting of the addressed user the message is send to him as private message including the link to irc log website.+  * db_host 
 +  * db_user 
 +  * db_pass 
 +  * db_name 
 +  * irc_host 
 +  * irc_port 
 +  * irc_chan 
 +  * irc_nick 
 +  * irc_name 
 +  * irc_pass 
 +  * initscript
  
-It is activated by starting the message with '@Nickname' e.g. @Andrwe.+The parameters you might want to change: 
 +  * *_log 
 +  * irc_* for automatic messages
  
-Currently the messages are only deleted after there were successfully send to the target.+==== Special commands ====
  
-===== TODO =====+The file ''irclog.special.pl'' is loaded by the bot and contains the funciton ''special()''.\\ 
 +This function implements bot commands by checking for commands within the message.
  
-  * check for already running process +===== systemd-file =====
-  * increase error checks +
-  * increase error logging +
-  * write help command +
-  * msgstore cleanup +
-  * zabbix monitoring+
  
-===== old version =====+The following systemd.service file controls irclog. 
 +Copy it to ''/etc/systemd/system/irclog.service'' and activate it with ''systemctl enable irclog''.
  
-DokuBot is our IRC bot. On netsplits or when MySQL goes down, the bot dies. [[user>ach|Anika]] is usually the first one to noticeHere's how to restart it:+<file ini /etc/systemd/system/irclog.service> 
 +[Unit] 
 +Description=start dokubot for logging IRC messages 
 +After=mysql.service
  
-  $> sudo su +[Service] 
-  #> /etc/init.d/irclog stop+User=irclog 
 +Group=irclog 
 +Type=forking 
 +Restart=no 
 +TimeoutSec=5min 
 +RemainAfterExit=yes 
 +ExecStart=/var/www/irclog/htdocs/irclog.pl -s 
 +ExecStop=/var/www/irclog/htdocs/irclog.pl -x 
 +ExecReload=/var/www/irclog/htdocs/irclog.pl -r
  
-Now it should be goneIn reality it probably isn't. Check with ps ax and kill it:+[Install] 
 +WantedBy=multi-user.target
  
-  #> ps ax |grep irc +</file>
-  11669 ?        S      4:46 /usr/bin/perl ./irclogger.pl +
-  #kill 11669+
  
-Then restart 
  
-  #> /etc/init.d/irclog start+===== Init-script - deprecated =====
  
-To check if it's alive join the IRC channel and ask him for beer.+The following can be used to control the bot on Debian systems. Just copy it to ''/etc/init.d/irclog''
 + 
 +<file bash /etc/init.d/irclog> 
 +#! /bin/sh 
 +### BEGIN INIT INFO 
 +# Provides:          irclog 
 +# Required-Start:    $remote_fs 
 +# Required-Stop:     $remote_fs 
 +# Default-Start:     2 3 4 5 
 +# Default-Stop:      0 1 6 
 +# Short-Description: start dokubot (irclogger) 
 +# Description:       start dokubot for logging IRC messages 
 +### END INIT INFO 
 + 
 +# Author: dokuwiki.org (Andrwe) 
 + 
 +PATH=/sbin:/usr/sbin:/bin:/usr/bin 
 +DESC="IRC logging service" 
 +NAME=irclog.pl 
 +DAEMON=/var/www/irclog/htdocs/$NAME 
 +PIDFILE=/var/run/$NAME.pid 
 + 
 +# Exit if the package is not installed 
 +[ -x "$DAEMON" ] || exit 1 
 + 
 +# Load the VERBOSE setting and other rcS variables 
 +. /lib/init/vars.sh 
 + 
 +# Define LSB log_* functions. 
 +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 
 +. /lib/lsb/init-functions 
 + 
 +
 +# Function that starts the daemon/service 
 +
 +do_start() 
 +
 +    # Return 
 +    #   0 if daemon has been started 
 +    #   1 if daemon was already running 
 +    #   2 if daemon could not be started 
 +    start-stop-daemon --start --quiet -d /var/www/irclog/htdocs -c irclog -b --exec $DAEMON -- -s  \ 
 +        || return 2 
 +
 + 
 +
 +# Function that stops the daemon/service 
 +
 +do_stop() 
 +
 +    # Return 
 +    #   0 if daemon has been stopped 
 +    #   1 if daemon was already stopped 
 +    #   2 if daemon could not be stopped 
 +    #   other if failure occurred 
 +    start-stop-daemon --stop --quiet --name $NAME -- -x 
 +    RETVAL="$?" 
 +    [ "$RETVAL" = 2 ] && return 2 
 +    return "$RETVAL" 
 +
 + 
 +do_reload() 
 +
 +    start-stop-daemon --start --quiet -d /var/www/irclog/htdocs -c irclog --exec $DAEMON -- -r \ 
 +        || return 1 
 +
 + 
 +do_check() 
 +
 +    return start-stop-daemon --start --quiet -d /var/www/irclog/htdocs -c irclog --exec $DAEMON -- -t 
 +
 + 
 +case "$1" in 
 +  start) 
 +    log_daemon_msg "Starting $DESC" "$NAME" 
 +    do_start 
 +    case "$?" in 
 +        0|1) log_end_msg 0 ;; 
 +        2) log_end_msg 1 ;; 
 +    esac 
 +    ;; 
 +  stop) 
 +    log_daemon_msg "Stopping $DESC" "$NAME" 
 +    do_stop 
 +    case "$?" in 
 +        0|1) log_end_msg 0 ;; 
 +        2) log_end_msg 1 ;; 
 +    esac 
 +    ;; 
 +  reload) 
 +    log_daemon_msg "Reloading $DESC" "$NAME" 
 +    do_reload 
 +    case "$?" in 
 +        0) log_end_msg 0 ;; 
 +        1) log_end_msg 1 ;; # Old process is still running 
 +        *) log_end_msg 1 ;; # Failed to start 
 +    esac 
 +    ;; 
 +  check) 
 +    log_daemon_msg "Checking $DESC" "$NAME" 
 +    do_check 
 +    case "$?" in 
 +        0) log_end_msg 0 ;; 
 +        1)  
 +            log_end_msg 1 
 +            log_daemon_msg "Couldn't run test." "$NAME" 
 +            ;; 
 +        2)  
 +            log_end_msg 1 
 +            log_daemon_msg "Test failed. To fix it you have to restart the bot." "$NAME" 
 +            ;; 
 +        3)  
 +            log_end_msg 1 
 +            log_daemon_msg "Test failed. To fix it you have to restart the bot." "$NAME" 
 +            ;; 
 +        *)  
 +            log_end_msg 1 
 +            ;; 
 +    esac 
 +    ;; 
 +  restart) 
 +    log_daemon_msg "Restarting $DESC" "$NAME" 
 +    do_stop 
 +    case "$?" in 
 +      0|1) 
 +        do_start 
 +        case "$?" in 
 +            0) log_end_msg 0 ;; 
 +            1) log_end_msg 1 ;; # Old process is still running 
 +            *) log_end_msg 1 ;; # Failed to start 
 +        esac 
 +        ;; 
 +      *) 
 +          # Failed to stop 
 +        log_end_msg 1 
 +        ;; 
 +    esac 
 +    ;; 
 +  *) 
 +    echo "Usage: $0 {start|stop|restart|reload}" >&
 +    exit 3 
 +    ;; 
 +esac 
 +</file> 
 + 
 +===== TODO ===== 
 + 
 +  * check for already running process 
 +  * increase error checks 
 +  * increase error logging 
 +  * write help command 
 +  * msgstore cleanup 
 +  * zabbix monitoring 
 +  * [[https://github.com/splitbrain/irclogger/issues]]
teams/dokubot.1375566926.txt.gz · Last modified: 2013-08-03 23:55 by 2001:4dd0:ff00:809d:76e5:bff:fedb:c1b4

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki