#!/bin/bash
#yuanxin.yang develop 2015-07-05
#文件系统和Busybox的路径====>可自己定制
FILESYSTEM=/Softwave/filesystem #定义自己制作的文件系统存放的位置
BUSYBOX=/Softwave/arm/busybox-1.17.2 #Busybox软体的位置
LIBS=/usr/local/arm/4.5.1/arm-none-linux-gnueabi #交叉编译相关的库文件的位置
#判断文件是否存在 如果存在 就删除
if [ -d $FILESYSTEM ]
then
rm -rf $FILESYSTEM &>/dev/null
mkdir $FILESYSTEM &>/dev/null
else
mkdir $FILESYSTEM &>/dev/null
fi
#拷贝busybox相关的文件
if ! cp -rf $BUSYBOX/_install/* $FILESYSTEM &>/dev/null
then
echo "cp busybox failed..."
exit 1
fi
#拷贝库
if ! cp -rf $LIBS/lib/ $FILESYSTEM/ &>/dev/null
then
echo "copy libs fair...."
exit 1
fi
#拷贝etc
if ! cp -rf $BUSYBOX/examples/bootfloppy/etc $FILESYSTEM &>/dev/null
then
echo "copy etc fair..."
exit 1
fi
#创建Linux相关目录
cd $FILESYSTEM &>/dev/null
mkdir boot mnt root sys var net proc tmp dev home opt &>/dev/null
#修改配置文件
echo > $FILESYSTEM/etc/fstab
#修改etc/profile文件
echo "# /etc/profile: system-wide .profile file for the Bourne shells" > $FILESYSTEM/etc/profile
echo "echo \"===========================\"" >> $FILESYSTEM/etc/profile
echo "echo \"Welcom to Linux System\"" >> $FILESYSTEM/etc/profile
echo "echo \"===========================\"" >> $FILESYSTEM/etc/profile
echo "export PS1=\"[jiaobenzhijia@Linux \W] # \"" >> $FILESYSTEM/etc/profile
#修改 etc/init.d/rcS
echo "#! /bin/sh" > $FILESYSTEM/etc/init.d/rcS
echo "/bin/mount -n -t proc none /proc" >> $FILESYSTEM/etc/init.d/rcS
echo "/bin/mount -n -t sysfs none /sys " >> $FILESYSTEM/etc/init.d/rcS
echo "/bin/mount -t ramfs none /dev " >> $FILESYSTEM/etc/init.d/rcS
echo "/bin/mount -n -t ramfs none /tmp " >> $FILESYSTEM/etc/init.d/rcS
echo "/sbin/mdev -s" >> $FILESYSTEM/etc/init.d/rcS
#配置nfs服务
if ! grep "$FILESYSTEM" /etc/exports &>/dev/null
then
echo "/filesystem *(rw,sync,no_root_squash)" >> /etc/exports
fi
#启动服务
iptables -F &>/dev/null
service rpcbind restart
service nfs restart
echo "make filesystem ok....."
exit 0