5 # Copyright (C) 2001-2007, Eduardo Silva P.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 INFOMODS
="extras/inf/"
32 echo "+ Creating conf/monkey.conf"
35 echo "+ Creating Makefile"
38 echo "+ Creating src/Makefile"
41 echo "+ Creating src/include/info.h"
44 echo "+ Creating banana script"
47 echo -n "Configuration done, just type 'make"
50 echo -n "+ Checking for Pthreads lib.........."
59 echo "+ Creando conf/monkey.conf"
62 echo "+ Creando Makefile"
65 echo "+ Creando src/Makefile"
68 echo "+ Creando src/include/info.h"
71 echo "+ Creando banana script"
74 echo -n "Configuracion completa, tipee 'make"
77 echo -n "+ Checkeando Pthreads lib.........."
86 echo "+ Creating conf/monkey.conf"
89 echo "+ Creating Makefile"
92 echo "+ Creating src/Makefile"
95 echo "+ Creating src/include/info.h"
98 echo "+ Creating banana script"
101 echo -n "Configuration done, just type 'make"
104 echo -n "+ Checking for Pthreads lib.........."
111 cat $INCDIR/config.path lang
/"$*"/mconf lang
/"$*"/sites
/default
> makeconf.sh
112 chmod 755 makeconf.sh
115 rm $INCDIR/config.path
116 cp lang
/"$*"/monkey.deny conf
/
117 cp lang
/"$*"/INSTALL .
/
118 cp lang
/"$*"/README .
/
127 if [ ! -d $bin ]; then
131 if [ ! -d $logs ]; then
135 if [ ! -d $sites ]; then
146 rm -rf src
/extras
/inf
/*
148 # Checking loaded modules
149 if [ "$modules" = "on" ]; then
150 add_obj_mod
="modules.o"
151 echo "Modules loaded :"
153 cat > $INCDIR/modules.h
<<EOF
154 char **MOD_Read_Config(char *mod_name);
155 char *MOD_get_ptr_value(char **ptr, char *var);
159 ##### MOD_MYSQL #####
160 if [ "$mod_mysql" = "on" ]; then
161 echo "* MySQL Module -> Running mod_mysql configure"
162 cd src
/extras
/mod_mysql
&& .
/configure
169 if test -f src
/extras
/inf
/libmod.info
; then
170 mod_libs
=`cat src/extras/inf/libmod.info`
172 if test -f src
/extras
/inf
/obj.info
; then
173 mod_obj
=`cat src/extras/inf/obj.info`
175 if test -f src
/extras
/inf
/defs.info
; then
176 mod_defs
=`cat src/extras/inf/defs.info`
179 if test -f src
/extras
/inf
/make_script.info
; then
180 make_script
=`cat src/extras/inf/make_script.info`
185 echo "Language : $lang"
188 if [ "$prefix" != "$actual_path" ]; then
192 if [ "$bindir" != "$actual_path/bin" ]; then
196 if [ "$cgibin" != "$actual_path/cgi-bin" ]; then
200 if [ "$sysconfdir" != "$actual_path/conf" ]; then
204 if [ "$datadir" != "$actual_path/htdocs" ]; then
208 if [ "$logdir" != "$actual_path/logs" ]; then
216 create_conf prefix bindir cgibin sysconfdir datadir logdir
221 if [ "$dir" = 0 ]; then
222 create_makefile1 bindir
224 create_makefile1_install prefix bindir cgibin sysconfdir datadir logdir
228 create_makefile2 mod_libs mod_defs mod_obj make_script add_obj_mod
231 create_info sysconfdir SYSNAME VERSION
234 create_banana_script bindir logdir
239 if [ "$dir" = 1 ]; then
240 echo -n " && make install' "
247 # Checkea biblioteca PTHREADS
252 int main(){ return 0;}
255 libtest
=`gcc check.c -lpthread &>configure.log`
256 libstatus
=`cat configure.log`
257 if test -n "$libstatus" ; then
259 rm -fr check
* configure.log
263 rm -fr check
* configure.log a.out
270 cat > Makefile
<< EOF
271 # Monkey HTTP Daemon: Makefile
272 # ============================
276 @echo " Running Monkey :"
277 @echo " ----------------"
279 @echo " # $bindir/monkey"
281 @echo " For more help use '-h' option."
284 @(cd src; make clean)
286 @(cd src; make distclean)
290 create_makefile1_install
()
293 # Monkey HTTP Daemon: Makefile
294 # ============================
298 SYSCONFDIR=${sysconfdir}
305 @(cd src; make clean)
307 @(cd src; make distclean)
311 install -d \$(BINDIR)
312 install -d \$(CGIBIN)
313 install -d \$(SYSCONFDIR)
314 install -d \$(DATADIR)
315 install -d \${DATADIR}/imgs
316 install -d \${DATADIR}/php
317 install -d \${DATADIR}/docs
318 install -d \${LOGDIR}
319 install -s -m 755 bin/monkey \$(BINDIR)
320 install -m 755 bin/banana \$(BINDIR)
321 install -m 755 ./cgi-bin/* \$(CGIBIN)
322 install -m 600 ./conf/*.* \$(SYSCONFDIR)
323 install -m 644 ./htdocs/*.* \$(DATADIR)
324 install -m 644 ./htdocs/imgs/*.* \${DATADIR}/imgs
325 install -m 644 ./htdocs/php/*.* \${DATADIR}/php
326 install -m 644 ./htdocs/docs/*.* \${DATADIR}/docs
328 @echo " Running Monkey :"
329 @echo " ----------------"
331 @echo " # $bindir/monkey"
333 @echo " For more help use '-h' option"
339 # Creando src/Makefile
343 if [ $SYSNAME = "SunOS" ]; then
347 if test -z $CC ; then
350 if test -z $STRIP ; then
354 ##### Internal options ####
355 if [ "$disable_sendfile" = "on" ]; then
356 internal_options
="-DDISABLE_SENDFILE_SYSCALL"
359 cat > src
/Makefile
<<EOF
361 DEFS = $mod_defs $internal_options
362 CFLAGS = \$(DEFS) -g -O2 -Wall
365 DESTDIR = ../bin/monkey
366 LIBS = -lpthread $mod_libs $MORE_LIBS
367 OBJ = monkey.o method.o mimetype.o request.o \\
368 vhost.o config.o logfile.o signals.o \\
369 dir_html.o deny.o cgi.o user.o utils.o \\
370 process.o chars.o mk_net.o mk_thread.o mk_common.o $add_obj_mod
372 all: modules ../bin/monkey
377 ../bin/monkey: \$(OBJ)
378 \$(CC) \$(CFLAGS) \$(LIBS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj
386 rm -rf *.o ../bin/* Makefile \\
387 ../Makefile ../conf/monkey.conf \\
388 ../conf/monkey.deny ../conf/sites/* include/info.h ../logs/*\\
390 @(cd extras && ./cleanmods.sh && cd ..)
393 \$(CC) -c \$(CFLAGS) -I\$(INCDIR) \$<
397 # Creando include/info.h
400 cat > $INCDIR/info.h
<<EOF
401 #define OS "$SYSNAME"
402 #define VERSION "$VERSION" /* Version de Monkey */
403 #define MONKEY_PATH_CONF "$sysconfdir"
409 cat > $INCDIR/config.path
<<EOF
414 sysconfdir=$sysconfdir
420 create_banana_script
()
422 cat > bin
/banana
<< EOF
425 # Monkey HTTP Daemon - Banana Script
426 # -----------------------------------
427 # This script allow you to control monkey. Written by Eduardo Silva
428 # ----------------------------
430 # ----------------------------
432 # Use: ./banana OPTION
434 # Options available to banana:
436 # start -> start monkey
437 # restart -> restart monkey
438 # stop -> stop monkey if this is running
439 # help -> what do u think ?
441 PIDFILE="$logdir/monkey.pid"
442 BINMONKEY="$bindir/monkey"
446 -*=*) optarg=\`echo "\$arg" | sed 's/[-_a-zA-Z0-9]*=//'\` ;;
450 if ! test -f \$PIDFILE ; then
453 PIDMONKEY=\`cat \$PIDFILE\`
454 if ! kill -0 \$PIDMONKEY 2>/dev/null; then
463 if [ "\$STATUS" == "yes" ] ; then
464 echo "Monkey is running... (PID=\$PIDMONKEY)"
467 if ! test -x \$BINMONKEY ; then
468 echo "Error: I can't run binary file"
471 if \$BINMONKEY -D 2>/dev/null ; then
472 echo "Running Monkey -> OK"
478 if [ "\$STATUS" == "no" ]; then
479 echo "Monkey is not running."
483 rm -rf \$PIDFILE > /dev/null
484 echo "Monkey stopped (\$PIDMONKEY)"
488 if [ "\$STATUS" == "yes" ]; then
489 if ! kill \$PIDMONKEY > /dev/null ; then
492 echo -n "Stopping Monkey... "
495 echo -n "Monkey is not running... "
497 if ! test -x \$BINMONKEY ; then
498 echo "Error: I can't run binary file"
501 \$BINMONKEY -D > /dev/null
502 echo "Restarting -> OK"
507 echo "Use : banana [start|stop|restart|help]"
512 echo "Use : banana [start|stop|restart|help]"
519 #---------------------------#
521 #---------------------------#
524 #---------------------------#
526 #---------------------------#
531 cgibin
="$aux/cgi-bin"
532 sysconfdir
="$aux/conf"
533 datadir
="$aux/htdocs"
536 rm -rf src
/extras
/*.info
537 touch $INCDIR/modules.h
542 optarg
=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
550 cgibin
="$optarg/cgi-bin"
551 sysconfdir
="$optarg/conf"
552 datadir
="$optarg/htdocs"
553 logdir
="$optarg/logs"
574 disable_sendfile
="on"
581 echo "Monkey HTTP Daemon v$VERSION"
582 echo "-------------------------"
583 echo "Copyright 2001-2002"
584 echo "Developed by Eduardo Silva"
585 echo "Monkey Home : http://monkeyd.sf.net"
586 echo "Contact Email : edsiper@users.sf.net"
591 echo "Usage: configure [--prefix=PREFIXDIR] [--lang=LANGUAGE] [ --bindir=BINDIR]"
592 echo " [--cgibin=CGIBINDIR] [--sysconfdir=SYSCONFDIR]"
593 echo " [--datadir=DATADIR] [--logdir=LOGDIR]"
596 echo " --help Display this help and exit"
597 echo " --version Display version information and exit"
599 echo " --prefix=PREFIX Install Monkey under PREFIX directory"
600 echo " --bindir=BINDIR Install Monkey binaries under BINDIR directory"
601 echo " --cgibin=CGIBINDIR Install Monkey cgi-bin under CGIBIN directory"
602 echo " --sysconfdir=SYSCONFDIR Install Monkey conf files under SYSCONFDIR dir"
603 echo " --datadir=DATADIR Install Monkey data dir files under DATADIR directory"
604 echo " --logdir=LOGDIR Install Monkey log files under LOGDIR directory"
605 echo " --lang=[en|es] Language to configuration files (default English)"
607 echo "Internal options :"
609 echo " --disable-sendfile Do not use the sendfile() system call"
612 echo " All modules are optional features, neither of them are loaded by default,"
613 echo " the available modules are:"
615 echo " --load-mod_mysql Load MySQL Support (read MODULES file for details)."
622 echo "********************************************"
623 echo " Monkey HTTP Daemon v$VERSION "
624 echo "* (http://monkeyd.sf.net) *"
625 echo "* ---------------------------------------- *"
626 echo "* We need beta testers, developers and *"
627 echo "* translators!, if u want help to this *"
628 echo "* project, email me : *"
630 echo "* edsiper@users.sourceforge.net *"
632 echo "* Thanks for use Monkey!!! *"
634 echo "********************************************"
635 echo "System : $SYSINFO"
637 if [ -z "$lang" ]; then
639 echo "+ Choose configure language: "
640 echo " -> [en] English"
641 echo " -> [es] Spanish"
642 echo " -> [fr] French"
644 echo -n " -> Option (default English) : "
649 if [ -z "$lang" ]; then
653 if [ $lang != "es" ] && [ $lang != "en" ] && [ $lang != "fr" ]; then
654 echo " -> Error: Language not available"
660 # starting main function
661 main prefix lang bindir cgibin sysconfdir datadir logdir modules mod_mysql SYSNAME VERSION