Fix major bugs in annna. - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
DIR commit 8ef63faa063c71c42142e1bf2892e8ccafacbb6c
DIR parent bc22021f5895ec90dda9183e932989364fbe0f63
HTML Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Mon, 2 Apr 2018 08:31:12 +0200
Fix major bugs in annna.
* On startup annna will listen to commands.
* If only some channels are set to be joined don't barf.
* Checking for channels is streamlined.
* Check for ii and socat so the connection really works.
Diffstat:
M annna-start-checker | 6 ++++--
M annna-start-checker-dbg | 6 ++++--
M annna-start-main | 6 ++++++
M annna-start-services | 33 +++++++++++++++++++++++--------
4 files changed, 39 insertions(+), 12 deletions(-)
---
DIR diff --git a/annna-start-checker b/annna-start-checker
@@ -9,10 +9,12 @@ export PATH="$PATH:/home/annna/bin"
while /bin/true;
do
# Is annna still in her world?
- pid="$(pgrep -U annna -x socat)"
+ socatpid="$(pgrep -U annna -x socat)"
+ iipid="$(pgrep -U annna -x ii)"
- if [ -z "$pid" ];
+ if [ -z "$socatpid" -o -z "$iipid" ];
then
+ annna-stop-socat >/dev/null 2>&1
annna-stop-services >/dev/null 2>&1
annna-start-main >/dev/null 2>&1
fi
DIR diff --git a/annna-start-checker-dbg b/annna-start-checker-dbg
@@ -8,11 +8,13 @@ export PATH="$PATH:/home/annna/bin"
while /bin/true;
do
# Is annna still in her world?
- pid="$(pgrep -U annna -x socat)"
+ socatpid="$(pgrep -U annna -x socat)"
+ iipid="$(pgrep -U annna -x ii)"
- if [ -z "$pid" ];
+ if [ -z "$socatpid" -o -z "$iipid" ];
then
printf "checker: Starting annna.\n"
+ sh -x annna-stop-socat
sh -x annna-stop-services
sh -x annna-start-main
fi
DIR diff --git a/annna-start-main b/annna-start-main
@@ -10,6 +10,8 @@ export PATH="$PATH:/home/annna/bin"
channels="#bitreich-con #bitreich-radio
#bitreich-scm #bitreich-en #bitreich-de
#bitreich-fr #bitreich-cooking"
+# Testing
+#channels="#bitreich-radio"
rm -rf $HOME/irc
mkdir -p $HOME/irc
@@ -21,6 +23,7 @@ socat openssl:chat.freenode.net:6697,keepalive,keepcnt=5,keepidle=1,keepintvl=1
unix-l:$HOME/freenode.sock &
while [ ! -e $HOME/freenode.sock ];
do
+ [ -z "$(pgrep socat)" ] && exit 1
sleep 0.5
done
@@ -72,6 +75,9 @@ for chan in ${channels};
do
printf "/j %s\n" "${chan}" > chat.freenode.net/in
+ # Do not flood.
+ sleep 1
+
## Make sure the pipes are there.
while [ ! -e "$HOME/irc/chat.freenode.net/${chan}/out" ];
do
DIR diff --git a/annna-start-services b/annna-start-services
@@ -4,30 +4,42 @@
# If this gets too unmaintainable, consider adding some directory structure.
#
+set -x
+
export PATH="$PATH:/home/annna/bin"
# Bitreich members who are allowed to run certain commands.
brmembers="__20h__ Evil_Bob chripo posativ quinq stateless solene josuah parazyd"
botname="annna"
+iiroot="/home/annna/irc"
iibase="/home/annna/irc/chat.freenode.net"
# Permissions
-chmod o+rx $HOME/irc
-chmod o+rx $HOME/irc/chat.freenode.net
+[ -d ${iiroot} ] && chmod o+rx ${iiroot}
+[ -d ${iibase} ] && chmod o+rx ${iibase}
## EN Channel (this script)
-chmod o+rx "$HOME/irc/chat.freenode.net/#bitreich-en"
-chmod o+w "$HOME/irc/chat.freenode.net/#bitreich-en/in"
+[ -d "${iibase}/#bitreich-en" ] \
+ && chmod o+rx "${iibase}/#bitreich-en"
+[ -f "${iibase}/#bitreich-en/in" ] \
+ && chmod o+w "${iibase}/#bitreich-en/in"
## SCM (/scm/post-receive)
-chmod o+rx "$HOME/irc/chat.freenode.net/#bitreich-scm"
-chmod o+w "$HOME/irc/chat.freenode.net/#bitreich-scm/in"
+[ -d "${iibase}/#bitreich-scm" ] \
+ && chmod o+rx "${iibase}/#bitreich-scm"
+[ -f "${iibase}/#bitreich-scm/in" ] \
+ && chmod o+w "${iibase}/#bitreich-scm/in"
## Radio (/br/radio/playlist.sh + this script)
-chmod o+rx "$HOME/irc/chat.freenode.net/#bitreich-radio"
-chmod o+w "$HOME/irc/chat.freenode.net/#bitreich-radio/in"
+[ -d "${iibase}/#bitreich-radio" ] \
+ && chmod o+rx "${iibase}/#bitreich-radio"
+[ -f "${iibase}/#bitreich-radio/in" ] \
+ && chmod o+w "${iibase}/#bitreich-radio/in"
+if [ -f "${iibase}/#bitreich-radio/out" ];
+then
# bitreich-radio
{
ls "${iibase}/#bitreich-radio/out" | entr tail -n 1 "${iibase}/#bitreich-radio/out" \
+ | grep -v --line-buffered -e '[0-9]* -!- .*' \
| sed -u 's,[0-9]* <\([^ >]*\)> \(.*\)$,\1\n\2,' \
| {
while read user;
@@ -52,10 +64,14 @@ chmod o+w "$HOME/irc/chat.freenode.net/#bitreich-radio/in"
done
}
} &
+fi
# bitreich-en
+if [ -f "${iibase}/#bitreich-en/out" ];
+then
{
ls "${iibase}/#bitreich-en/out" | entr tail -n 1 "${iibase}/#bitreich-en/out" \
+ | grep -v --line-buffered -e '[0-9]* -!- .*' \
| sed -u 's,[0-9]* <\([^ >]*\)> \(.*\)$,\1\n\2,' \
| {
while read user;
@@ -187,4 +203,5 @@ chmod o+w "$HOME/irc/chat.freenode.net/#bitreich-radio/in"
done
}
} &
+fi