5 # Copyright (C) 2001-2009, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 echo "+ Creating conf/monkey.conf"
34 echo "+ Creating Makefile"
37 echo "+ Creating src/Makefile"
40 echo "+ Creating src/include/info.h"
43 echo "+ Creating banana script"
46 echo -n "Configuration done, just type 'make"
49 echo -n "+ Checking for Pthreads lib.........."
54 # Create configuration files under 'conf/'
57 cat $INCDIR/config.path lang
/"$*"/mconf lang
/"$*"/sites
/default
> makeconf.sh
61 rm $INCDIR/config.path
62 cp lang
/"$*"/INSTALL .
/
63 cp lang
/"$*"/README .
/
72 if [ ! -d $bin ]; then
76 if [ ! -d $logs ]; then
80 if [ ! -d $sites ]; then
92 if [ "$prefix" != "$actual_path" ]; then
96 if [ "$bindir" != "$actual_path/bin" ]; then
100 if [ "$cgibin" != "$actual_path/cgi-bin" ]; then
104 if [ "$sysconfdir" != "$actual_path/conf" ]; then
108 if [ "$datadir" != "$actual_path/htdocs" ]; then
112 if [ "$logdir" != "$actual_path/logs" ]; then
117 echo "Checking dependencies"
118 echo "====================="
124 echo "Creating Makefiles and scripts"
125 echo "=============================="
129 create_conf prefix bindir cgibin sysconfdir datadir logdir
134 if [ "$dir" = 0 ]; then
135 create_makefile1 bindir
137 create_makefile1_install prefix bindir cgibin sysconfdir datadir logdir
141 create_makefile2 mod_libs mod_defs mod_obj make_script add_obj_mod cheetah_obj
144 create_info sysconfdir SYSNAME VERSION
147 create_banana_script bindir logdir
151 if [ "$dir" = 1 ]; then
152 echo -n " && make install' "
158 create_makefile_plugins
$plugdir
160 echo "#define CC \"${CC}\"" > src
/include
/env.h
168 int main(){ return 0;}
171 libtest
=`gcc check.c -lpthread &>configure.log`
172 libstatus
=`cat configure.log`
173 if test -n "$libstatus" ; then
175 rm -fr check
* configure.log
179 rm -fr check
* configure.log a.out
186 cat > Makefile
<< EOF
187 # Monkey HTTP Daemon: Makefile
188 # ============================
192 @echo " Running Monkey :"
193 @echo " ----------------"
195 @echo " # $bindir/monkey"
197 @echo " For more help use '-h' option."
201 @(cd plugins; make all)
204 @(cd src; make clean)
206 @(cd src; make distclean)
210 create_makefile1_install
()
213 # Look for plugins and create list
214 for entry
in plugins
/*
216 if [ -d $entry ]; then
217 echo "\tinstall -s -m 644 $entry/*.so \${PLUGINDIR}" >> plugins.list
220 plglist
=`cat plugins.list`
223 # Look for plugins configuration
224 for entry
in conf
/plugins
/*
226 if [ -d $entry ]; then
227 echo "\tcp -r $entry \${SYSCONFDIR}/plugins/" >> plugins.conf
230 plgconf
=`cat plugins.conf`
234 # Monkey HTTP Daemon: Makefile
235 # ============================
239 SYSCONFDIR=${sysconfdir}
247 @(cd src; make clean)
249 @(cd src; make distclean)
253 install -d \$(BINDIR)
254 install -d \$(CGIBIN)
255 install -d \$(SYSCONFDIR)
256 install -d \${SYSCONFDIR}/sites
257 install -d \${SYSCONFDIR}/plugins
258 install -d \$(DATADIR)
259 install -d \${DATADIR}/imgs
260 install -d \${DATADIR}/php
261 install -d \${DATADIR}/docs
262 install -d \${LOGDIR}
263 install -d \${PLUGINDIR}
264 install -s -m 755 bin/monkey \$(BINDIR)
265 install -m 755 bin/banana \$(BINDIR)
266 install -m 755 ./cgi-bin/* \$(CGIBIN)
267 install -m 600 ./conf/*.* \$(SYSCONFDIR)
269 install -m 600 ./conf/sites/* \${SYSCONFDIR}/sites
271 install -m 644 ./htdocs/*.* \$(DATADIR)
272 install -m 644 ./htdocs/imgs/*.* \${DATADIR}/imgs
273 install -m 644 ./htdocs/php/*.* \${DATADIR}/php
274 install -m 644 ./htdocs/docs/*.* \${DATADIR}/docs
276 @echo " Running Monkey :"
277 @echo " ----------------"
279 @echo " # $bindir/monkey"
281 @echo " For more help use '-h' option"
287 # Create monkey/src/Makefile
291 if test -z $CC ; then
295 if test -z $debug ; then
301 ##### Internal options ####
302 # just for remember that one time we support this :_(
303 # ---------------------------------------------------
304 #if [ "$disable_sendfile" = "on" ]; then
305 # internal_options="-DDISABLE_SENDFILE_SYSCALL"
308 cat > src
/Makefile
<<EOF
310 DEFS = $mod_defs $internal_options
311 CFLAGS = $CFLAGS \$(DEFS)
314 DESTDIR = ../bin/monkey
315 LIBS = -ldl -lpthread $mod_libs $MORE_LIBS
316 OBJ = monkey.o method.o mimetype.o request.o \\
317 header.o config.o logfile.o signals.o \\
318 user.o utils.o chars.o epoll.o scheduler.o \\
319 str.o memory.o connection.o iov.o http.o \\
320 file.o socket.o clock.o cache.o worker.o \\
326 ../bin/monkey: \$(OBJ)
327 @echo "Compiling Monkey"
328 @echo "================"
329 \$(CC) \$(CFLAGS) \$(LIBS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj
331 @echo "Compiling Plugins"
332 @echo "================="
333 @(cd ../plugins && make all && cd ..)
340 rm -rf *.o ../bin/* Makefile \\
341 ../Makefile ../conf/monkey.conf \\
342 ../conf/sites/* include/info.h ../logs/*\\
345 \$(CC) -c \$(CFLAGS) -I\$(INCDIR) \$<
349 create_makefile_plugins
()
356 plugins_load
="../conf/plugins.load"
357 echo -n > $plugins_load
358 echo "# Monkey plugins are loaded on run, by default all " >> $plugins_load
359 echo "# plugins are disabled, if you want to enable" >> $plugins_load
360 echo "# one, just remove the comment character for each line" >> $plugins_load
361 echo "" >> $plugins_load
363 list
=`echo */ "" | sed "s/\/ /\n/g"`
366 echo " @(cd $i && make && cd ..)" >> Makefile
;
368 if [ "$plugdir" != "" ]; then
369 echo "#LoadPlugin $plugdir/monkey-$i.so" >> ..
/conf
/plugins.load
371 echo "#LoadPlugin $dir/$i/monkey-$i.so" >> ..
/conf
/plugins.load
375 # Add 'install' option to make file if plugdir was specified
376 if [ "$plugdir" != "" ]; then
377 echo "\ninstall:" >> Makefile
378 echo "\tinstall -d $plugdir" >> Makefile
380 list
=`echo */ "" | sed "s/\/ /\n/g"`
383 echo "\tinstall -m 644 $dir/$i/monkey-$i.so $plugdir/" >> Makefile
389 # Creando include/info.h
392 cat > $INCDIR/info.h
<<EOF
393 #define OS "$SYSNAME"
394 #define VERSION "$VERSION" /* Version de Monkey */
395 #define MONKEY_PATH_CONF "$sysconfdir"
401 cat > $INCDIR/config.path
<<EOF
406 sysconfdir=$sysconfdir
412 create_banana_script
()
414 cat > bin
/banana
<< EOF
417 # Monkey HTTP Daemon - Banana Script
418 # -----------------------------------
419 # This script allow you to control monkey. Written by Eduardo Silva
420 # ----------------------------
422 # ----------------------------
424 # Use: ./banana OPTION
426 # Options available to banana:
428 # start -> start monkey
429 # restart -> restart monkey
430 # stop -> stop monkey if this is running
431 # help -> what do u think ?
433 PIDFILE="$logdir/monkey.pid"
434 BINMONKEY="$bindir/monkey"
438 -*=*) optarg=\`echo "\$arg" | sed 's/[-_a-zA-Z0-9]*=//'\` ;;
442 if ! test -f \$PIDFILE ; then
445 PIDMONKEY=\`cat \$PIDFILE\`
446 if ! kill -0 \$PIDMONKEY 2>/dev/null; then
455 if [ "\$STATUS" = "yes" ] ; then
456 echo "Monkey is running... (PID=\$PIDMONKEY)"
459 if ! test -x \$BINMONKEY ; then
460 echo "Error: I can't run binary file"
463 if \$BINMONKEY -D 2>/dev/null ; then
464 echo "Running Monkey -> OK"
470 if [ "\$STATUS" = "no" ]; then
471 echo "Monkey is not running."
475 rm -rf \$PIDFILE > /dev/null
476 echo "Monkey stopped (\$PIDMONKEY)"
480 if [ "\$STATUS" = "yes" ]; then
481 if ! kill \$PIDMONKEY > /dev/null ; then
484 echo -n "Stopping Monkey... "
487 echo -n "Monkey is not running... "
489 if ! test -x \$BINMONKEY ; then
490 echo "Error: I can't run binary file"
493 \$BINMONKEY -D > /dev/null
494 echo "Restarting -> OK"
499 echo "Use : banana [start|stop|restart|help]"
504 echo "Use : banana [start|stop|restart|help]"
511 #---------------------------#
513 #---------------------------#
516 #---------------------------#
518 #---------------------------#
523 cgibin
="$aux/cgi-bin"
524 sysconfdir
="$aux/conf"
525 datadir
="$aux/htdocs"
531 optarg
=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
539 cgibin
="$optarg/cgi-bin"
540 sysconfdir
="$optarg/conf"
541 datadir
="$optarg/htdocs"
542 logdir
="$optarg/logs"
569 echo "Monkey HTTP Daemon v$VERSION"
570 echo "-------------------------"
571 echo "Copyright 2001-2010"
572 echo "Developed by Eduardo Silva Pereira"
573 echo "Monkey Home : http://www.monkey-project.com"
574 echo "Contact Email : edsiper@gmail.com"
579 echo "Usage: configure [--prefix=PREFIXDIR] [--lang=LANGUAGE] [ --bindir=BINDIR]"
580 echo " [--cgibin=CGIBINDIR] [--sysconfdir=SYSCONFDIR]"
581 echo " [--datadir=DATADIR] [--logdir=LOGDIR] [--plugdir=PLUGDIR]"
584 echo " --help Display this help and exit"
585 echo " --version Display version information and exit"
587 echo " --prefix=PREFIX Install Monkey under PREFIX directory"
588 echo " --bindir=BINDIR Install Monkey binaries under BINDIR directory"
589 echo " --cgibin=CGIBINDIR Install Monkey cgi-bin under CGIBIN directory"
590 echo " --sysconfdir=SYSCONFDIR Install Monkey conf files under SYSCONFDIR dir"
591 echo " --datadir=DATADIR Install Monkey data dir files under DATADIR directory"
592 echo " --logdir=LOGDIR Install Monkey log files under LOGDIR directory"
593 echo " --plugdir=PLUGDIR Target directory for Monkey plugins"
600 echo "********************************************"
601 echo " Monkey HTTP Daemon v$VERSION "
602 echo "* http://www.monkey-project.com *"
603 echo "* ---------------------------------------- *"
604 echo "* We need beta testers, developers and *"
605 echo "* translators!, if u want help to this *"
606 echo "* project, email me : *"
608 echo "* edsiper@gmail.com *"
610 echo "* Thanks for use Monkey!!! *"
612 echo "********************************************"
613 echo "System : $SYSINFO"
617 # starting main function
618 main prefix lang bindir cgibin sysconfdir datadir logdir plugdir modules SYSNAME VERSION