diff --git a/configure b/configure index d4b94d09..e6203a10 100755 --- a/configure +++ b/configure @@ -621,6 +621,7 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS +LIBEXECDIR DATADIR CFGDIR PSQL_CONFIG @@ -4564,6 +4565,30 @@ _ACEOF + +libexec_dir=`echo $libexecdir | grep prefix` + +if test -n "$libexec_dir"; then + if test "$prefix" = "NONE" + then + libexec_dir="$ac_default_prefix/libexec" + else + libexec_dir="$prefix/libexec" + fi +else + libexec_dir="$libexecdir" +fi + +LIBEXECDIR=$libexec_dir + + +cat >>confdefs.h <<_ACEOF +#define LIBEXECDIR "$libexec_dir" +_ACEOF + + + + cat >>confdefs.h <<_ACEOF #define VIRUS_TEMPLATE "$my_prefix/share/clapf/template.virus" _ACEOF diff --git a/configure.in b/configure.in index baba8486..81c53631 100644 --- a/configure.in +++ b/configure.in @@ -310,6 +310,27 @@ DATADIR=$data_dir AC_SUBST(DATADIR) AC_DEFINE_UNQUOTED(DATADIR,"$data_dir",[where to look for the data files]) + +dnl configure libexec directory + +libexec_dir=`echo $libexecdir | grep prefix` + +if test -n "$libexec_dir"; then + if test "$prefix" = "NONE" + then + libexec_dir="$ac_default_prefix/libexec" + else + libexec_dir="$prefix/libexec" + fi +else + libexec_dir="$libexecdir" +fi + +LIBEXECDIR=$libexec_dir +AC_SUBST(LIBEXECDIR) +AC_DEFINE_UNQUOTED(LIBEXECDIR,"$libexec_dir",[where to look for the piler helpers]) + + AC_DEFINE_UNQUOTED(VIRUS_TEMPLATE, "$my_prefix/share/clapf/template.virus", [where the virus template is]) AC_DEFINE_UNQUOTED(ZOMBIE_NET_REGEX, "$my_prefix/share/clapf/zombienets.regex", [where the virus template is]) diff --git a/init.d/Makefile.in b/init.d/Makefile.in index 60834657..560f5eba 100644 --- a/init.d/Makefile.in +++ b/init.d/Makefile.in @@ -29,6 +29,8 @@ all: install: + $(INSTALL) -m 0755 $(srcdir)/rc.piler $(DESTDIR)/etc/init.d/rc.piler + $(INSTALL) -m 0755 $(srcdir)/rc.searchd $(DESTDIR)/etc/init.d/rc.searchd clean: rm -f rc.piler rc.pilergetd rc.searchd diff --git a/util/Makefile.in b/util/Makefile.in index 48fa53ab..0f54b724 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -25,6 +25,8 @@ RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)` INSTALL = @INSTALL@ all: + sed -e "s%BINDIR%$(bindir)%" -e "s%__SYSCONFDIR%$(sysconfdir)%" -e "s%__LOCALSTATEDIR%$($localstatedir)%" -e "s%__LIBEXECDIR%$($libexecdir)%" $(srcdir)/postinstall.sh.in > $(srcdir)/postinstall.sh + install: $(INSTALL) -m 0755 $(srcdir)/daily-report.php $(DESTDIR)$(libexecdir)/piler @@ -33,6 +35,7 @@ install: $(INSTALL) -m 0755 $(srcdir)/indexer.delta.sh $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/indexer.main.sh $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/import.sh $(DESTDIR)$(libexecdir)/piler + $(INSTALL) -m 0755 $(srcdir)/postinstall.sh $(DESTDIR)$(libexecdir)/piler clean: diff --git a/util/postinstall.sh b/util/postinstall.sh.in similarity index 72% rename from util/postinstall.sh rename to util/postinstall.sh.in index fb66550f..0056dc77 100755 --- a/util/postinstall.sh +++ b/util/postinstall.sh.in @@ -7,7 +7,167 @@ CRON_ORIG="/tmp/crontab.piler.orig" CRON_TMP="/tmp/crontab.piler" PILERCONF_TMP="/tmp/config.piler.88" -. ./util/utilfunc.sh + +load_default_values() { + PILERUSER="piler" + PILERGROUP="piler" + SYSCONFDIR=__SYSCONFDIR + LOCALSTATEDIR=__LOCALSTATEDIR + LIBEXECDIR=__LIBEXECDIR + + KEYTMPFILE="piler.key" + KEYFILE="$SYSCONFDIR/piler.key" + + HOSTNAME=`hostname --fqdn` + + MYSQL_HOSTNAME="localhost" + MYSQL_DATABASE="piler" + MYSQL_USERNAME="piler" + MYSQL_PASSWORD="" + MYSQL_ROOT_PASSWORD="" + + SPHINXCFG="/usr/local/etc/sphinx.conf" + + WWWGROUP="apache" + DOCROOT="/var/www/$HOSTNAME" + + SMARTHOST="" + SMARTHOST_PORT=25 + + SSL_CERT_DATA="/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" +} + + +make_certificate() { + if [ ! -f $SYSCONFDIR/piler.pem ]; then + echo -n "Making an ssl certificate ... " + openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "$SSL_CERT_DATA" -keyout $SYSCONFDIR/piler.pem -out 1.cert + cat 1.cert >> $SYSCONFDIR/piler.pem + chmod 600 $SYSCONFDIR/piler.pem + rm 1.cert + fi +} + + +display_install_intro() { + echo "" + echo "" + echo "This is the postinstall utility for piler" + echo "It should be run only at the first install. DO NOT run on an existing piler installation!" + echo "" + + askYN "Continue? [Y/N]" "N" + if [ $response != "yes" ]; then + echo "Aborted." + exit + fi + + echo "" +} + + +check_user() { + user=$1 + + if [ x`whoami` != x$user ]; then echo "ERROR: postinstaller must be run as $user user"; exit 1; fi +} + + +isFQDN() { + # we need min. 2 dots + if [ x"$1" = "xdogfood" ]; then + echo 1 + return + fi + + if [ x"$1" = "x" ]; then + echo 0 + return + fi + + NF=`echo $1 | awk -F. '{print NF}'` + if [ $NF -ge 2 ]; then + echo 1 + else + echo 0 + fi +} + + +ask() { + PROMPT=$1 + DEFAULT=$2 + + echo "" + echo -n "$PROMPT [$DEFAULT] " + read response + + if [ -z $response ]; then + response=$DEFAULT + fi +} + + +askNonBlankNoEcho() { + PROMPT=$1 + DEFAULT=$2 + + while [ 1 ]; do + stty -echo + ask "$PROMPT" "$DEFAULT" + stty echo + echo "" + if [ ! -z $response ]; then + break + fi + echo "A non-blank answer is required" + done +} + + +askNonBlank() { + PROMPT=$1 + DEFAULT=$2 + + while [ 1 ]; do + ask "$PROMPT" "$DEFAULT" + if [ ! -z $response ]; then + break + fi + echo "A non-blank answer is required" + done +} + + +askYN() { + PROMPT=$1 + DEFAULT=$2 + + if [ "x$DEFAULT" = "xyes" -o "x$DEFAULT" = "xYes" -o "x$DEFAULT" = "xy" -o "x$DEFAULT" = "xY" ]; then + DEFAULT="Y" + else + DEFAULT="N" + fi + + while [ 1 ]; do + ask "$PROMPT" "$DEFAULT" + response=$(perl -e "print lc(\"$response\");") + if [ -z $response ]; then + : + else + if [ $response = "yes" -o $response = "y" ]; then + response="yes" + break + else + if [ $response = "no" -o $response = "n" ]; then + response="no" + break + fi + fi + fi + echo "A Yes/No answer is required" + done +} preinstall_check() { @@ -195,6 +355,8 @@ execute_post_install_tasks() { rm -f $KEYTMPFILE echo "Done." + make_certificate + sed "s/mysqlpwd=verystrongpassword/mysqlpwd=$MYSQL_PASSWORD/" $SYSCONFDIR/piler.conf > $PILERCONF_TMP cat $PILERCONF_TMP > $SYSCONFDIR/piler.conf rm -f $PILERCONF_TMP @@ -259,14 +421,6 @@ clean_up_temp_stuff() { load_default_values -if [ $# -ne 5 ]; then usage; fi - -PILERUSER=$1 -PILERGROUP=$2 -SYSCONFDIR=$3 -LOCALSTATEDIR=$4 -LIBEXECDIR=$5 - #LOGFILE="/tmp/piler-install.log.$$" #touch $LOGFILE #chmod 600 $LOGFILE diff --git a/util/utilfunc.sh b/util/utilfunc.sh deleted file mode 100644 index 1bfe7a8b..00000000 --- a/util/utilfunc.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/bin/sh - - -usage() { - echo "usage: $0 "; - exit 1; -} - - -load_default_values() { - PILERUSER="piler" - SYSCONFDIR="/usr/local/etc" - LOCALSTATEDIR="/var" - LIBEXECDIR="/usr/local/libexec" - - KEYTMPFILE="piler.key" - KEYFILE="$SYSCONFDIR/piler.key" - - HOSTNAME=`hostname --fqdn` - - MYSQL_HOSTNAME="localhost" - MYSQL_DATABASE="piler" - MYSQL_USERNAME="piler" - MYSQL_PASSWORD="" - MYSQL_ROOT_PASSWORD="" - - SPHINXCFG="/usr/local/etc/sphinx.conf" - - WWWGROUP="apache" - DOCROOT="/var/www/$HOSTNAME" - - SMARTHOST="" - SMARTHOST_PORT=25 -} - - -display_install_intro() { - echo "" - echo "" - echo "This is the postinstall utility for piler" - echo "It should be run only at the first install. DO NOT run on an existing piler installation!" - echo "" - - askYN "Continue? [Y/N]" "N" - if [ $response != "yes" ]; then - echo "Aborted." - exit - fi - - echo "" -} - - -check_user() { - user=$1 - - if [ x`whoami` != x$user ]; then echo "ERROR: postinstaller must be run as $user user"; exit 1; fi -} - - -isFQDN() { - # we need min. 2 dots - if [ x"$1" = "xdogfood" ]; then - echo 1 - return - fi - - if [ x"$1" = "x" ]; then - echo 0 - return - fi - - NF=`echo $1 | awk -F. '{print NF}'` - if [ $NF -ge 2 ]; then - echo 1 - else - echo 0 - fi -} - - -ask() { - PROMPT=$1 - DEFAULT=$2 - - echo "" - echo -n "$PROMPT [$DEFAULT] " - read response - - if [ -z $response ]; then - response=$DEFAULT - fi -} - - -askNonBlankNoEcho() { - PROMPT=$1 - DEFAULT=$2 - - while [ 1 ]; do - stty -echo - ask "$PROMPT" "$DEFAULT" - stty echo - echo "" - if [ ! -z $response ]; then - break - fi - echo "A non-blank answer is required" - done -} - -askNonBlank() { - PROMPT=$1 - DEFAULT=$2 - - while [ 1 ]; do - ask "$PROMPT" "$DEFAULT" - if [ ! -z $response ]; then - break - fi - echo "A non-blank answer is required" - done -} - -askYN() { - PROMPT=$1 - DEFAULT=$2 - - if [ "x$DEFAULT" = "xyes" -o "x$DEFAULT" = "xYes" -o "x$DEFAULT" = "xy" -o "x$DEFAULT" = "xY" ]; then - DEFAULT="Y" - else - DEFAULT="N" - fi - - while [ 1 ]; do - ask "$PROMPT" "$DEFAULT" - response=$(perl -e "print lc(\"$response\");") - if [ -z $response ]; then - : - else - if [ $response = "yes" -o $response = "y" ]; then - response="yes" - break - else - if [ $response = "no" -o $response = "n" ]; then - response="no" - break - fi - fi - fi - echo "A Yes/No answer is required" - done -} - -