xentaur

diff build-xenomips-image @ 1:50d24d4b810d

Xentaurs files have moved to CVS tree.
author igor
date Fri Jul 13 16:57:33 2007 +0300 (2007-07-13)
parents
children 825cd93472de
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-xenomips-image	Fri Jul 13 16:57:33 2007 +0300
     1.3 @@ -0,0 +1,123 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +DYNAMIPS_BUILD=yes
     1.7 +XENOMIPS_FS_BUILD=yes
     1.8 +CONFIG_FS_BUILD=no
     1.9 +IOS_FS_BUILD=yes
    1.10 +
    1.11 +#Xenomips FS
    1.12 +XENOMIPS_FS_SIZE=2048k                  # size in 1k blocks
    1.13 +XENOMIPS_FS_NAME=xenomips1.img
    1.14 +
    1.15 +# Config FS
    1.16 +CONFIG_FS_SIZE=100k
    1.17 +CONFIG_FS_NAME=xenomips-config1.img
    1.18 +
    1.19 +# IOS FS
    1.20 +IOS_FS_SIZE=2048k
    1.21 +IOS_FS_NAME=xenomips-ios1.img
    1.22 +
    1.23 +
    1.24 +XENOMIPS_DIR="files/"
    1.25 +
    1.26 +
    1.27 +DEBIAN_MIRROR=http://debian.org.ua/debian
    1.28 +DISTRO=sid
    1.29 +PACKAGES="openssh-server libc6-xen libelf1 libpcap0.8 screen nfs-common quagga"
    1.30 +DYNAMIPS_SOURCES=http://www.ipflow.utc.fr/dynamips/dynamips-0.2.7.tar.gz
    1.31 +DYNAMIPS_BUILD_DIR=dynamips/
    1.32 +KERNEL_VERSION=`uname -r`
    1.33 +SSH_OPEN_KEY=files/id_dsa.pub
    1.34 +
    1.35 +IOS_DIR="ios/"
    1.36 +
    1.37 +WORK_DIR=${XENOMIPS_FS_NAME%%.img}
    1.38 +
    1.39 +build_and_install_dynamips()
    1.40 +{
    1.41 +    OLD_PWD="`pwd`"
    1.42 +    DESTDIR=`pwd`/${WORK_DIR}
    1.43 +
    1.44 +    if echo $DYNAMIPS_BUILD | grep -qi ^y
    1.45 +    then
    1.46 +        rm -rf ${DYNAMIPS_BUILD_DIR}/
    1.47 +        mkdir -p ${DYNAMIPS_BUILD_DIR}/
    1.48 +        cd ${DYNAMIPS_BUILD_DIR}/
    1.49 +        wget $DYNAMIPS_SOURCES
    1.50 +        tar xfz dynamips*tar*
    1.51 +        cd dynamips*/
    1.52 +        perl -p -i -e s@^PCAP_LIB=.*@PCAP_LIB=-lpcap@ Makefile
    1.53 +        make
    1.54 +    else
    1.55 +        cd ${DYNAMIPS_BUILD_DIR}/dynamips*/
    1.56 +    fi
    1.57 +    make install DESTDIR=${DESTDIR}
    1.58 +    cd ${OLD_PWD}
    1.59 +}
    1.60 +
    1.61 +
    1.62 +dd if=/dev/zero of=${XENOMIPS_FS_NAME} count=${XENOMIPS_FS_SIZE} bs=1024
    1.63 +mkfs.ext3 -F ${XENOMIPS_FS_NAME}
    1.64 +mkdir -p ${WORK_DIR}
    1.65 +mount -o loop ${XENOMIPS_FS_NAME} ${WORK_DIR}
    1.66 +debootstrap  ${DISTRO} ${WORK_DIR} ${DEBIAN_MIRROR} 
    1.67 +cat <<SCRIPT | chroot ${WORK_DIR} sh -s
    1.68 +unset LANG
    1.69 +apt-get -y --force-yes install ${PACKAGES}
    1.70 +/etc/init.d/ssh stop
    1.71 +cat <<FSTAB > /etc/fstab
    1.72 +/dev/hda1       /                       ext3    ro              0       0
    1.73 +/dev/hda2       /xenomips/ios           ext3    ro              0       0
    1.74 +/dev/hda3       /xenomips/config        ext3    rw              0       0
    1.75 +FSTAB
    1.76 +mkdir -p /data/Cisco_IOS /xenomips
    1.77 +
    1.78 +cat <<'INTERFACES' > /etc/network/interfaces
    1.79 +auto lo eth0
    1.80 +
    1.81 +iface lo inet loopback 
    1.82 +        up for i in \`ifconfig -a | grep 'eth.*Link encap' | awk '{print \$1}'\`; do ifconfig \$i up ; done || true
    1.83 +
    1.84 +iface eth0 inet dhcp
    1.85 +INTERFACES
    1.86 +
    1.87 +echo /usr/local/bin/xenomips.sh > /etc/rc.local
    1.88 +cd /etc/rcS.d; ln -s ../init.d/xenomips-init S35xenomips-init
    1.89 +rm /etc/rc2.d/S*quagga
    1.90 +
    1.91 +perl -i -p -e s@C_PATH=/etc/quagga@C_PATH=/xenomips/etc/quagga@ /etc/init.d/quagga
    1.92 +
    1.93 +mkdir -p /xenomips/{ios,config,dynamips,etc/quagga} /var/lib/xenomips /root/.ssh
    1.94 +
    1.95 +screen -ls | grep -q Attached && screen -x || screen -ls | grep -q Detached && screen -r
    1.96 +SCRIPT
    1.97 +
    1.98 +cp -R /lib/modules/${KERNEL_VERSION} ${WORK_DIR}/lib/modules
    1.99 +
   1.100 +cp ${XENOMIPS_DIR}/xenomips-init ${WORK_DIR}/etc/init.d/
   1.101 +cp ${XENOMIPS_DIR}/xenomips.sh ${WORK_DIR}/usr/local/bin
   1.102 +sudo chmod +x  ${WORK_DIR}/usr/local/bin/xenomips.sh ${WORK_DIR}/etc/init.d/xenomips-init
   1.103 +
   1.104 +cat ${SSH_OPEN_KEY} > ${WORK_DIR}/root/.ssh/authorized_keys
   1.105 +chmod 600  ${WORK_DIR}/root/.ssh/authorized_keys
   1.106 +
   1.107 +build_and_install_dynamips
   1.108 +
   1.109 +umount ${WORK_DIR}
   1.110 +
   1.111 +if  echo $CONFIG_FS_BUILD | grep -qi ^y
   1.112 +then
   1.113 +    dd if=/dev/zero of=${CONFIG_FS_NAME} bs=1k count=${CONFIG_FS_SIZE}
   1.114 +    mkfs.ext3 -F ${CONFIG_FS_NAME}
   1.115 +fi
   1.116 +
   1.117 +
   1.118 +if echo $IOS_FS_BUILD | grep -qi ^y
   1.119 +then
   1.120 +    dd if=/dev/zero of=${IOS_FS_NAME} bs=1k count=${CONFIG_FS_SIZE}
   1.121 +    mkfs.ext3 -F ${IOS_FS_NAME}
   1.122 +    mount -o loop ${IOS_FS_NAME} ${WORK_DIR}
   1.123 +    cp ${IOS_DIR}/* ${WORK_DIR}
   1.124 +    umount ${WORK_DIR}
   1.125 +fi
   1.126 +