#!/bin/sh
# Aviation Setup completely (c) 1998 by Mixter
# usage: ./setup [new-name-of-eggdrop]
if test -z $1 ; then echo "usage: ./setup [new-name-of-eggdrop]" ; exit ; fi
eggname=$1
printf "\taviation setup v3.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\ngenerating AVIATION backup... "
# hide me ?
#cat language/core.english.lang | grep -v "0x53e" | \
#grep -v "0x540" > language/tmp
#echo "0x53e,\n" >> language/tmp
#echo "0x540,\n" >> language/tmp
mv -f language/tmp language/core.english.lang
cp -f src/mod/filesys.mod/files.english.lang language/
cp -f src/mod/wire.mod/wire.english.lang language/
# We generate a "distribution backup" with the compiled eggdrop
tar cf avi-back.tar aviation.tcl mkconf mkcron quench.c \
setup shad.c userfile language eggdrop
printf "OK\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 chconf.c... "
if test ! -r chconf.c ;then printf "not found\n\n---STOP---\n";exit 1 ;fi
printf "found\ncompiling... "
cc chconf.c -o chconf ; strip chconf ; chmod 500 chconf
if test ! -r chconf ;then printf "error :/\n" ; exit 1 ; fi
printf "done\nwriting \"conf\" and \"bchk\"... "
echo "#!/bin/sh" > bchk
echo cd \"`pwd`\" >> bchk
echo "if [ ! -f pid.* ] ; then" >> bchk
echo ./shad \"`whoami`\" ./$eggname conf >> bchk
echo "exit ; fi" >> bchk
echo botpid=\`cat pid.\*\` >> bchk
echo if \`kill -CHLD \$botpid \>/dev/null 2\>\&1\`\; then >> bchk
echo ./shad \"`whoami`\" ./$eggname conf >> bchk
echo "exit ; fi" >> bchk
echo "rm -f pid.*" >> bchk
echo ./shad \"`whoami`\" ./$eggname conf >> bchk
echo exit 0 >> bchk
chmod 755 bchk
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 "#us-opers"
set network "EFNET"
source aviation.tcl
EOF
chmod 755 conf
printf "ok\nremoving unneeded files, hit ENTER to continue or type \"QUIT\": "
read fd
if test ! -z $fd ; then printf "skipped.\n" ; else
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 "...cleaned\n"
fi
printf "renaming eggdrop to "$eggname"... "
mv eggdrop $eggname
printf "5,15,25,35,45,55 * * * *   \"`pwd`/bchk\" >/dev/null 2>&1\n" >cron
printf "\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 755 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 [#us-opers]: " ; read fd
if test ! -z $fd ; then echo set botchans \"$fd\" >> conf ; fi
if test -z $fd ; then echo set botchans \"#us-opers\" >> 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
