Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # crucial mountpoints
- mount -t proc none /proc
- mount -t sysfs none /sys
- ROOT_ON_SQUASHFS=`grep '/dev/root' /proc/mounts | grep -c squashfs`
- if [ ${ROOT_ON_SQUASHFS} -ne 0 ]; then
- mount -n tmpfs /var -t tmpfs
- tar cf /tmp/devtmp.tar /dev
- mount dev /dev -t tmpfs
- tar xf /tmp/devtmp.tar && rm -f /tmp/devtmp.tar
- mknod /dev/console c 5 1
- mknod /dev/ttyS0 c 4 64
- mknod /dev/null c 1 3
- mknod /dev/gpio_reset c 10 129
- mknod /dev/zero c 1 5
- mknod /dev/tty c 5 0
- mknod /dev/tty0 c 4 0
- mknod /dev/tty1 c 4 1
- mknod /dev/random c 1 8
- mknod /dev/urandom c 1 9
- mknod /dev/ptmx c 5 2
- mknod /dev/mem c 1 1
- mknod /dev/watchdog c 10 130
- mknod /dev/mtdblock0 b 31 0
- mknod /dev/mtdblock1 b 31 1
- mknod /dev/mtdblock2 b 31 2
- mknod /dev/mtdblock3 b 31 3
- mknod /dev/mtdblock4 b 31 4
- mknod /dev/mtdblock5 b 31 5
- mknod /dev/mtdblock6 b 31 6
- mknod /dev/mtdblock7 b 31 7
- mknod /dev/mtd0 c 90 0
- mknod /dev/mtd1 c 90 2
- mknod /dev/mtd2 c 90 4
- mknod /dev/mtd3 c 90 6
- mknod /dev/mtd4 c 90 8
- mknod /dev/mtd5 c 90 10
- mknod /dev/mtd6 c 90 12
- mknod /dev/mtd7 c 90 14
- mknod /dev/ppp c 108 0
- mkdir /dev/pts /dev/shm
- # mount -n tmpfs /var -t tmpfs -o size=${FLASH_SIZE}
- fi
- # rest of the mounts
- mount none /dev/pts -t devpts
- # setup console, consider using ptmx?
- CIN=/dev/console
- COUT=/dev/console
- exec <$CIN &>$COUT
- mkdir -p /var/run /var/tmp /var/log /var/etc /var/etc/persistent/cfg /var/lock
- # insert hal module
- [ ! -f /lib/modules/*/ubnthal.ko ] || insmod /lib/modules/*/ubnthal.ko
- # insert the gpiodev and set the LED
- if [ -f /lib/modules/*/gpiodev.ko ] ; then
- insmod /lib/modules/*/gpiodev.ko
- echo -n 20 > /proc/gpio/led_pattern # boot up blinking
- fi
- # making sure that critical files are in place, make others as symbolic link
- # we need to get /etc/inittab created here
- # because we cannot do 'init -q' during rc / init
- cp -f /usr/etc/inittab /etc/inittab
- mkdir -p /etc/udhcpc
- # do not update if exist
- for f in passwd group login.defs profile hosts host.conf \
- fstab udhcpc/udhcpc udhcpc/udhcpc_ip_only startup.list udhcpc_services; do
- if [ ! -e /etc/$f ]; then
- cp -f /usr/etc/$f /etc/$f
- fi
- done
- mkdir -p /etc/sysinit/
- # make symlinks if do not exist
- for f in services protocols shells mime.types ethertypes modules.d rc.d init.d; do
- [ ! -e /etc/$f ] || rm -Rf /etc/$f
- ln -s /usr/etc/$f /etc/$f
- done
- CFG_SYSTEM="/tmp/system.cfg"
- CFG_RUNNING="/tmp/running.cfg"
- CFG_DEFAULT="/usr/etc/system.cfg"
- # detection + default config
- if [ -e /sbin/ubntconf ]; then
- /sbin/ubntconf -i $CFG_DEFAULT
- fi
- # System configuration
- /sbin/cfgmtd -r -p /etc/ -f $CFG_RUNNING
- if [ $? -ne 0 ]; then
- /sbin/cfgmtd -r -p /etc/ -t 2 -f $CFG_RUNNING
- if [ $? -ne 0 ]; then
- cp $CFG_DEFAULT $CFG_RUNNING
- fi
- fi
- sort $CFG_RUNNING > $CFG_SYSTEM
- rm $CFG_RUNNING
- mkdir -p /var/etc/persistent/cfg
- # Kernel tuning
- # start the page cache/kmem cache cleanup timer in the kernel
- echo 1 > /proc/sys/vm/drop_caches
- # when processes uses page-cache more than 30% of system memory,
- # lets force them to write
- echo 20 > /proc/sys/vm/dirty_ratio
- # when the dirty pages cross more than 5% of sys memory,
- # kick in the pdflush
- echo 5 > /proc/sys/vm/dirty_background_ratio
- # Run configuration parser
- if [ -e /sbin/ubntconf ]; then
- /sbin/ubntconf
- fi
- # what this implies is that ubntconf cannot rely on too
- # many filesystem assumptions
- echo "...running /sbin/init"
- exec /sbin/init
- echo "INTERNAL ERROR!!! Cannot run /sbin/init."
- - init [Readonly] 139/139 100%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement