1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
#!/bin/sh
set -e
CONF="/etc/http-analyze.cfg"
CRON="/var/spool/cron/crontabs/"
CONFNEU="n"
if [ -s $CONF ] && [ -f $CONF ]; then
LINE0="c"
echo "It seems that you already have a http-analyze-configuration."
echo "Do you want to Convert your existing configuration to the "
echo "new format? Otherwise I will create a new one."
echo "[$LINE0]"
echo -n "> "
read CONFNEU
if [ -z $CONFNEU ]; then
CONFNEU=$LINE0
fi
fi
LINE1="monthly"
echo "Please enter wether the mode of operation should be monthly "
echo "or daily. monthly is a lot better imho."
echo "[$LINE1]"
echo -n "> "
read MODE
if [ -z $MODE ]; then
MODE=$LINE1
fi
LINE2="www.`dnsdomainname`"
echo "Please enter the name of your server."
echo "[$LINE2]"
echo -n "> "
read SERVNAME
if [ -z $SERVNAME ]; then
SERVNAME=$LINE2
fi;
LINE3="/var/web/server/access.log"
echo "Please enter the name of the default logfile."
echo "[$LINE3]"
echo -n "> "
read LOGFILE
if [ -z $LOGFILE ]; then
LOGFILE=$LINE3
fi;
LINE4="index.html"
echo "Please enter the name of the normal index page"
echo "[$LINE4]"
echo -n "> "
read INDEX
if [ -z $INDEX ]; then
INDEX=$LINE4
fi
LINE5="/var/web/webspace/stats"
echo "Please enter the complete Path to the directory where"
echo "the stats-files should be created."
echo "[$LINE5]"
echo -n "> "
read HTMLDIR
if [ -z $HTMLDIR ]; then
HTMLDIR=$LINE5
fi
if [ ! -d $HTMLDIR ]; then
mkdir -p $HTMLDIR 2>/dev/null
fi
LINE6="lists"
echo "Please enter the name of a _private_ directory where"
echo "the detailed site/URL lists should be created. Pathnames"
echo "not beginning with a '/' are relative to the previous"
echo "entry. [$LINE6]"
echo -n "> "
read PRIVATEDIR
if [ -z $PRIVATEDIR ]; then
PRIVATEDIR=$LINE6
fi
LINE7="10"
echo "Please enter the number of entries in the top"
echo "sites lists. [$LINE7]"
echo -n "> "
read TOPSITES
if [ -z $TOPSITES ]; then
TOPSITES=$LINE7
fi
LINE8="30"
echo "Please enter the number of entries in the top"
echo "URLs lists. [$LINE8]"
echo -n "> "
read TOPURL
if [ -z $TOPURL ]; then
TOPURL=$LINE8
fi
LINE9="10"
echo "Please enter the number of entries in the last"
echo "URLs lists. [$LINE9]"
echo -n "> "
read LASTURL
if [ -z $LASTURL ]; then
LASTURL=$LINE9
fi
LINE9a="2"
echo "Level of subdomains in hostnames to use in the Top N sites list as an"
echo "item, under which all hostnames from this domain are lumped together."
echo "Valid range: 1-5, Default: 2"
echo "[$LINE9a]"
echo -n "> "
read SHOWDOMAIN
if [ -z $SHOWDOMAIN ]; then
SHOWDOMAIN=$LINE9a
fi
LINE10="Access statistics for $SERVNAME"
echo "Please enter the document title and header to display."
echo "[$LINE10]"
echo -n "> "
read DOCTITLE
if [ -z $DOCTITLE ]; then
DOCTITLE=$LINE10
fi
LINE11='<BODY BGCOLOR="#D6D6D6"><P><HR SIZE="8">'
echo "Please enter the suffix string to output after"
echo "the document header."
echo "[$LINE11]"
echo -n "> "
read HEADPREFIX
if [ -z $HEADPREFIX ]; then
HEADPREFIX=$LINE11
fi
LINE12='<BR><FONT SIZE="-1"><A HREF="/">Back</A> to my homepage</FONT>'
echo "Please enter the trailer string to output at end of page."
echo "[$LINE12]"
echo -n "> "
read DOCTRAILER
if [ -z $DOCTRAILER ]; then
DOCTRAILER=$LINE12
fi
LINE13='www-data'
echo "Please enter the user who will run http-analyze"
echo "[$LINE13]"
echo -n "> "
read CRONUSER
if [ -z $CRONUSER ]; then
CRONUSER=$LINE13
fi
if [ $CONFNEU = "c" ]; then
http-analyze -c $CONF -i ${CONF}.N
mv $CONF ${CONF}.old
mv ${CONF}.N ${CONF}
else
rm -rf $CONF
touch $CONF
echo -e "DefaultMode\t$MODE" > $CONF
echo -e "ServerName\t$SERVNAME" >> $CONF
echo -e "LogFile\t\t${LOGFILE}" >> $CONF
echo -e "HomePage\t$INDEX" >> $CONF
echo -e "OutputDir\t${HTMLDIR}" >> $CONF
echo -e "PrivateDir\t${PRIVATEDIR}" >> $CONF
echo -e "TopSites\t$TOPSITES" >> $CONF
echo -e "TopURLs\t\t$TOPURL" >> $CONF
echo -e "LastURLs\t$LASTURL" >> $CONF
echo -e "ShowDomain\t$SHOWDOMAIN" >> $CONF
echo -e "ReportTitle\t${DOCTITLE}" >> $CONF
echo -e "HTMLPrefix\t${HEADPREFIX}" >> $CONF
# echo -e "HTMLTrailer\t${HEADSUFFIX}" >> $CONF
echo -e "DocTrailer\t${DOCTRAILER}" >> $CONF
echo -e "HideURL\t\t*.map\t[All map files]" >> $CONF
echo -e "HideURL\t\t/robots.txt\t[Internal pages]" >> $CONF
CRON="${CRON}${CRONUSER}"
if [ -f $CRON ]; then
echo -e "0 3 * * *\t\t/usr/bin/http-analyze -c /etc/http-analyze.cfg >/dev/null 2>/dev/null" >> $CRON
else
echo -e "0 3 * * *\t\t/usr/bin/http-analyze -c /etc/http-analyze.cfg >/dev/null 2>/dev/null" > $CRON
fi
chmod 0644 $CONF
chmod 0600 $CRON
fi
echo ""
echo ""
echo "Thank you. This configuration is now written to $CONF."
echo "If you want to change the configuration, just edit "
echo "this file. You will find a sample.conf in"
echo "/usr/doc/http-analyze/examples/. "
echo "Good day."
|