#!/bin/sh
# Aviation Setup completely (c) 1998 by Mixter
# usage: ./setup [new-eggdrop-name]
if test -z $1 ; then eggname=eggdrop ; fi
if test ! -z $1 ; then eggname=$1 ; fi
printf "\taviation setup v2.0 by Mixter\n"
printf "\nsearching for eggdrop... "
if test ! -r eggdrop ;then
printf "not found\n\nplease compile eggdrop AND the modules first\n"
printf "because this script removes unneccessary files like source\n"
exit 1 ; fi
printf "found\nsearching for aviation.tcl... "
if test ! -r aviation.tcl ;then printf "not found\n\n---STOP---\n";exit 1 ;fi
printf "found\nsearching for shad.c... "
if test ! -r shad.c ;then printf "not found\n\n---STOP---\n";exit 1 ;fi
printf "found\ncompiling... "
cc shad.c -o shad ; strip shad ; chmod 500 shad
if test ! -r shad ;then printf "error :/\n" ; exit 1 ; fi
printf "done\nsearching for quench.c... "
if test ! -r quench.c ;then printf "not found\n\n---STOP---\n";exit 1 ;fi
printf "found\ncompiling... "
cc quench.c -o quench ; strip quench ; chmod 500 quench
if test ! -r quench ;then printf "error :/\n" ; exit 1 ; fi
printf "done\nsearching for conf... "
echo "#!/bin/sh" > bchk
echo cd \"`pwd`\" >> bchk
echo botpid=\`cat pid.\*\` >> bchk
echo if \`kill -CHLD \$botpid \>/dev/null 2\>\&1\`\; then >> bchk
echo exit 0 >> bchk
echo fi >> bchk
echo rm -f pid.\* >> bchk
echo ./shad \"vim\" ./$1 conf >> bchk
echo exit 0 >> bchk
chmod +x bchk
if test ! -r conf ;then printf "no conf?\ncreating it... "
cat >conf<<EOF
#!`pwd`/$eggname
set nick1 "nickname"
set username "[exec whoami]"
set realname "* I'm to lame to read BitchX.doc *"
set owner "Mixter"
set allport "12345"
set useport "0"
set botport "0"
set botchans "#eggdrop"
set network "EFNET"
source aviation.tcl
EOF
fi
chmod +x conf
printf "ok\nremoving unneccessary files, ctrl-c to abort... "
sleep 1
rm -rf .* C* D* E* F* I* M* N* R* config* doc eggdrop.* 1>/dev/null 2>/dev/null
rm -rf *log klines lush.* motd pid.* *.c o* scripts src 1>/dev/null 2>/dev/null
printf "done\nrenaming eggdrop to "$eggname"... "
mv eggdrop $eggname
printf "5,15,25,35,45,55 * * * *   \"`pwd`/bchk\" >/dev/null 2>&1\n" >cron
printf "done\nWriting config file, hit ENTER to continue, or type quit: "
read fd
if test ! -z $fd ; then printf "skipped. "
printf "type \"crontab cron\" to activate crontab\n" ; exit 0 ; fi
printf "\n\taviation config v2.0 by Mixter\n"
>conf ; chmod +x conf
echo #!`pwd`/$eggname >> conf
printf "Bot nick [lamestbot]: " ; read fd
if test ! -z $fd ; then echo set nick1 \"$fd\" >> conf
mv userfile userfile.$fd ; fi
if test -z $fd ; then echo set nick1 \"lamestbot\" >> conf
mv userfile userfile.lamestbot ; fi
printf "Bot ident ["`whoami`"]: " ; read fd
if test ! -z $fd ; then echo set username \"$fd\" >> conf ; fi
if test -z $fd ; then echo set username \"`whoami`\" >> conf ; fi
printf "Bot ircname [random]: " ; read fd
if test ! -z "$fd" ; then echo set realname \"$fd\" >> conf ; fi
printf "Bot owner [Mixter]: " ; read fd
if test ! -z $fd ; then echo set owner \"$fd\" >> conf ; fi
if test -z $fd ; then echo set owner \"Mixter\" >> conf ; fi
printf "Listening ports(all) [12345]: " ; read fd
if test ! -z $fd ; then echo set allport \"$fd\" >> conf ; fi
if test -z $fd ; then echo set allport \"12345\" >> conf ; fi
printf "Listening ports(users) [none]: " ; read fd
if test ! -z $fd ; then echo set useport \"$fd\" >> conf ; fi
if test -z $fd ; then echo set useport \"0\" >> conf ; fi
printf "Listening ports(bots) [none]: " ; read fd
if test ! -z $fd ; then echo set botport \"$fd\" >> conf ; fi
if test -z $fd ; then echo set botport \"0\" >> conf ; fi
printf "Bots channels [#eggdrop]: " ; read fd
if test ! -z $fd ; then echo set botchans \"$fd\" >> conf ; fi
if test -z $fd ; then echo set botchans \"#eggdrop\" >> conf ; fi
printf "IRC Network [EFNET]: " ; read fd
if test ! -z $fd ; then echo set network \"$fd\" >> conf ; fi
if test -z $fd ; then echo set network \"EFNET\" >> conf ; fi
echo source aviation.tcl >> conf
printf "done\ntype \"crontab cron\" to activate crontab\n"
printf "type \"./bchk\" or \"./conf\" to start the bot manually\n"
exit 0
