slitaz-modular rev 154
local-mirror: Add fake-website script. This is used to make mirror websites with fake addresses work locally or with dnsmasq. Just start or restart lighttpd after using it.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Sat Dec 24 17:07:37 2011 +0000 (2011-12-24) |
parents | 130e216fd686 |
children | a4df52f75723 |
files | initramfs/usr/bin/fake-website initramfs/usr/bin/local-mirror |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/initramfs/usr/bin/fake-website Sat Dec 24 17:07:37 2011 +0000 1.3 @@ -0,0 +1,59 @@ 1.4 +#!/bin/sh 1.5 + 1.6 +source /usr/lib/slitaz/libtaz 1.7 +source_lib commons 1.8 +check_root 1.9 +. /etc/slitaz/slitaz.conf 1.10 +. /etc/local-mirror.conf 1.11 + 1.12 +DIR="$1" 1.13 +WEB_ADDRESS="$2" 1.14 +VERSION="0.1" 1.15 +usage() { 1.16 + echo "$0 $VERSION" 1.17 + echo "$0 /path/to/fake/website fakewebsite.com" 1.18 + echo "NOTE: Don't need http:// for fake website address" 1.19 + exit 1 1.20 +} 1.21 + 1.22 +[ ! -d "$DIR" ] && usage 1.23 +[ "$DIR" = "" -o "$WEB_ADDRESS" = "" ] && usage 1.24 + 1.25 +[ -d $MAIN_WWW_DIR ] || mkdir -p $MAIN_WWW_DIR 1.26 +if [ -d $DIR ]; then 1.27 + [ -d $MAIN_WWW_DIR/$(basename $DIR) ] || ln -sf $DIR $MAIN_WWW_DIR/$(basename $DIR) 1.28 +fi 1.29 + 1.30 +if [ ! -f /etc/lighttpd/$WEB_ADDRESS.conf ]; then 1.31 + cat > /etc/lighttpd/$WEB_ADDRESS.conf << EOF 1.32 +\$HTTP["host"] =~ "${WEB_ADDRESS}$" { 1.33 + server.document-root = "$MAIN_WWW_DIR/$(basename $DIR)" 1.34 + server.errorlog = "/var/log/lighttpd/${WEB_ADDRESS}-error.log" 1.35 + accesslog.filename = "/var/log/lighttpd/${WEB_ADDRESS}-access.log" 1.36 +} 1.37 +EOF 1.38 +fi 1.39 + 1.40 +[ -d /var/lib/awstats/$WEB_ADDRESS ] || mkdir -p /var/lib/awstats/$WEB_ADDRESS 1.41 +if [ ! -f /etc/awstats/awstats.${WEB_ADDRESS}.conf ]; then 1.42 + cat > /etc/awstats/awstats.${WEB_ADDRESS}.conf << EOF 1.43 +LogFile="/var/log/lighttpd/${WEB_ADDRESS}-access.log" 1.44 +SiteDomain="$WEB_ADDRESS" 1.45 +DirData="/var/lib/awstats/${WEB_ADDRESS}" 1.46 +LogoLink="http://${WEB_ADDRESS}" 1.47 +Include "/etc/awstats/awstats.optional.conf" 1.48 +EOF 1.49 +fi 1.50 + 1.51 +if [ ! $(grep -l "include \"$WEB_ADDRESS.conf\"" /etc/lighttpd/vhosts-local.conf) ]; then 1.52 + echo "include \"$WEB_ADDRESS.conf\"" >> /etc/lighttpd/vhosts-local.conf 1.53 +fi 1.54 + 1.55 +if [ ! $(grep -l "$IP_ADDR $WEB_ADDRESS" /etc/hosts) ]; then 1.56 + echo "$IP_ADDR $WEB_ADDRESS" >> /etc/hosts 1.57 +fi 1.58 + 1.59 +if [ ! -L /etc/lighttpd/vhosts.conf ]; then 1.60 + ln -sf /etc/lighttpd/vhosts-local.conf /etc/lighttpd/vhosts.conf 1.61 +fi 1.62 +chown www.www -R $MAIN_WWW_DIR
2.1 --- a/initramfs/usr/bin/local-mirror Sat Dec 24 16:44:02 2011 +0000 2.2 +++ b/initramfs/usr/bin/local-mirror Sat Dec 24 17:07:37 2011 +0000 2.3 @@ -278,35 +278,43 @@ 2.4 #[ -f /etc/mercurial/hgweb.conf ] && sed -i 's|style = slitaz|style = gitweb|g' /etc/mercurial/hgweb.config 2.5 ;; 2.6 lfs) 2.7 - [ -d $MAIN_WWW_DIR/lfs ] || ln -sf /usr/share/doc/lfs-book $MAIN_WWW_DIR/lfs ;; 2.8 + #[ -d $MAIN_WWW_DIR/lfs ] || ln -sf /usr/share/doc/lfs-book $MAIN_WWW_DIR/lfs ;; 2.9 + fake-website /usr/share/doc/lfs-book lfs.slitaz.org ;; 2.10 hgbook) 2.11 - if [ -d /usr/share/hgbook ]; then 2.12 - [ -d $MAIN_WWW_DIR/hgbook ] || ln -sf /usr/share/hgbook $MAIN_WWW_DIR/hgbook 2.13 - fi ;; 2.14 + #if [ -d /usr/share/hgbook ]; then 2.15 + # [ -d $MAIN_WWW_DIR/hgbook ] || ln -sf /usr/share/hgbook $MAIN_WWW_DIR/hgbook 2.16 + #fi ;; 2.17 + fake-website /usr/share/hgbook hgbook.slitaz.org ;; 2.18 absguide) 2.19 - if [ -d /usr/share/absguide ]; then 2.20 - [ -d $MAIN_WWW_DIR/absguide ] || ln -sf /usr/share/absguide $MAIN_WWW_DIR/absguide 2.21 - fi ;; 2.22 + #if [ -d /usr/share/absguide ]; then 2.23 + # [ -d $MAIN_WWW_DIR/absguide ] || ln -sf /usr/share/absguide $MAIN_WWW_DIR/absguide 2.24 + #fi ;; 2.25 + fake-website /usr/share/absguide absguide.slitaz.org ;; 2.26 man-html) 2.27 - if [ -d /usr/share/man-html ]; then 2.28 - [ -d $MAIN_WWW_DIR/man-html ] || ln -sf /usr/share/man-html $MAIN_WWW_DIR/man-html 2.29 - fi ;; 2.30 + #if [ -d /usr/share/man-html ]; then 2.31 + # [ -d $MAIN_WWW_DIR/man-html ] || ln -sf /usr/share/man-html $MAIN_WWW_DIR/man-html 2.32 + #fi ;; 2.33 + fake-website /usr/share/mam-html man-html.slitaz.org ;; 2.34 gimp.en) 2.35 - if [ -d /usr/share/gimp/2.0/help/en ]; then 2.36 - [ -d $MAIN_WWW_DIR/gimp_en ] || ln -sf /usr/share/gimp/2.0/help/en $MAIN_WWW_DIR/gimp_en 2.37 - fi ;; 2.38 + #if [ -d /usr/share/gimp/2.0/help/en ]; then 2.39 + # [ -d $MAIN_WWW_DIR/gimp_en ] || ln -sf /usr/share/gimp/2.0/help/en $MAIN_WWW_DIR/gimp_en 2.40 + #fi ;; 2.41 + fake-website /usr/share/gimp/2.0/help/en gimp.en.slitaz.org ;; 2.42 gimp.fr) 2.43 - if [ -d /usr/share/gimp/2.0/help/fr ]; then 2.44 - [ -d $MAIN_WWW_DIR/gimp_fr ] || ln -sf /usr/share/gimp/2.0/help/fr $MAIN_WWW_DIR/gimp_fr 2.45 - fi ;; 2.46 + #if [ -d /usr/share/gimp/2.0/help/fr ]; then 2.47 + # [ -d $MAIN_WWW_DIR/gimp_fr ] || ln -sf /usr/share/gimp/2.0/help/fr $MAIN_WWW_DIR/gimp_fr 2.48 + #fi ;; 2.49 + fake-website /usr/share/gimp/2.0/help/fr gimp.fr.slitaz.org ;; 2.50 gimp.es) 2.51 - if [ -d /usr/share/gimp/2.0/help/es ]; then 2.52 - [ -d $MAIN_WWW_DIR/gimp_es ] || ln -sf /usr/share/gimp/2.0/help/es $MAIN_WWW_DIR/gimp_es 2.53 - fi ;; 2.54 + #if [ -d /usr/share/gimp/2.0/help/es ]; then 2.55 + # [ -d $MAIN_WWW_DIR/gimp_es ] || ln -sf /usr/share/gimp/2.0/help/es $MAIN_WWW_DIR/gimp_es 2.56 + #fi ;; 2.57 + fake-website /usr/share/gimp/2.0/help/es gimp.es.slitaz.org ;; 2.58 linuxgazette) 2.59 - if [ -d /repos/linuxgazette ]; then 2.60 - [ -d $MAIN_WWW_DIR/linuxgazette ] || ln -sf /repos/linuxgazette $MAIN_WWW_DIR/linuxgazette 2.61 - fi ;; 2.62 + #if [ -d /repos/linuxgazette ]; then 2.63 + # [ -d $MAIN_WWW_DIR/linuxgazette ] || ln -sf /repos/linuxgazette $MAIN_WWW_DIR/linuxgazette 2.64 + #fi ;; 2.65 + fake-website /repos/linuxgazette linuxgazette.net 2.66 esac 2.67 } 2.68 2.69 @@ -418,8 +426,8 @@ 2.70 [ "$c" = "hg" ] && repos 2.71 fi 2.72 done 2.73 - echo "127.0.0.1 localhost $(cat /etc/hostname)" > /etc/hosts 2.74 - [ "$IP_ADDR" == "127.0.0.1" ] && echo "127.0.0.1 tazpanel tazpanel.slitaz.org" >> /etc/hosts 2.75 + #echo "127.0.0.1 localhost $(cat /etc/hostname)" > /etc/hosts 2.76 + [ "$IP_ADDR" == "127.0.0.1" ] && echo "127.0.0.1 tazpanel.slitaz.org" >> /etc/hosts 2.77 for hostname in $ADDRESS; do 2.78 if [ "$hostname" = "www.slitaz.org" ]; then 2.79 echo "$IP_ADDR $hostname slitaz.org" >> /etc/hosts