v.1.4 misc updates

This commit is contained in:
Dmitry Isaenko 2017-12-03 10:39:21 +03:00
parent fb6a38cfd2
commit f7f820dc54
108 changed files with 121 additions and 56 deletions

View file

@ -1,24 +1,48 @@
# Compiler
CC=gcc
# Flags
#CFLAGS=-lircclient
#CFLAGS=-static libircclient.a
# CFLAGS=-lircclient
# CFLAGS=-static libircclient.a
MKDIR_P = mkdir -p
APP_NAME = loperIRCLogBot
SYSTEMD_DETECT = shell cat /proc/1/comm|grep systemd
all: lib loperIRCLogBot
all: lib $(APP_NAME)
lib:
cp ./files/* ./libircclient-1.9/src/
cp ./src/files/* ./src/libircclient-1.9/src/
# patch -p0 -i ./files/patchFile
$(MAKE) -C ./libircclient-1.9/src/ || exit 1;
cp -r ./libircclient-1.9/include/ ./libircclient
cp ./libircclient-1.9/src/libircclient.a .
$(MAKE) -C ./src/libircclient-1.9/src/ || exit 1;
cp -r ./src/libircclient-1.9/include/ ./src/libircclient
cp ./src/libircclient-1.9/src/libircclient.a ./src
loperIRCLogBot: loperIRCLogBot.c
loperIRCLogBot: ./src/$(APP_NAME).c
$(MKDIR_P) ./bin
# $(CC) $(CFLAGS) loperIRCLogBot.c -o ./bin/loperIRCLogBot
$(CC) -std=gnu89 loperIRCLogBot.c libircclient.a -o ./bin/loperIRCLogBot
# $(CC) $(CFLAGS) $(APP_NAME).c -o ./bin/loperIRCLogBot
$(CC) -std=gnu89 ./src/$(APP_NAME).c ./src/libircclient.a -o ./bin/$(APP_NAME)
clean:
rm -rf ./bin/*.o ./bin/loperIRCLogBot ./libircclient libircclient.a ./libircclient-1.9/src/libircclient.o ./libircclient-1.9/src/libircclient.a ./libircclient-1.9/src/config.h ./libircclient-1.9/src/Makefile
rm -rf ./bin/*.o \
./bin/loperIRCLogBot \
./src/libircclient \
./src/libircclient.a \
./src/libircclient-1.9/src/libircclient.o \
./src/libircclient-1.9/src/libircclient.a \
./src/libircclient-1.9/src/config.h \
./src/libircclient-1.9/src/Makefile
install:
install ./bin/loperIRCLogBot /usr/bin
$(MKDIR_P) /etc/$(APP_NAME)
ifeq ($(SYSTEMD_DETECT),'systemd')
cp ./src/files/loperIRCLogBot.service /etc/systemd/system/loperIRCLogBot.service
else
@echo "* Not a systemD distro. Skipping unit installation."
endif
uninstall:
rm /usr/bin/loperIRCLogBot
rmdir /etc/$(APP_NAME)
ifeq ($(SYSTEMD_DETECT),'systemd')
rm -rf /etc/systemd/system/loperIRCLogBot.service
endif

95
README
View file

@ -1,40 +1,47 @@
README that actually FAQ.
# loperIRCLogBot
What is it about?
loperIRCLogBot is an IRC logging bot made for writing log-files. It could connect to one server and log one channel.
When someone says bot's name at the chat, the URL to logs could be published.
When someone says bot's name at the chat, the URL to logs web-storage could be published (or any message defined in configuration file).
Is it works for Windows™?
Nope
## Description
And if I compile it for Windows™?
It won't.
Works for linux. Need to be tested on other UNIX-like OS.
OS X? BSD?
I don't know. Give a try, let me know.
Key feachures and limitations:
* Could work as a daemon.
* Store configuration file in current folder (./bot.conf) or on /etc/loperIRCLogBot/bot.conf
* Only one channel and server supported for now.
* User can define folder to store files.
* Reconnect in ~6 minutes. Maybe earlier.
* Dumb flood-control
* Authorization only as: /nickserv IDENTIFY [password]
How to build?
Type 'make'
# License
It doesn't work and you don't provide ./configure, what should I do? Why is it happening?
Change Makfile and ./files/Makefile. They're simple as hell. I don't know much about ./configure, so there is no such option. Sorry.
Source code spreads under the GNU General Public License v.3. You can find it in LICENSE file or just visit www.gnu.org (it should be there for sure).
It also uses libircclient writted by George Yunaev, that is stored at ./src/libircclient-1.9. Libircclient is licensed under Lesser General Public License version 3 or higher.
I see some warnings during compilation. Is it ok?
Yeah, I hope so. I also saw them. When I find the time, I'll do something with this.
## Build & Deploy
Where is the executable? Where should I look for this and how to start?
$ ./bin/loperIRCLogBot
```
$ make
# sudo make install
```
# Uninstall
```
make uninstall
```
What about license?
Source code, which is actually 'loperIRCLogBot.c' file spreads under the GNU General Public License v.3 license. You can find it in LICENSE file or just visit www.gnu.org (it should be there for sure). It also uses libircclient writted by George Yunaev. Libircclient is licensed under Lesser General Public License version 3 or higher.
NOTES:
I believe you could change Makefile to let this app work with libircclien as a shared library. Now it's statically linked.
If you have bot.conf file at /etc/loperIRCLogBot folder it won't be deleted. So remember to delete it manually if needed.
Is it possible to let this app work with shared libraries of the libircclient that I already have in my distro?
Yes! Will update Makefile sooner or later.
## Configuration
Where is the application configuration should be set? How?
At the /etc/loperIRCLogBot/bot.conf OR ./bin/bot.conf file. You could generate template by passing -g option: './loperIRCLogBot -g'.
Application settings should be set on /etc/loperIRCLogBot/bot.conf OR ./bin/bot.conf file. You could generate template by passing -g option: './loperIRCLogBot -g'.
Configuration file contains 15 lines, so make sure that you didn't define any sensetive information below these 15 lines.
Here is an example:
```
server: irc.example.com
channel: #channel
port: 6667
@ -47,31 +54,29 @@ logPath: 0
link: http://localhost:8080/logs/
reJoin: yes
floodTimeOut: 10
'server' should be set as described. NO "irc://" or stuff like this allowed, no slashes and backslashes.
'channel' is the channel to log. Should be started by '#' symbol
'port' is server port.
'nick' is nick. Restricted by 'maxNickLength'. It means, that your nick shouldn't be greater then 'maxNickLength'.
'username' is username that defined as second parameter at your nick-on-server. Like nick!~[USERNAME]@ip_adress.
'realname' is realname. Don't ask, just set here something, ok?
'password' is a password for the nick. It goes to server as '/nickserv IDENTIFY [password]'. If '0' then no password needed,
'maxNickLength' is a maximum length of the nick. Various servers restrict the length of the nick. '30' should be enough. '128' is maximum, but I'm not sure that you have to set '128' in here, because if server doesn't support nicknames with such lenght, you could face to unforseen behavior in the application.
'logPath' is a path to 'logs' directory, where all your logs will be stored. If '0' then they will be stored at executable file folder. Pay attention, that logPath should be defined as full path. Not like ~/logs of ../../logs.
'link' is a link, that will be provided to anyone on the channel, who starts his/her message by your nick. If '0' then smile will be shown.
'reJoin'. If set to 'yes', then bot will be re-connect to channel after kick. If 'no' then it won't.
'floodTimeOut' is a time in seconds before answering on request sent to us.
```
Is there any other options for this application?
Yes. When you start application, you could pass next options:
-d, --daemon Start application as daemon. Writes to /var/log/loperIRCLogBot.log and syslog. Stores PID number at /var/run/loperIRCLogBot.pid\n
Let's go deeper:
* 'server' should be set as described. NO "irc://" or stuff like this allowed, no slashes and backslashes.
* 'channel' is the channel to log. Should be started by '#' symbol
* 'port' is server port.
* 'nick' is nick. Restricted by 'maxNickLength'. It means, that your nick shouldn't be greater then 'maxNickLength'.
* 'username' is username that defined as second parameter at your nick-on-server. Like nick!~[USERNAME]@ip_adress.
* 'realname' is realname. Don't ask, just set here something, ok?
* 'password' is a password for the nick. It goes to server as '/nickserv IDENTIFY [password]'. If '0' then no password needed.
* 'maxNickLength' is a maximum length of the nick. Various servers restrict the length of the nick. '30' should be enough. '128' is maximum, but I'm not sure that you have to set '128' in here, because if server doesn't support nicknames with such lenght, you could face to unforseen behavior inside the application.
* 'logPath' is a path to 'logs' directory, where all your logs will be stored. If '0' then they will be stored at executable file folder. Pay attention, that logPath should be defined as full path. Not like '~/logs' or '../../logs'.
* 'link' is a link, that will be provided to anyone on the channel, who starts his/her message by your nick.
* 'reJoin'. If set to 'yes', then bot will be re-connect to channel after kick. If 'no' then it won't.
* 'floodTimeOut' is a time in seconds before answering on next request sent to us.
## Options & work modes
When you start application, you could pass next options:
-d, --daemon Start application as daemon. Writes to /var/log/loperIRCLogBot.log and syslog. Stores PID number at /var/run/loperIRCLogBot.pid
Also can interrupt correctly on SIGTERM, not so smooth on SIGINT and reopen log file directory on SIGHUP (used to handle logrotation).
-g, --genconf Create configuration file template. Attention! It will overrite your existing configuration file.
-s, --silent Silent mode. All program messages stores to the 'output.txt' file
-v, --version Application version
--help Show this message and terminate application
Any chance to log more than one channel?
Nope.
If connection is lost, could this bot re-connect? When he will do it?
In ~6 minutes. Maybe earlier.

Binary file not shown.

View file

@ -0,0 +1,18 @@
[Unit]
Description=IRC log bot
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/loperIRCLogBot.pid
OOMScoreAdjust=-100
TimeoutSec=300
Restart=always
ExecStart=/usr/bin/loperIRCLogBot -d
ExecReload=/bin/kill -TERM $PIDFile && /usr/bin/loperIRCLogBot -d
ExecStop=/bin/kill -TERM $PIDFile
[Install]
WantedBy=multi-user.target

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 35 B

After

Width:  |  Height:  |  Size: 35 B

View file

Before

Width:  |  Height:  |  Size: 706 B

After

Width:  |  Height:  |  Size: 706 B

View file

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Some files were not shown because too many files have changed in this diff Show more