slitaz-modular view initramfs/usr/bin/fake-website @ rev 172

local-mirror: Update local-mirror script.
author Christopher Rogers <slaxemulator@gmail.com>
date Thu Jul 19 11:48:23 2012 +0000 (2012-07-19)
parents 1faf54d48fc1
children
line source
1 #!/bin/sh
3 source /lib/libtaz.sh
4 check_root
5 . /etc/slitaz/slitaz.conf
6 . /etc/local-mirror.conf
8 DIR="$1"
9 WEB_ADDRESS="$2"
10 VERSION="0.1"
11 usage() {
12 echo "$0 $VERSION"
13 echo "$0 /path/to/fake/website fakewebsite.com"
14 echo "NOTE: Don't need http:// for fake website address"
15 exit 1
16 }
18 [ ! -d "$DIR" ] && usage
19 [ "$DIR" = "" -o "$WEB_ADDRESS" = "" ] && usage
21 [ -d $MAIN_WWW_DIR/$(basename $DIR) ] || echo "building $WEB_ADDRESS site"
22 [ -d $MAIN_WWW_DIR ] || mkdir -p $MAIN_WWW_DIR
23 if [ -d $DIR ]; then
24 [ -d $MAIN_WWW_DIR/$(basename $DIR) ] || ln -sf $DIR $MAIN_WWW_DIR/$(basename $DIR)
25 fi
27 if [ ! -f /etc/lighttpd/$WEB_ADDRESS.conf ]; then
28 cat > /etc/lighttpd/$WEB_ADDRESS.conf << EOF
29 \$HTTP["host"] =~ "${WEB_ADDRESS}$" {
30 server.document-root = "$MAIN_WWW_DIR/$(basename $DIR)"
31 server.errorlog = "/var/log/lighttpd/${WEB_ADDRESS}-error.log"
32 accesslog.filename = "/var/log/lighttpd/${WEB_ADDRESS}-access.log"
33 }
34 EOF
35 fi
37 [ -d /var/lib/awstats/$WEB_ADDRESS ] || mkdir -p /var/lib/awstats/$WEB_ADDRESS
38 if [ ! -f /etc/awstats/awstats.${WEB_ADDRESS}.conf ]; then
39 cat > /etc/awstats/awstats.${WEB_ADDRESS}.conf << EOF
40 LogFile="/var/log/lighttpd/${WEB_ADDRESS}-access.log"
41 SiteDomain="$WEB_ADDRESS"
42 DirData="/var/lib/awstats/${WEB_ADDRESS}"
43 LogoLink="http://${WEB_ADDRESS}"
44 Include "/etc/awstats/awstats.optional.conf"
45 EOF
46 fi
48 if [ ! $(grep -l "include \"$WEB_ADDRESS.conf\"" /etc/lighttpd/vhosts-local.conf) ]; then
49 echo "include \"$WEB_ADDRESS.conf\"" >> /etc/lighttpd/vhosts-local.conf
50 fi
52 if [ ! $(grep -l "$IP_ADDR $WEB_ADDRESS" /etc/hosts) ]; then
53 echo "$IP_ADDR $WEB_ADDRESS" >> /etc/hosts
54 fi
56 if [ ! -L /etc/lighttpd/vhosts.conf ]; then
57 ln -sf /etc/lighttpd/vhosts-local.conf /etc/lighttpd/vhosts.conf
58 fi
59 chown www.www -R $MAIN_WWW_DIR