teams:dokubot
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
teams:dokubot [2013-08-03 23:55] – 2001:4dd0:ff00:809d:76e5:bff:fedb:c1b4 | teams: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 ' | ||
+ | |||
+ | Currently the messages are only deleted after there were successfully send to the target. | ||
===== Usage ===== | ===== Usage ===== | ||
Line 14: | Line 35: | ||
</ | </ | ||
- | On the server of dokuwiki | + | On the server of dokuwiki |
< | < | ||
- | # start | + | # start bot |
- | service irclog | + | systemctl |
- | # stop | + | # stop bot |
- | service irclog | + | systemctl |
- | # restart | + | # restart |
- | service irclog | + | systemctl |
- | # reload | + | # reload |
- | service irclog | + | systemctl |
+ | # checks running bot | ||
+ | systemctl status irclog | ||
</ | </ | ||
- | ===== Functions ===== | + | For testing purpose there is irclog-test init-script. It starts a bot using / |
- | * 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 | + | 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 | + | 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 ' | + | 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 '' |
+ | 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 ''/ | ||
- | DokuBot is our IRC bot. On netsplits or when MySQL goes down, the bot dies. [[user> | + | <file ini / |
+ | [Unit] | ||
+ | Description=start dokubot for logging IRC messages | ||
+ | After=mysql.service | ||
- | $> sudo su - | + | [Service] |
- | #> | + | User=irclog |
+ | Group=irclog | ||
+ | Type=forking | ||
+ | Restart=no | ||
+ | TimeoutSec=5min | ||
+ | RemainAfterExit=yes | ||
+ | ExecStart=/ | ||
+ | ExecStop=/var/www/ | ||
+ | ExecReload=/ | ||
- | Now it should be gone. In 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 / | + | |
- | #> kill 11669 | + | |
- | Then restart | ||
- | #> / | + | ===== Init-script - deprecated ===== |
- | To check if it's alive join the IRC channel | + | The following can be used to control the bot on Debian systems. Just copy it to ''/ |
+ | |||
+ | <file bash / | ||
+ | #! /bin/sh | ||
+ | ### BEGIN INIT INFO | ||
+ | # Provides: | ||
+ | # Required-Start: | ||
+ | # Required-Stop: | ||
+ | # Default-Start: | ||
+ | # Default-Stop: | ||
+ | # Short-Description: | ||
+ | # Description: | ||
+ | ### END INIT INFO | ||
+ | |||
+ | # Author: dokuwiki.org (Andrwe) | ||
+ | |||
+ | PATH=/ | ||
+ | DESC=" | ||
+ | NAME=irclog.pl | ||
+ | DAEMON=/ | ||
+ | PIDFILE=/ | ||
+ | |||
+ | # Exit if the package is not installed | ||
+ | [ -x " | ||
+ | |||
+ | # Load the VERBOSE setting | ||
+ | . / | ||
+ | |||
+ | # Define LSB log_* functions. | ||
+ | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. | ||
+ | . / | ||
+ | |||
+ | # | ||
+ | # Function that starts the daemon/ | ||
+ | # | ||
+ | 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 / | ||
+ | || return 2 | ||
+ | } | ||
+ | |||
+ | # | ||
+ | # Function that stops the daemon/ | ||
+ | # | ||
+ | do_stop() | ||
+ | { | ||
+ | # Return | ||
+ | # 0 if daemon has been stopped | ||
+ | # 1 if daemon was already stopped | ||
+ | # 2 if daemon could not be stopped | ||
+ | # other if a failure occurred | ||
+ | start-stop-daemon --stop --quiet --name $NAME -- -x | ||
+ | RETVAL=" | ||
+ | [ " | ||
+ | return " | ||
+ | } | ||
+ | |||
+ | do_reload() | ||
+ | { | ||
+ | start-stop-daemon --start --quiet -d / | ||
+ | || return 1 | ||
+ | } | ||
+ | |||
+ | do_check() | ||
+ | { | ||
+ | return start-stop-daemon --start --quiet -d / | ||
+ | } | ||
+ | |||
+ | case " | ||
+ | start) | ||
+ | log_daemon_msg " | ||
+ | do_start | ||
+ | case " | ||
+ | 0|1) log_end_msg 0 ;; | ||
+ | 2) log_end_msg 1 ;; | ||
+ | esac | ||
+ | ;; | ||
+ | stop) | ||
+ | log_daemon_msg " | ||
+ | do_stop | ||
+ | case " | ||
+ | 0|1) log_end_msg 0 ;; | ||
+ | 2) log_end_msg 1 ;; | ||
+ | esac | ||
+ | ;; | ||
+ | reload) | ||
+ | log_daemon_msg " | ||
+ | do_reload | ||
+ | case " | ||
+ | 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 " | ||
+ | do_check | ||
+ | case " | ||
+ | 0) log_end_msg 0 ;; | ||
+ | 1) | ||
+ | log_end_msg 1 | ||
+ | log_daemon_msg " | ||
+ | ;; | ||
+ | 2) | ||
+ | log_end_msg 1 | ||
+ | log_daemon_msg "Test failed. To fix it you have to restart the bot." " | ||
+ | ;; | ||
+ | 3) | ||
+ | log_end_msg 1 | ||
+ | log_daemon_msg "Test failed. To fix it you have to restart the bot." " | ||
+ | ;; | ||
+ | *) | ||
+ | log_end_msg 1 | ||
+ | ;; | ||
+ | esac | ||
+ | ;; | ||
+ | restart) | ||
+ | log_daemon_msg " | ||
+ | do_stop | ||
+ | case " | ||
+ | 0|1) | ||
+ | do_start | ||
+ | case " | ||
+ | 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 " | ||
+ | exit 3 | ||
+ | ;; | ||
+ | esac | ||
+ | </ | ||
+ | |||
+ | ===== TODO ===== | ||
+ | |||
+ | * check for already running process | ||
+ | * increase error checks | ||
+ | * increase error logging | ||
+ | * write help command | ||
+ | * msgstore cleanup | ||
+ | * zabbix monitoring | ||
+ | * [[https:// |
teams/dokubot.1375566926.txt.gz · Last modified: 2013-08-03 23:55 by 2001:4dd0:ff00:809d:76e5:bff:fedb:c1b4