#!/bin/sh CURET_DIR=$(pwd) src_path="$CURET_DIR/rootfs-src-tmp" dst_path="$CURET_DIR/rootfs-dst-tmp" help() { echo "" echo "eg: auto-build-rootfs src.ext2 dst.ext2" } #check src rootfs.ext2 if [ ! -f $CURET_DIR/$1 ]; then echo "no file $CURET_DIR/$1" help exit fi #check dst rootfs.ext2 if [ ! -f $CURET_DIR/$2 ]; then echo "no file $CURET_DIR/$2" help exit fi #check src mount path if [ ! -d $src_path ]; then echo "no dir: $src_path, we will create it!" mkdir -p $src_path else echo "exist dir: $src_path, pl check it, exit" exit fi #check dst mount path if [ ! -d $dst_path ]; then echo "no dir: $dst_path, we will create it!" mkdir -p $dst_path else echo "exist dir: $dst_path, pl check it, exit" exit fi # mount echo "" echo "mount $1 to $src_path ..." mount $1 $src_path echo "mount $2 to $dst_path ..." mount $2 $dst_path #modify file cp $src_path/etc/default/lxc $dst_path/etc/default/lxc cp $src_path/etc/fstab $dst_path/etc/fstab cp $src_path/etc/init.d/rcS $dst_path/etc/init.d/rcS cp $src_path/etc/profile $dst_path/etc/profile #cp file cp $src_path/usr/lib/liblxc.so $dst_path/usr/lib/liblxc.so cp $src_path/usr/lib/liblxc.so.1 $dst_path/usr/lib/liblxc.so.1 cp $src_path/usr/lib/liblxc.so.1.6.0 $dst_path/usr/lib/liblxc.so.1.6.0 cp $src_path/usr/lib32/liblxc.so $dst_path/usr/lib32/liblxc.so cp $src_path/usr/lib32/liblxc.so.1 $dst_path/usr/lib32/liblxc.so.1 cp $src_path/usr/lib32/liblxc.so.1.6.0 $dst_path/usr/lib32/liblxc.so.1.6.0 cp $src_path/usr/libexec/lxc/lxc-net $dst_path/usr/libexec/lxc/lxc-net #cp $src_path/usr/share/lxc/templates/lxc-busybox $dst_path/usr/usr/share/lxc/templates/lxc-busybox cp $src_path/etc/default/lxc-net $dst_path/etc/default/lxc-net cp $src_path/etc/resolv.conf $dst_path/etc/ #cp dir cp -rf $src_path/usr/local $dst_path/usr/local cp -rf $src_path/var/lib/lxc/lxc-busybox $dst_path/var/lib/lxc/lxc-busybox #umount umount $src_path umount $dst_path rm -r $src_path rm -r $dst_path