wok-stable rev 5973
mirror-tools: add host scripts
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Aug 08 19:48:39 2010 +0200 (2010-08-08) |
parents | a0dc4b416eca |
children | 7cc5d70d5d9b |
files | mirror-tools/stuff/host/boot/lguest-disk mirror-tools/stuff/host/boot/lguest-slitaz mirror-tools/stuff/host/etc/apache/conf.d/slitaz mirror-tools/stuff/host/etc/apache/conf.d/slitaz-ssl mirror-tools/stuff/host/install |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mirror-tools/stuff/host/boot/lguest-disk Sun Aug 08 19:48:39 2010 +0200 1.3 @@ -0,0 +1,59 @@ 1.4 +#!/bin/sh 1.5 + 1.6 +usage() 1.7 +{ 1.8 + cat << EOT 1.9 +resize2fs 1.10 +usage: 1.11 +$0 grow <guest> <size>[MG] 1.12 +$0 fixmbr <guest> 1.13 +EOT 1.14 + exit 1 1.15 +} 1.16 + 1.17 +grow() 1.18 +{ 1.19 + case "$2" in 1.20 + *M) dd if=/dev/zero bs=1M count=${2%M} >> /boot/guests/$1 ;; 1.21 + *G) dd if=/dev/zero bs=1G count=${2%G} >> /boot/guests/$1 ;; 1.22 + esac 1.23 +} 1.24 + 1.25 +# write a 32 bits data 1.26 +# usage: storelong offset data32 file 1.27 +storelong() 1.28 +{ 1.29 + printf "00000 %02X %02X %02X %02X \n" \ 1.30 + $(( $2 & 255 )) $(( ($2>>8) & 255 )) \ 1.31 + $(( ($2>>16) & 255 )) $(( ($2>>24) & 255 )) | \ 1.32 + hexdump -R | dd bs=1 conv=notrunc of=$3 seek=$(( $1 )) 2> /dev/null 1.33 +} 1.34 + 1.35 +# read a 32 bits data 1.36 +# usage: getlong offset file 1.37 +getlong() 1.38 +{ 1.39 + dd if=$2 bs=1 skip=$(( $1 )) count=4 2> /dev/null | \ 1.40 + hexdump -e '"" 1/4 "%d" "\n"' 1.41 +} 1.42 + 1.43 +fixmbr() 1.44 +{ 1.45 + if [ $(getlong 0x1ea $1) -ne 0 -a $(getlong 0x1fa $1) -ne 0 ]; then 1.46 + echo "Parttion 3 & 4 non empty. Abort" 1.47 + exit 1 1.48 + fi 1.49 + if [ $(getlong 0x1da $1) -eq 0 ]; then 1.50 + echo "Parttion 2 empty. Abort" 1.51 + exit 1 1.52 + fi 1.53 + size=$(stat -c %s $1) 1.54 + new=$(( $size/512 - 32 - $(getlong 0x1ca $1) )) 1.55 + storelong 0x1da $new $1 1.56 +} 1.57 + 1.58 +case "$1" in 1.59 +grow) shift; grow $@ ; fixmbr $1 ;; 1.60 +fixmbr) shift; fixmbr $1 ;; 1.61 +*) usage ;; 1.62 +esac
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/mirror-tools/stuff/host/boot/lguest-slitaz Sun Aug 08 19:48:39 2010 +0200 2.3 @@ -0,0 +1,21 @@ 2.4 +#!/bin/sh 2.5 + 2.6 +tty=tty; [ -n "$1" ] && tty=$1 2.7 +export TERM=$tty 2.8 +shift 2.9 + 2.10 +rootfs="--initrd=/boot/rootfs-lguest.gz" 2.11 +[ -n "$1" ] && rootfs="--block=$1 root=/dev/vda2" 2.12 +shift 2.13 + 2.14 +net="--tunnet=192.168.0.1" 2.15 +case "$1" in 2.16 +192*) net="--tunnet=$1"; shift;; 2.17 +esac 2.18 + 2.19 +args="screen=text lang=fr_FR kmap=fr-latin1 sound=noconf" 2.20 +[ -n "$1" ] && args=$@ 2.21 + 2.22 +/sbin/modprobe lg 2.23 +/usr/bin/lguest 512 /boot/vmlinuz-2.6.25.5-lguest \ 2.24 + $net $rootfs $args > /dev/$tty < /dev/$tty 2>&1
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/mirror-tools/stuff/host/etc/apache/conf.d/slitaz Sun Aug 08 19:48:39 2010 +0200 3.3 @@ -0,0 +1,16 @@ 3.4 +<VirtualHost *:80> 3.5 + ServerName mirror.slitaz.org 3.6 + ServerAlias *.slitaz.org 3.7 + <IfModule mod_proxy.c> 3.8 + ProxyPreserveHost On 3.9 + ProxyRequests Off 3.10 + ProxyTimeout 600 3.11 + <Proxy *> 3.12 + Order deny,allow 3.13 + Allow from all 3.14 + </Proxy> 3.15 + ProxyPass / http://192.168.0.6/ 3.16 + ProxyPassReverse / http://192.168.0.6/ 3.17 + </IfModule> 3.18 +</VirtualHost> 3.19 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/mirror-tools/stuff/host/etc/apache/conf.d/slitaz-ssl Sun Aug 08 19:48:39 2010 +0200 4.3 @@ -0,0 +1,20 @@ 4.4 +<VirtualHost *:443> 4.5 + SSLProxyEngine On 4.6 + SSLEngine On 4.7 + ServerName mirror.slitaz.org:443 4.8 + ServerAlias *.slitaz.org 4.9 + SSLCertificateFile /etc/ssl/apache/slitaz.org.pem 4.10 + SSLCertificateKeyFile /etc/ssl/apache/slitaz.org.pem 4.11 + <IfModule mod_proxy.c> 4.12 + ProxyPreserveHost On 4.13 + ProxyRequests Off 4.14 + ProxyTimeout 600 4.15 + <Proxy *> 4.16 + Order deny,allow 4.17 + Allow from all 4.18 + </Proxy> 4.19 + ProxyPass / http://192.168.0.6/ 4.20 + ProxyPassReverse / http://192.168.0.6/ 4.21 + </IfModule> 4.22 +</VirtualHost> 4.23 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/mirror-tools/stuff/host/install Sun Aug 08 19:48:39 2010 +0200 5.3 @@ -0,0 +1,25 @@ 5.4 +#!/bin/sh 5.5 + 5.6 +grep -qs lguest-slitaz /etc/inittab || { 5.7 +sed -i 's|^tty1::|tty16::respawn:/boot/lguest-slitaz tty16 /boot/guests/mirror.slitaz.org 192.168.0.1\n&|' /etc/inittab 5.8 +cat >> /etc/init.d/local.sh <<EOT 5.9 +. /etc/network.conf 5.10 +iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE 5.11 +for port in 22 873 ; do 5.12 + iptables -t nat -A PREROUTING -i $INTERFACE --dport $port \ 5.13 + -j DNAT --to-destination 192.168.0.6:$port 5.14 +done 5.15 +for port in 80 443 ; do 5.16 + iptables -A INPUT -p tcp -m tcp --dport $port -j ACCEPT 5.17 +done 5.18 +for iface in tap+ ; do 5.19 + iptables -A INPUT -i $iface -j ACCEPT 5.20 + iptables -A OUTPUT -o $iface -j ACCEPT 5.21 + iptables -A FORWARD -i $iface -m state \ 5.22 + --state NEW,RELATED,ESTABLISHED,UNTRACKED -j ACCEPT 5.23 + iptables -A FORWARD -o $iface -m state \ 5.24 + --state NEW,RELATED,ESTABLISHED,UNTRACKED -j ACCEPT 5.25 +done 5.26 +echo "1" > /proc/sys/net/ipv4/ip_forward 5.27 +EOT 5.28 +}