Advertisement
Guest User

Untitled

a guest
May 17th, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3.  
  4. # crucial mountpoints
  5. mount -t proc none /proc
  6. mount -t sysfs none /sys
  7.  
  8. ROOT_ON_SQUASHFS=`grep '/dev/root' /proc/mounts | grep -c squashfs`
  9. if [ ${ROOT_ON_SQUASHFS} -ne 0 ]; then
  10. mount -n tmpfs /var -t tmpfs
  11.  
  12. tar cf /tmp/devtmp.tar /dev
  13. mount dev /dev -t tmpfs
  14. tar xf /tmp/devtmp.tar && rm -f /tmp/devtmp.tar
  15.  
  16. mknod /dev/console c 5 1
  17. mknod /dev/ttyS0 c 4 64
  18.  
  19. mknod /dev/null c 1 3
  20. mknod /dev/gpio_reset c 10 129
  21.  
  22. mknod /dev/zero c 1 5
  23. mknod /dev/tty c 5 0
  24. mknod /dev/tty0 c 4 0
  25. mknod /dev/tty1 c 4 1
  26. mknod /dev/random c 1 8
  27. mknod /dev/urandom c 1 9
  28. mknod /dev/ptmx c 5 2
  29. mknod /dev/mem c 1 1
  30.  
  31. mknod /dev/watchdog c 10 130
  32.  
  33. mknod /dev/mtdblock0 b 31 0
  34. mknod /dev/mtdblock1 b 31 1
  35. mknod /dev/mtdblock2 b 31 2
  36. mknod /dev/mtdblock3 b 31 3
  37. mknod /dev/mtdblock4 b 31 4
  38. mknod /dev/mtdblock5 b 31 5
  39. mknod /dev/mtdblock6 b 31 6
  40. mknod /dev/mtdblock7 b 31 7
  41.  
  42. mknod /dev/mtd0 c 90 0
  43. mknod /dev/mtd1 c 90 2
  44. mknod /dev/mtd2 c 90 4
  45. mknod /dev/mtd3 c 90 6
  46. mknod /dev/mtd4 c 90 8
  47. mknod /dev/mtd5 c 90 10
  48. mknod /dev/mtd6 c 90 12
  49. mknod /dev/mtd7 c 90 14
  50.  
  51. mknod /dev/ppp c 108 0
  52.  
  53. mkdir /dev/pts /dev/shm
  54. # mount -n tmpfs /var -t tmpfs -o size=${FLASH_SIZE}
  55. fi
  56.  
  57. # rest of the mounts
  58. mount none /dev/pts -t devpts
  59.  
  60. # setup console, consider using ptmx?
  61. CIN=/dev/console
  62. COUT=/dev/console
  63.  
  64. exec <$CIN &>$COUT
  65.  
  66. mkdir -p /var/run /var/tmp /var/log /var/etc /var/etc/persistent/cfg /var/lock
  67.  
  68. # insert hal module
  69. [ ! -f /lib/modules/*/ubnthal.ko ] || insmod /lib/modules/*/ubnthal.ko
  70.  
  71. # insert the gpiodev and set the LED
  72. if [ -f /lib/modules/*/gpiodev.ko ] ; then
  73. insmod /lib/modules/*/gpiodev.ko
  74. echo -n 20 > /proc/gpio/led_pattern # boot up blinking
  75. fi
  76.  
  77. # making sure that critical files are in place, make others as symbolic link
  78. # we need to get /etc/inittab created here
  79. # because we cannot do 'init -q' during rc / init
  80. cp -f /usr/etc/inittab /etc/inittab
  81.  
  82. mkdir -p /etc/udhcpc
  83. # do not update if exist
  84. for f in passwd group login.defs profile hosts host.conf \
  85. fstab udhcpc/udhcpc udhcpc/udhcpc_ip_only startup.list udhcpc_services; do
  86. if [ ! -e /etc/$f ]; then
  87. cp -f /usr/etc/$f /etc/$f
  88. fi
  89. done
  90.  
  91. mkdir -p /etc/sysinit/
  92. # make symlinks if do not exist
  93. for f in services protocols shells mime.types ethertypes modules.d rc.d init.d; do
  94. [ ! -e /etc/$f ] || rm -Rf /etc/$f
  95. ln -s /usr/etc/$f /etc/$f
  96. done
  97.  
  98. CFG_SYSTEM="/tmp/system.cfg"
  99. CFG_RUNNING="/tmp/running.cfg"
  100. CFG_DEFAULT="/usr/etc/system.cfg"
  101.  
  102. # detection + default config
  103. if [ -e /sbin/ubntconf ]; then
  104. /sbin/ubntconf -i $CFG_DEFAULT
  105. fi
  106.  
  107. # System configuration
  108. /sbin/cfgmtd -r -p /etc/ -f $CFG_RUNNING
  109. if [ $? -ne 0 ]; then
  110. /sbin/cfgmtd -r -p /etc/ -t 2 -f $CFG_RUNNING
  111. if [ $? -ne 0 ]; then
  112. cp $CFG_DEFAULT $CFG_RUNNING
  113. fi
  114. fi
  115. sort $CFG_RUNNING > $CFG_SYSTEM
  116. rm $CFG_RUNNING
  117. mkdir -p /var/etc/persistent/cfg
  118.  
  119. # Kernel tuning
  120. # start the page cache/kmem cache cleanup timer in the kernel
  121. echo 1 > /proc/sys/vm/drop_caches
  122. # when processes uses page-cache more than 30% of system memory,
  123. # lets force them to write
  124. echo 20 > /proc/sys/vm/dirty_ratio
  125. # when the dirty pages cross more than 5% of sys memory,
  126. # kick in the pdflush
  127. echo 5 > /proc/sys/vm/dirty_background_ratio
  128.  
  129. # Run configuration parser
  130. if [ -e /sbin/ubntconf ]; then
  131. /sbin/ubntconf
  132. fi
  133. # what this implies is that ubntconf cannot rely on too
  134. # many filesystem assumptions
  135.  
  136. echo "...running /sbin/init"
  137. exec /sbin/init
  138.  
  139. echo "INTERNAL ERROR!!! Cannot run /sbin/init."
  140. - init [Readonly] 139/139 100%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement