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

fake-website: Only echo building $WEB_ADDRESS site when folder doesn't exist.
author Christopher Rogers <slaxemulator@gmail.com>
date Tue Jan 24 04:53:38 2012 -0500 (2012-01-24)
parents a260a9380e9d
children b227f5995c89
line source
1 #!/bin/sh
3 source /usr/lib/slitaz/libtaz
4 source_lib commons
5 check_root
6 . /etc/slitaz/slitaz.conf
7 . /etc/local-mirror.conf
9 DIR="$1"
10 WEB_ADDRESS="$2"
11 VERSION="0.1"
12 usage() {
13 echo "$0 $VERSION"
14 echo "$0 /path/to/fake/website fakewebsite.com"
15 echo "NOTE: Don't need http:// for fake website address"
16 exit 1
17 }
19 [ ! -d "$DIR" ] && usage
20 [ "$DIR" = "" -o "$WEB_ADDRESS" = "" ] && usage
22 [ -d $MAIN_WWW_DIR/$(basename $DIR) ] || echo "building $WEB_ADDRESS site"
23 [ -d $MAIN_WWW_DIR ] || mkdir -p $MAIN_WWW_DIR
24 if [ -d $DIR ]; then
25 [ -d $MAIN_WWW_DIR/$(basename $DIR) ] || ln -sf $DIR $MAIN_WWW_DIR/$(basename $DIR)
26 fi
28 if [ ! -f /etc/lighttpd/$WEB_ADDRESS.conf ]; then
29 cat > /etc/lighttpd/$WEB_ADDRESS.conf << EOF
30 \$HTTP["host"] =~ "${WEB_ADDRESS}$" {
31 server.document-root = "$MAIN_WWW_DIR/$(basename $DIR)"
32 server.errorlog = "/var/log/lighttpd/${WEB_ADDRESS}-error.log"
33 accesslog.filename = "/var/log/lighttpd/${WEB_ADDRESS}-access.log"
34 }
35 EOF
36 fi
38 [ -d /var/lib/awstats/$WEB_ADDRESS ] || mkdir -p /var/lib/awstats/$WEB_ADDRESS
39 if [ ! -f /etc/awstats/awstats.${WEB_ADDRESS}.conf ]; then
40 cat > /etc/awstats/awstats.${WEB_ADDRESS}.conf << EOF
41 LogFile="/var/log/lighttpd/${WEB_ADDRESS}-access.log"
42 SiteDomain="$WEB_ADDRESS"
43 DirData="/var/lib/awstats/${WEB_ADDRESS}"
44 LogoLink="http://${WEB_ADDRESS}"
45 Include "/etc/awstats/awstats.optional.conf"
46 EOF
47 fi
49 if [ ! $(grep -l "include \"$WEB_ADDRESS.conf\"" /etc/lighttpd/vhosts-local.conf) ]; then
50 echo "include \"$WEB_ADDRESS.conf\"" >> /etc/lighttpd/vhosts-local.conf
51 fi
53 if [ ! $(grep -l "$IP_ADDR $WEB_ADDRESS" /etc/hosts) ]; then
54 echo "$IP_ADDR $WEB_ADDRESS" >> /etc/hosts
55 fi
57 if [ ! -L /etc/lighttpd/vhosts.conf ]; then
58 ln -sf /etc/lighttpd/vhosts-local.conf /etc/lighttpd/vhosts.conf
59 fi
60 chown www.www -R $MAIN_WWW_DIR