#!/bin/sh
echo "********************************"
echo " Exec rcS "
echo "********************************"
runlevel=S
export runlevel
# Host name
/bin/hostname FBox_Lite
# Mount /proc if not
[ -d "/proc/1" ] || mount /proc
# Mount /tmp -> tmpfs
mount tmpfs /tmp -t tmpfs -o size=16m
# mount /dev/pts -> devpts for telnetd
mkdir /dev/pts
mount -t devpts devpts /dev/pts
# Start local services
/etc/init.d/rc.local
# Install 8188eu.ko for wlan0
# insmod /home/wifi/8188eu.ko 暂时不加
#mkdir /home/FBox_Bak
dirPath="/home/FBox_Bak/"
if [ ! -d "$dirPath" ]; then
echo "$dirPath"" is not exist, create it."
mkdir "$dirPath"
else
echo "$dirPath"" has exist."
fi
#mkdir /home/fbox_tmp
dirPath="/home/fbox_tmp/"
if [ ! -d "$dirPath" ]; then
echo "$dirPath"" is not exist, create it."
mkdir "$dirPath"
else
echo "$dirPath"" has exist."
fi
#mkdir /home/fbox_tmp/bin
dirPath="/home/fbox_tmp/bin/"
if [ ! -d "$dirPath" ]; then
echo "$dirPath"" is not exist, create it."
mkdir "$dirPath"
else
echo "$dirPath"" has exist."
fi
#mkdir /var/run
dirPath="/var/run/"
if [ ! -d "$dirPath" ]; then
echo "$dirPath"" is not exist, create it."
mkdir "$dirPath"
else
echo "$dirPath"" has exist."
fi
#mkdir /tmp/Log
dirPath="/tmp/Log/"
if [ ! -d "$dirPath" ]; then
echo "$dirPath"" is not exist, create it."
mkdir "$dirPath"
else
echo "$dirPath"" has exist."
fi
#touch /tmp/Log/gprs.log
dirPath="/tmp/Log/gprs.log"
if [ ! -f "$dirPath" ]; then
echo "$dirPath"" is not exist, create it."
touch "$dirPath"
else
echo "$dirPath"" has exist."
fi
# 拷贝fls文件
dirPath="/home/FBox_Run/fls"
if [ ! -f "$dirPath" ]; then
echo "$dirPath"" is not exist."
echo "cp -f /home/FBoxLite_Bak/fls /home/FBox_Run/fls"
cp -f /home/FBoxLite_Bak/fls /home/FBox_Run/fls
echo "chmod 777 /home/FBox_Run/fls"
chmod 777 /home/FBox_Run/fls
else
echo "$dirPath"" has exist."
if [ ! -x "$dirPath" ]; then
echo "$dirPath"" has no x authority."
echo "chmod 777 /home/FBox_Run/fls"
chmod 777 /home/FBox_Run/fls
fi
fi
# 拷贝fcs文件
dirPath="/home/FBox_Run/fcs"
if [ ! -f "$dirPath" ]; then
echo "$dirPath"" is not exist."
echo "cp -f /home/FBoxLite_Bak/fcs /home/FBox_Run/fcs"
cp -f /home/FBoxLite_Bak/fcs /home/FBox_Run/fcs
echo "chmod 777 /home/FBox_Run/fcs"
chmod 777 /home/FBox_Run/fcs
else
echo "$dirPath"" has exist."
if [ ! -x "$dirPath" ]; then
echo "$dirPath"" has no x authority."
echo "chmod 777 /home/FBox_Run/fcs"
chmod 777 /home/FBox_Run/fcs
fi
fi
# 拷贝fds文件
dirPath="/home/FBox_Run/fds"
if [ ! -f "$dirPath" ]; then
echo "$dirPath"" is not exist."
echo "cp -f /home/FBoxLite_Bak/fds /home/FBox_Run/fds"
cp -f /home/FBoxLite_Bak/fcs /home/FBox_Run/fcs
echo "chmod 777 /home/FBox_Run/fds"
chmod 777 /home/FBox_Run/fds
else
echo "$dirPath"" has exist."
if [ ! -x "$dirPath" ]; then
echo "$dirPath"" has no x authority."
echo "chmod 777 /home/FBox_Run/fds"
chmod 777 /home/FBox_Run/fds
fi
fi
# 拷贝串口0的驱动
dirPath="/home/FBoxLite_Bak/drv_0.so"
drvFile_0="/home/Bin/Device/Serial/drv_0.so"
drvFile_1="/home/Bin/Device/Service/Serial/drv_0.so"
if [ ! -f "$dirPath" ]; then
# 备份驱动文件不存在 不需要拷贝
echo "$dirPath"" is not exist. don't copy drv_so."
else
# 备份驱动文件存在,查看一下驱动文件是否存在 不存在则需要拷贝
if [ ! -f "$drvFile_0" ]; then
echo "$drvFile_0"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_0"
cp -f "$dirPath" "$drvFile_0"
else
echo "$drvFile_0"" has exist."
fi
if [ ! -f "$drvFile_1" ]; then
echo "$drvFile_1"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_1"
cp -f "$dirPath" "$drvFile_1"
else
echo "$drvFile_1"" has exist."
fi
fi
# 拷贝串口1的驱动
dirPath="/home/FBoxLite_Bak/drv_1.so"
drvFile_0="/home/Bin/Device/Serial/drv_1.so"
drvFile_1="/home/Bin/Device/Service/Serial/drv_1.so"
if [ ! -f "$dirPath" ]; then
# 备份驱动文件不存在 不需要拷贝
echo "$dirPath"" is not exist. don't copy drv_so."
else
# 备份驱动文件存在,查看一下驱动文件是否存在 不存在则需要拷贝
if [ ! -f "$drvFile_0" ]; then
echo "$drvFile_0"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_0"
cp -f "$dirPath" "$drvFile_0"
else
echo "$drvFile_0"" has exist."
fi
if [ ! -f "$drvFile_1" ]; then
echo "$drvFile_1"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_1"
cp -f "$dirPath" "$drvFile_1"
else
echo "$drvFile_1"" has exist."
fi
fi
# 拷贝串口2的驱动
dirPath="/home/FBoxLite_Bak/drv_2.so"
drvFile_0="/home/Bin/Device/Serial/drv_2.so"
drvFile_1="/home/Bin/Device/Service/Serial/drv_2.so"
if [ ! -f "$dirPath" ]; then
# 备份驱动文件不存在 不需要拷贝
echo "$dirPath"" is not exist. don't copy drv_so."
else
# 备份驱动文件存在,查看一下驱动文件是否存在 不存在则需要拷贝
if [ ! -f "$drvFile_0" ]; then
echo "$drvFile_0"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_0"
cp -f "$dirPath" "$drvFile_0"
else
echo "$drvFile_0"" has exist."
fi
if [ ! -f "$drvFile_1" ]; then
echo "$drvFile_1"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_1"
cp -f "$dirPath" "$drvFile_1"
else
echo "$drvFile_1"" has exist."
fi
fi
# 拷贝网口的驱动
cd /home/FBoxLite_Bak/
for file in $(ls drv_4*)
do
echo "file : $file"
dirPath="/home/FBoxLite_Bak/""$file"
drvFile_0="/home/Bin/Device/Ethernet/""$file"
drvFile_1="/home/Bin/Device/Service/Ethernet/""$file"
if [ ! -f "$dirPath" ]; then
# 备份驱动文件不存在 不需要拷贝
echo "$dirPath"" is not exist. don't copy drv_so."
else
# 备份驱动文件存在,查看一下驱动文件是否存在 不存在则需要拷贝
if [ ! -f "$drvFile_0" ]; then
echo "$drvFile_0"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_0"
cp -f "$dirPath" "$drvFile_0"
else
echo "$drvFile_0"" has exist."
fi
if [ ! -f "$drvFile_1" ]; then
echo "$drvFile_1"" is not exist."
echo "cp -f ""$dirPath"" ""$drvFile_1"
cp -f "$dirPath" "$drvFile_1"
else
echo "$drvFile_1"" has exist."
fi
fi
done
cd /home/FBox_Run/
/home/FBox_Run/fls &
echo "********************************"
echo " www.flexem.com "
echo " FBox-Lite "
echo "********************************"