]> git.pld-linux.org Git - packages/bnc.git/blob - bncsetup.pld
- adapterized,
[packages/bnc.git] / bncsetup.pld
1 #!/bin/sh
2 # You NEED the dialog program to use this!
3 MYPID=$$
4 TMPFILE=.bnc$MYPID.tmp
5 RSLFILE=.bnc$MYPID.rsl
6 VHTFILE=.bnc$MYPID.vht
7 BSVERSION="0.3 for BNC2.6.4"
8 SAVEFILE=./bnc.conf
9
10 bsclean()
11 {
12   rm -f $TMPFILE $RSLFILE $VHTFILE
13   exit $1
14 }
15
16 saveit()
17 {
18 echo "Writing your configuration to $SAVEFILE"
19 cat << 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
37 S:$SUPERPASS
38 D:$BNCPORT:$MAXUSERS:$BNCPASS
39
40 EOF
41
42 cat $TMPFILE $VHTFILE > $SAVEFILE
43 echo "Finished! You may now edit $SAVEFILE to make any special changes"
44
45 bsclean 0
46 }
47
48 altconf()
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
66 if ! [ -e /usr/bin/bncmkpasswd ]
67 then
68   echo "You need to Make the package before you can use this script"
69   echo "(required /usr/bin/bncmkpasswd)"
70   bsclean 0
71 fi
72
73 echo "BAD\$" > $TMPFILE
74 echo "Test" | /usr/bin/bncmkpasswd -s >> $TMPFILE
75 CRCYS=$(cat $TMPFILE | grep '\$' | tail -1 )
76
77
78 if [ "BAD\$" = "$CRCYS" ]
79 then
80   CRCY=ON
81 else
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
86 fi
87
88 dialog --clear
89 ERRORLEVEL=$?
90 if [ x$ERRORLEVEL != x0 ]
91 then
92   echo "You appear to not have the program named dialog"
93   echo "This script depends on it heavily"
94   altconf
95   bsclean 0
96 fi
97
98
99
100 cat << EOF > $TMPFILE
101 BNCSETUP v$BSVERSION
102
103 Written by IceWizard <ice@walt-disney.com>
104 Rewritten Pharos <Pharos@refract.com>
105 BNCSetup is a quick BNC conf generator
106
107 EOF
108 clear
109 dialog --title "BNCSETUP by IceWizard" --msgbox "$(cat $TMPFILE)" 10 50
110
111 cat << EOF > $TMPFILE
112 What port would you like BNC to listen on?
113 This must be a number greater than 1024 and must not be in use.
114
115 EOF
116
117 BNCPORT=
118 while [ -z "$BNCPORT" ]
119 do
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
130 done
131
132
133 cat << EOF > $TMPFILE
134 How many users would you like to be allowed on BNC at the same time?
135 Please note, if you would like to allow unlimited users, enter a 0
136
137 EOF
138
139 MAXUSERS=
140 while [ -z "$MAXUSERS" ]
141 do
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
151 done
152
153 cat << EOF > $TMPFILE
154 Pick a password you would like to use for BNC?
155 This is the pass that will be used upon
156 /quote pass PASS
157 when using bnc.
158
159 EOF
160
161 BNCPASS=
162 while [ -z "$BNCPASS" ]
163 do
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
174 done
175
176 cat << EOF > $TMPFILE
177 Pick a superviser password you would like to use for BNC?
178 If you are the only person to use your BNC,
179 feel free to enter the same password.
180
181 EOF
182
183 SUPERPASS=
184 while [ -z "$SUPERPASS" ]
185 do
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
194 done
195
196 if [ xON = x$CRCY ]
197 then
198
199 dialog --yesno "Use encrypted passes in config file (Securety)" 5 60
200 ERRORLEVEL=$?
201
202 if [ x$ERRORLEVEL = x0 ]
203 then 
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
214 fi
215 fi
216
217 rm -f $VHTFILE
218 dialog --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
221 ERRORLEVEL=$?
222 if [ x$ERRORLEVEL = x1 ]; then
223   clear
224   echo "BNC Configuration was cancelled..."
225   bsclean 0
226 fi
227 ERRORLEVEL="$(head -1 $RSLFILE)"
228
229 cat << EOF > $TMPFILE
230 Enter an IP to be allowed to use BNC.
231 this ip can include *'s and ?'s and other wildcard stuff.
232 enter q alone to end entering IP's
233 EOF
234
235 if [ x$ERRORLEVEL = x1 ]
236 then
237 BDONE=
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
250 fi
251
252 if ! [ -e "$VHTFILE" ]
253 then
254   echo "A:1:*" > $VHTFILE
255 fi
256
257
258 cat << EOF > $TMPFILE
259 Enter a Default Vhost IP or DNS that bnc will use.
260 EOF
261
262 dialog --yesno "Enter a default Vhost to use?" 5 60
263 ERRORLEVEL=$?
264
265 if [ x$ERRORLEVEL = x0 ]
266 then 
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
273 fi
274
275 dialog --yesno "Enter a list of Vhost possiblities?" 5 60
276 ERRORLEVEL=$?
277
278 cat << EOF > $TMPFILE
279 Enter an Vhost that can be used by this bnc.
280 This has no bearing on how bnc functions but is simply
281 what is listed when the user does:
282 /quote vip
283 enter q alone to end entering IP's
284 EOF
285
286 if [ x$ERRORLEVEL = x0 ]
287 then
288 BDONE=
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
301 fi
302
303
304 dialog --yesno "Would you like bnc to log?" 5 60
305 ERRORLEVEL=$?
306
307 cat << EOF > $TMPFILE
308 Pick a filename for bnc to write logging info into.
309 if you do not want to use the default
310
311 EOF
312
313 if [ x$ERRORLEVEL = x0 ]
314 then 
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
321 fi
322
323 dialog --yesno "Would you like bnc to display a motd?" 5 60
324 ERRORLEVEL=$?
325
326 cat << EOF > $TMPFILE
327 Pick a filename for bnc to show as a motd
328 if you do not want to use the default
329
330 EOF
331
332 if [ x$ERRORLEVEL = x0 ]
333 then 
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
340 fi
341
342 dialog --title "Requires Identwd to be installed." --yesno "Do you want bnc's dynamic ident support?" 5 60
343 ERRORLEVEL=$?
344 if [ x$ERRORLEVEL = x0 ]
345 then
346   echo "W:1" >> $VHTFILE
347 fi
348
349
350
351
352 cat << EOF > $TMPFILE
353 Pick a file to save the configuration in
354 if you do not want to use the default
355
356 EOF
357
358 SAVEFILE=
359 while [ -z "$SAVEFILE" ]
360 do
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
369 done
370 clear
371 if [ -e "$SAVEFILE" ]
372 then
373   echo "BNCsetup found a configuration file already... saving it as $SAVEFILE.old"
374   mv $SAVEFILE "$SAVEFILE".old
375 fi
376
377 saveit
378
This page took 0.76045 seconds and 3 git commands to generate.