]> git.pld-linux.org Git - packages/bnc.git/blame - bncsetup.pld
- adapterized,
[packages/bnc.git] / bncsetup.pld
CommitLineData
120b0e93 1#!/bin/sh
2# You NEED the dialog program to use this!
3MYPID=$$
4TMPFILE=.bnc$MYPID.tmp
5RSLFILE=.bnc$MYPID.rsl
6VHTFILE=.bnc$MYPID.vht
7BSVERSION="0.3 for BNC2.6.4"
8SAVEFILE=./bnc.conf
9
10bsclean()
11{
12 rm -f $TMPFILE $RSLFILE $VHTFILE
13 exit $1
14}
15
16saveit()
17{
18echo "Writing your configuration to $SAVEFILE"
19cat << EOF > $TMPFILE
20#!/home/myhome/bnc
21# BNCSetup $BSVERSION by IceWizard and pharos
22# automaticly generated configuration file.
23# edit the first line and chmod +x this file if you like to load bnc
24# by running its .conf file
25# Here are additional options you may add:
26# C:6667 Default Irc Server Port to Connect to
27# X:default.vhost.com Default Virtual Host to Use
28# V:another.vhost.com Other Vhosts That Can Be Used
29# V:different.vhost.com As Many Vhosts as You Want
30# P:pid.bnc Name of PID File
31# *NOTE PID file is required if bnc is to be
32# *used with crontab
33# L:bnc.log Name of Log File
34# W:1 enable dynamic idents on servers with
35# identwd installed
36# A:1:*.addy.net Allow list of ip addresses that can use BNC
37S:$SUPERPASS
38D:$BNCPORT:$MAXUSERS:$BNCPASS
39
40EOF
41
42cat $TMPFILE $VHTFILE > $SAVEFILE
43echo "Finished! You may now edit $SAVEFILE to make any special changes"
44
45bsclean 0
46}
47
48altconf()
49{
50 echo "##" > $VHTFILE
51 echo "Running alt configuration tool"
52 echo -n "Port to listen on> "
53 read BNCPORT
54 echo "How many users would you like to be allowed on BNC at the same time?"
55 echo "Please note, if you would like to allow unlimited users, enter a 0"
56 echo -n "> "
57 read MAXUSERS
58 echo -n "Pick a password >"
59 read BNCPASS
60 echo -n "Pick a password for the superuser >"
61 read SUPERPASS
62 saveit
63
64}
65
66if ! [ -e /usr/bin/bncmkpasswd ]
67then
68 echo "You need to Make the package before you can use this script"
69 echo "(required /usr/bin/bncmkpasswd)"
70 bsclean 0
71fi
72
73echo "BAD\$" > $TMPFILE
74echo "Test" | /usr/bin/bncmkpasswd -s >> $TMPFILE
75CRCYS=$(cat $TMPFILE | grep '\$' | tail -1 )
76
77
78if [ "BAD\$" = "$CRCYS" ]
79then
80 CRCY=ON
81else
82 echo "Your OS is using an unstandard Crypt lib, disabling encryption."
83 CRCY=OFF
84 echo "Continuing script in 4 seconds"
85 sleep 4
86fi
87
88dialog --clear
89ERRORLEVEL=$?
90if [ x$ERRORLEVEL != x0 ]
91then
92 echo "You appear to not have the program named dialog"
93 echo "This script depends on it heavily"
94 altconf
95 bsclean 0
96fi
97
98
99
100cat << EOF > $TMPFILE
101BNCSETUP v$BSVERSION
102
103Written by IceWizard <ice@walt-disney.com>
104Rewritten Pharos <Pharos@refract.com>
105BNCSetup is a quick BNC conf generator
106
107EOF
108clear
109dialog --title "BNCSETUP by IceWizard" --msgbox "$(cat $TMPFILE)" 10 50
110
111cat << EOF > $TMPFILE
112What port would you like BNC to listen on?
113This must be a number greater than 1024 and must not be in use.
114
115EOF
116
117BNCPORT=
118while [ -z "$BNCPORT" ]
119do
120
121 dialog --title "Port to listen on" --inputbox "$(cat $TMPFILE)" 10 68 "6669" 2> $RSLFILE
122 ERRORLEVEL=$?
123 BNCPORT="$(head -1 $RSLFILE)"
124 if [ x$ERRORLEVEL = x1 ]
125 then
126 clear
127 echo "BNC Configuration was cancelled..."
128 bsclean 0
129 fi
130done
131
132
133cat << EOF > $TMPFILE
134How many users would you like to be allowed on BNC at the same time?
135Please note, if you would like to allow unlimited users, enter a 0
136
137EOF
138
139MAXUSERS=
140while [ -z "$MAXUSERS" ]
141do
142 dialog --title "Maximum users" --inputbox "$(cat $TMPFILE)" 10 78 "0" 2> $RSLFILE
143 ERRORLEVEL=$?
144 MAXUSERS="$(head -1 $RSLFILE)"
145 if [ x$ERRORLEVEL = x1 ]
146 then
147 clear
148 echo "BNC Configuration was cancelled..."
149 bsclean 0
150 fi
151done
152
153cat << EOF > $TMPFILE
154Pick a password you would like to use for BNC?
155This is the pass that will be used upon
156/quote pass PASS
157when using bnc.
158
159EOF
160
161BNCPASS=
162while [ -z "$BNCPASS" ]
163do
164
165 dialog --title "Pick a password" --inputbox "$(cat $TMPFILE)" 12 60 2> $RSLFILE
166 ERRORLEVEL=$?
167 BNCPASS="$(head -1 $RSLFILE)"
168 if [ x$ERRORLEVEL = x1 ]
169 then
170 clear
171 echo "BNC Configuration was cancelled..."
172 bsclean 0
173 fi
174done
175
176cat << EOF > $TMPFILE
177Pick a superviser password you would like to use for BNC?
178If you are the only person to use your BNC,
179feel free to enter the same password.
180
181EOF
182
183SUPERPASS=
184while [ -z "$SUPERPASS" ]
185do
186 dialog --title "Pick a superviser password" --inputbox "$(cat $TMPFILE)" 10 62 2> $RSLFILE
187 ERRORLEVEL=$?
188 SUPERPASS="$(head -1 $RSLFILE)"
189 if [ x$ERRORLEVEL = x1 ]; then
190 clear
191 echo "BNC Configuration was cancelled..."
192 bsclean 0
193 fi
194done
195
196if [ xON = x$CRCY ]
197then
198
199dialog --yesno "Use encrypted passes in config file (Securety)" 5 60
200ERRORLEVEL=$?
201
202if [ x$ERRORLEVEL = x0 ]
203then
204 if [ -x /usr/bin/bncmkpasswd ]
205 then
206 SUPERPASS="+"$(echo "$SUPERPASS" | /usr/bin/bncmkpasswd -s)
207 BNCPASS="+"$(echo "$BNCPASS" | /usr/bin/bncmkpasswd -s)
208 else
209 clear
210 echo "You have not did ./configure and make so there is no /usr/bin/bncmkpasswd"
211 echo "This program is required to produce the encryption"
212 bsclean 0
213 fi
214fi
215fi
216
217rm -f $VHTFILE
218dialog --radiolist "Choose Allow method" 10 70 3 \
219"0" "Allow ANY ip to use bnc if they know the pass" "on" \
220"1" "Go to menu for creating ip lists" "off" 2> $RSLFILE
221ERRORLEVEL=$?
222if [ x$ERRORLEVEL = x1 ]; then
223 clear
224 echo "BNC Configuration was cancelled..."
225 bsclean 0
226fi
227ERRORLEVEL="$(head -1 $RSLFILE)"
228
229cat << EOF > $TMPFILE
230Enter an IP to be allowed to use BNC.
231this ip can include *'s and ?'s and other wildcard stuff.
232enter q alone to end entering IP's
233EOF
234
235if [ x$ERRORLEVEL = x1 ]
236then
237BDONE=
238 while ! [ x$BDONE = xq ]
239 do
240 dialog --title "Enter Wildcard IP" --inputbox "$(cat $TMPFILE)" 10 62 2> $RSLFILE
241 BDONE="$(head -1 $RSLFILE)"
242 if ! [ -z BDONE ]
243 then
244 if ! [ x$BDONE = xq ]
245 then
246 echo "A:1:$BDONE" >> $VHTFILE
247 fi
248 fi
249 done
250fi
251
252if ! [ -e "$VHTFILE" ]
253then
254 echo "A:1:*" > $VHTFILE
255fi
256
257
258cat << EOF > $TMPFILE
259Enter a Default Vhost IP or DNS that bnc will use.
260EOF
261
262dialog --yesno "Enter a default Vhost to use?" 5 60
263ERRORLEVEL=$?
264
265if [ x$ERRORLEVEL = x0 ]
266then
267 dialog --title "Enter Default Vhost" --inputbox "$(cat $TMPFILE)" 10 62 2> $RSLFILE
268 BDONE="$(head -1 $RSLFILE)"
269 if ! [ -z BDONE ]
270 then
271 echo "X:$BDONE" >> $VHTFILE
272 fi
273fi
274
275dialog --yesno "Enter a list of Vhost possiblities?" 5 60
276ERRORLEVEL=$?
277
278cat << EOF > $TMPFILE
279Enter an Vhost that can be used by this bnc.
280This has no bearing on how bnc functions but is simply
281what is listed when the user does:
282/quote vip
283enter q alone to end entering IP's
284EOF
285
286if [ x$ERRORLEVEL = x0 ]
287then
288BDONE=
289 while ! [ x$BDONE = xq ]
290 do
291 dialog --title "Enter Vhost possibility" --inputbox "$(cat $TMPFILE)" 15 62 2> $RSLFILE
292 BDONE="$(head -1 $RSLFILE)"
293 if ! [ -z BDONE ]
294 then
295 if ! [ x$BDONE = xq ]
296 then
297 echo "V:$BDONE" >> $VHTFILE
298 fi
299 fi
300 done
301fi
302
303
304dialog --yesno "Would you like bnc to log?" 5 60
305ERRORLEVEL=$?
306
307cat << EOF > $TMPFILE
308Pick a filename for bnc to write logging info into.
309if you do not want to use the default
310
311EOF
312
313if [ x$ERRORLEVEL = x0 ]
314then
315 dialog --title "Enter logfile Filename" --inputbox "$(cat $TMPFILE)" 10 62 "bnc.log" 2> $RSLFILE
316 BDONE="$(head -1 $RSLFILE)"
317 if ! [ -z BDONE ]
318 then
319 echo "L:$BDONE" >> $VHTFILE
320 fi
321fi
322
323dialog --yesno "Would you like bnc to display a motd?" 5 60
324ERRORLEVEL=$?
325
326cat << EOF > $TMPFILE
327Pick a filename for bnc to show as a motd
328if you do not want to use the default
329
330EOF
331
332if [ x$ERRORLEVEL = x0 ]
333then
334 dialog --title "Enter logfile Filename" --inputbox "$(cat $TMPFILE)" 10 62 "motd" 2> $RSLFILE
335 BDONE="$(head -1 $RSLFILE)"
336 if ! [ -z BDONE ]
337 then
338 echo "M:$BDONE" >> $VHTFILE
339 fi
340fi
341
342dialog --title "Requires Identwd to be installed." --yesno "Do you want bnc's dynamic ident support?" 5 60
343ERRORLEVEL=$?
344if [ x$ERRORLEVEL = x0 ]
345then
346 echo "W:1" >> $VHTFILE
347fi
348
349
350
351
352cat << EOF > $TMPFILE
353Pick a file to save the configuration in
354if you do not want to use the default
355
356EOF
357
358SAVEFILE=
359while [ -z "$SAVEFILE" ]
360do
361 dialog --title "Save as" --inputbox "$(cat $TMPFILE)" 10 45 "bnc.conf" 2> $RSLFILE
362 ERRORLEVEL=$?
363 SAVEFILE="$(head -1 $RSLFILE)"
364 if [ x$ERRORLEVEL = x1 ]; then
365 clear
366 echo "BNC Configuration was cancelled..."
367 bsclean 0
368 fi
369done
370clear
371if [ -e "$SAVEFILE" ]
372then
373 echo "BNCsetup found a configuration file already... saving it as $SAVEFILE.old"
374 mv $SAVEFILE "$SAVEFILE".old
375fi
376
377saveit
378
This page took 0.107354 seconds and 4 git commands to generate.