2004-03-28 02:20:21 +02:00
|
|
|
#!/bin/sh
|
2004-05-04 12:42:46 +03:00
|
|
|
# $Id$
|
2004-03-28 02:20:21 +02:00
|
|
|
|
|
|
|
|
2004-07-21 06:13:56 +03: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 06:52:45 +03:00
|
|
|
echo -n "Creating jffs2 partition... "
|
2004-07-27 10:27:13 +03:00
|
|
|
mtd erase OpenWrt >&-
|
2004-05-04 12:42:46 +03:00
|
|
|
mount -t jffs2 /dev/mtdblock/4 /jffs
|
2004-07-21 06:52:45 +03:00
|
|
|
echo "done"
|
2004-05-04 12:42:46 +03:00
|
|
|
cd /jffs
|
|
|
|
else
|
2004-03-28 04:22:15 +03:00
|
|
|
echo "firstboot has already been run"
|
2004-07-21 06:52:45 +03:00
|
|
|
echo "jffs2 partition is mounted, only resetting files"
|
2004-07-21 06:13:56 +03:00
|
|
|
cd $jdev
|
2004-05-04 12:42:46 +03:00
|
|
|
fi
|
2004-03-28 04:22:15 +03:00
|
|
|
|
2004-07-27 10:27:13 +03:00
|
|
|
exec 2>/dev/null
|
|
|
|
|
2004-07-21 06:13:56 +03:00
|
|
|
mount /dev/mtdblock/2 /rom -o ro
|
|
|
|
|
2004-07-21 06:52:45 +03:00
|
|
|
echo -n "creating directories... "
|
2004-03-28 02:20:21 +02:00
|
|
|
{
|
|
|
|
cd /rom
|
|
|
|
find . -type d
|
2004-05-04 12:42:46 +03:00
|
|
|
cd -
|
2004-03-28 02:20:21 +02:00
|
|
|
} | xargs mkdir
|
2004-07-21 06:52:45 +03:00
|
|
|
echo "done"
|
2004-03-28 02:20:21 +02:00
|
|
|
|
2004-07-21 06:52:45 +03:00
|
|
|
echo -n "setting up symlinks... "
|
2004-03-28 02:20:21 +02:00
|
|
|
for file in $(cd /rom; find * -type f; find * -type l;)
|
|
|
|
do {
|
|
|
|
ln -sf /rom/$file $file
|
|
|
|
} done
|
2004-07-21 06:52:45 +03:00
|
|
|
echo "done"
|
2004-03-28 02:20:21 +02: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
|