Introduction
Introduction Statistics Contact Development Disclaimer Help
annna-start-main - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
annna-start-main (2654B)
---
1 #!/bin/sh
2
3 export PATH="$PATH:/home/annna/bin"
4
5 cfgbase="$(pwd)"
6 ircbase="$(cat ${cfgbase}/ircbase)"
7
8 server="$1"
9 usetls="$2"
10 [ $usetls -gt 0 ] && tlsparam=" -v -t"
11 port="$3"
12 channels="$4"
13
14 maxtries=10
15 maxnicktries=5
16 {
17 nicktries=0
18 iipid=0
19 while [ -f ${cfgbase}/running ];
20 do
21 # Connect
22 #socat openssl:${server}:6697,keepalive,keepcnt=5,keepid…
23 # unix-l:${ircbase}/${server}/sock &
24 #while [ ! -e ${ircbase}/${server}/sock ];
25 #do
26 # [ -z "$(pgrep socat)" ] && exit 1
27 # sleep 0.5
28 #done
29
30 rm -rf ${ircbase}/${server}
31 mkdir -p ${ircbase}/${server}
32
33 # Connection
34 export ircuser="$(cat ${cfgbase}/${server}/ircuser)"
35 [ -n "${ircuser}" ] && ircuserparam=" -n ${ircuser}"
36
37 export ircpass="$(cat ${cfgbase}/${server}/ircpass 2>/de…
38 ircpassparam=""
39 [ -n "${ircpass}" ] && ircpassparam=" -k ircpass"
40
41 if [ -f ${cfgbase}/${server}/fullname ];
42 then
43 fullname="$(cat ${cfgbase}/${server}/fullname)"
44 else
45 fullname="Gode"
46 fi
47
48 # For debugging.
49 #ii -s "${server}"${ircpassparam}${ircuserparam}${tlspar…
50 # -f "${fullname}" -p ${port} &
51
52 [ $iipid -gt 0 ] && kill -KILL $iipid >/dev/null 2>&1
53
54 ii -s "${server}"${ircpassparam}${ircuserparam}${tlspara…
55 -f "${fullname}" -p ${port} >/dev/null 2>&1 &
56 #ii -s "${server}"${ircpassparam}${ircuserparam}${tlspar…
57 # -f "${fullname}" -p ${port}
58 iipid=$!
59
60 sleep 5
61
62 tries=0
63 ## Waiting for the socket to be available.
64 while [ ! -e ${ircbase}/${server}/out ];
65 do
66 kill -0 $iipid >/dev/null 2>&1 || exit 1
67 [ ! -f ${cfgbase}/running ] && exit 1
68 tries=$(($tries + 1))
69 [ $tries -gt $maxtries ] && break
70 sleep 4
71 done
72 [ $tries -gt $maxtries ] && continue
73
74 # 433: Nickname is already in use.
75 if [ -n "$(grep " 433 " ${ircbase}/${server}/out)" ];
76 then
77 nicktries=$(($nicktries + 1))
78 [ $nicktries -gt $maxnicktries ] && exit 3
79 sleep 30
80 continue
81 fi
82
83 tries=0
84 # Check for end of motd.
85 while [ -z "$(grep " 376 " ${ircbase}/${server}/out)" ];
86 do
87 [ ! -f ${cfgbase}/running ] && exit 1
88 # Sometimes the connection is too fast and the i…
89 # and NICK is slurped.
90 printf "USER %s\r\nUSER %s localhost %s :%s" \
91 "${ircuser}" "${ircuser}" "$(hostname)" \
92 "${fullname}" \
93 > "${ircbase}/${server}/in"
94 tries=$(($tries + 1))
95 [ $tries -gt $maxtries ] && break
96 sleep 2
97 done
98 [ $tries -gt $maxtries ] && continue
99
100 {
101 annna-join-channels "${server}" "${channels}"
102 } &
103
104 # Watch for ii to exit. Then remove the used directory t…
105 # services disappear.
106 while kill -0 $iipid >/dev/null 2>&1;
107 do
108 sleep 30
109 done
110 rm -rf ${ircbase}/${server}
111 done
112 } &
113
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.