2004-03-28 08:20:21 +08:00
|
|
|
#!/bin/sh
|
2004-05-04 17:42:46 +08:00
|
|
|
# $Id$
|
2004-03-28 08:20:21 +08:00
|
|
|
|
|
|
|
|
2004-07-21 11:13:56 +08:00
|
|
|
[ -f "/tmp/.firstboot" ] && {
|
|
|
|
echo "firstboot is already running"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
touch /tmp/.firstboot
|
|
|
|
|
|
|
|
jdev=$(mount | awk '/jffs2/ {print $3}')
|
|
|
|
|
|
|
|
if [ -z "$jdev" ]; then
|
2004-07-21 11:52:45 +08:00
|
|
|
echo -n "Creating jffs2 partition... "
|
2004-07-27 15:27:13 +08:00
|
|
|
mtd erase OpenWrt >&-
|
2004-05-04 17:42:46 +08:00
|
|
|
mount -t jffs2 /dev/mtdblock/4 /jffs
|
2004-07-21 11:52:45 +08:00
|
|
|
echo "done"
|
2004-05-04 17:42:46 +08:00
|
|
|
cd /jffs
|
|
|
|
else
|
2004-03-28 09:22:15 +08:00
|
|
|
echo "firstboot has already been run"
|
2004-07-21 11:52:45 +08:00
|
|
|
echo "jffs2 partition is mounted, only resetting files"
|
2004-07-21 11:13:56 +08:00
|
|
|
cd $jdev
|
2004-05-04 17:42:46 +08:00
|
|
|
fi
|
2004-03-28 09:22:15 +08:00
|
|
|
|
2004-07-27 15:27:13 +08:00
|
|
|
exec 2>/dev/null
|
|
|
|
|
2004-07-21 11:13:56 +08:00
|
|
|
mount /dev/mtdblock/2 /rom -o ro
|
|
|
|
|
2004-07-21 11:52:45 +08:00
|
|
|
echo -n "creating directories... "
|
2004-03-28 08:20:21 +08:00
|
|
|
{
|
|
|
|
cd /rom
|
|
|
|
find . -type d
|
2004-05-04 17:42:46 +08:00
|
|
|
cd -
|
2004-03-28 08:20:21 +08:00
|
|
|
} | xargs mkdir
|
2004-07-21 11:52:45 +08:00
|
|
|
echo "done"
|
2004-03-28 08:20:21 +08:00
|
|
|
|
2004-07-21 11:52:45 +08:00
|
|
|
echo -n "setting up symlinks... "
|
2004-03-28 08:20:21 +08:00
|
|
|
for file in $(cd /rom; find * -type f; find * -type l;)
|
|
|
|
do {
|
|
|
|
ln -sf /rom/$file $file
|
|
|
|
} done
|
2004-07-21 11:52:45 +08:00
|
|
|
echo "done"
|
2004-03-28 08:20:21 +08:00
|
|
|
|
|
|
|
touch /tmp/resolv.conf
|
|
|
|
ln -s /tmp/resolv.conf /etc/resolv.conf
|
|
|
|
|
|
|
|
umount /rom
|
|
|
|
mount none /jffs/proc -t proc
|
|
|
|
pivot_root /jffs /jffs/rom
|
|
|
|
mount none /dev -t devfs
|
|
|
|
mount none /tmp -t ramfs
|
|
|
|
umount /rom/proc
|
|
|
|
umount /rom/tmp
|
|
|
|
umount /rom/dev
|