Advertisement
Guest User

Untitled

a guest
Jan 25th, 2022
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 17.04 KB | None
  1. /lib/preinit # ls
  2. 02_default_set_state         40_run_failsafe_hook
  3. 03_preinit_do_ipq806x.sh     41_merge_overlay_hooks
  4. 05_mount_skip                50_choose_console
  5. 10_check_for_mtd             50_indicate_regular_preinit
  6. 10_essential_fs              60_init_hotplug
  7. 10_indicate_failsafe         70_initramfs_test
  8. 10_indicate_preinit          70_pivot_ext4_root
  9. 20_check_jffs2_ready         70_pivot_jffs2_root
  10. 20_device_fs_mount           70_pivot_ubifs_root
  11. 30_device_fs_daemons         80_mount_root
  12. 30_failsafe_wait             90_init_console
  13. 40_init_shm                  90_mount_no_jffs2
  14. 40_mount_devpts              90_restore_config
  15. 40_mount_ext4                99_10_failsafe_login
  16. 40_mount_jffs2               99_10_mount_no_mtd
  17. 40_mount_ubifs               99_10_run_init
  18.  
  19. /lib/preinit # head -n 999999 ./*
  20. ==> ./02_default_set_state <==
  21. #!/bin/sh
  22.  
  23. define_default_set_state() {
  24.     . /etc/diag.sh
  25. }
  26.  
  27. boot_hook_add preinit_main define_default_set_state
  28.  
  29. ==> ./03_preinit_do_ipq806x.sh <==
  30. #!/bin/sh
  31. #
  32. # Copyright (c) 2013 The Linux Foundation. All rights reserved.
  33. #
  34.  
  35. do_ipq806x() {
  36.     . /lib/ipq806x.sh
  37.  
  38.     ipq806x_board_detect
  39. }
  40.  
  41. boot_hook_add preinit_main do_ipq806x
  42.  
  43. ==> ./05_mount_skip <==
  44. #!/bin/sh
  45.  
  46. # Copyright (C) 2006 OpenWrt.org
  47. # Copyright (C) 2010 Vertical Communications
  48.  
  49. check_skip() {
  50.     if [ "$pi_mount_skip_next" = "true" ]; then
  51.     return 0
  52.     else
  53.     return 1
  54.     fi
  55. }
  56.  
  57.  
  58. ==> ./10_check_for_mtd <==
  59. #!/bin/sh
  60.  
  61. # Copyright (C) 2006-2010 OpenWrt.org
  62. # Copyright (C) 2010 Vertical Communications
  63.  
  64. mount_no_rootfs_data() {
  65.     mtd unlock rootfs
  66.     mount -o remount,rw /dev/root /
  67. }
  68.  
  69. check_for_rootfs_data() {
  70.     check_skip || {
  71.     grep -qs rootfs_data /proc/mtd || grep -qs ubi_rootfs_data /sys/class/ubi/ubi0/ubi0_1/name || grep -qs rootfs_data /sys/block/mmcblk0/mmcblk0p*/uevent || {
  72.         mount_no_rootfs_data && pi_mount_skip_next=true
  73.     }
  74.     }
  75. }
  76.  
  77. boot_hook_add preinit_mount_root check_for_rootfs_data
  78.  
  79.  
  80. ==> ./10_essential_fs <==
  81. #!/bin/sh
  82. # Copyright (C) 2006 OpenWrt.org
  83. # Copyright (C) 2010 Vertical Communications
  84.  
  85. do_mount_procfs() {
  86.    mount proc /proc -t proc
  87. }
  88.  
  89. do_mount_sysfs() {
  90.     mount sysfs /sys -t sysfs
  91. }
  92.  
  93. calc_tmpfs_size() {
  94.     pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)&&(mt>l)?mt-l:s}' /proc/meminfo)
  95. }
  96.  
  97. do_mount_tmpfs() {
  98.     calc_tmpfs_size
  99.     mount tmpfs /tmp -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777
  100. }
  101.  
  102. boot_hook_add preinit_essential do_mount_procfs
  103. boot_hook_add preinit_essential do_mount_sysfs
  104. boot_hook_add preinit_essential do_mount_tmpfs
  105.  
  106.  
  107. ==> ./10_indicate_failsafe <==
  108. #!/bin/sh
  109. # Copyright (C) 2006 OpenWrt.org
  110. # Copyright (C) 2010 Vertical Communications
  111.  
  112. # commands for emitting messages to network in failsafe mode
  113.  
  114. indicate_failsafe_led () {
  115.     set_state failsafe
  116. }
  117.  
  118. indicate_failsafe() {
  119.     echo "- failsafe -"
  120.     preinit_net_echo "Entering Failsafe!\n"
  121.     indicate_failsafe_led
  122. }
  123.  
  124. boot_hook_add failsafe indicate_failsafe
  125.  
  126.  
  127. ==> ./10_indicate_preinit <==
  128. #!/bin/sh
  129. # Copyright (C) 2006 OpenWrt.org
  130. # Copyright (C) 2010 Vertical Communications
  131.  
  132. preinit_ip() {
  133.     # if the preinit interface isn't specified and ifname is set in
  134.     # preinit.arch use that interface
  135.     if [ -z "$pi_ifname" ]; then
  136.     pi_ifname=$ifname    
  137.     fi
  138.  
  139.     [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
  140.     ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
  141.     }
  142. }
  143.  
  144. preinit_ip_deconfig() {
  145.     [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
  146.     ifconfig $pi_ifname 0.0.0.0 down
  147.     }
  148. }
  149.  
  150. preinit_net_echo() {
  151.     [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
  152.         {
  153.             [ "$pi_preinit_net_messages" = "y" ] || {
  154.                         [ "$pi_failsafe_net_message"  = "true" ] &&
  155.                             [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
  156.                      }
  157.                    
  158.         } && netmsg $pi_broadcast "$1"
  159.         }
  160. }
  161.  
  162. preinit_echo() {
  163.     preinit_net_echo $1
  164.     echo $1
  165. }
  166.  
  167. pi_indicate_led() {
  168.     set_state preinit
  169. }
  170.  
  171. pi_indicate_preinit() {
  172.     echo "- preinit -"
  173.     preinit_net_echo "Doing OpenWRT Preinit\n"
  174.     pi_indicate_led
  175. }
  176.  
  177. boot_hook_add preinit_main preinit_ip
  178. boot_hook_add preinit_main pi_indicate_preinit
  179.  
  180.  
  181. ==> ./20_check_jffs2_ready <==
  182. #!/bin/sh
  183. # Copyright (C) 2006-2010 OpenWrt.org
  184. # Copyright (C) 2010 Vertical Communications
  185.  
  186. mount_no_jffs2() {
  187.     echo "jffs2 not ready yet; using ramdisk"
  188.     ramoverlay
  189. }
  190.  
  191. check_for_jffs2() {
  192.     # skip jffs2 mounting even if it's there if we have volume named
  193.     # ubi_rootfs_data
  194.     check_skip && return
  195.  
  196.     jffs2_ready || {
  197.         grep -wqs rootfs_data /proc/mtd && {
  198.             mount_no_jffs2 && pi_mount_skip_next=true
  199.         }
  200.     }
  201. }
  202.  
  203. boot_hook_add preinit_mount_root check_for_jffs2
  204.  
  205.  
  206. ==> ./20_device_fs_mount <==
  207. #!/bin/sh
  208. # Copyright (C) 2006 OpenWrt.org
  209. # Copyright (C) 2010 Vertical Communications
  210.  
  211. do_move_devtmpfs() {
  212.     local mnt="$(grep devtmpfs /proc/mounts)"
  213.           mnt="${mnt#* }"; mnt="${mnt%% *}"
  214.  
  215.     [ "$mnt" = "/dev" ] || mount -o move "$mnt" /dev
  216. }
  217.  
  218. do_mount_devfs() {
  219.     mount devfs /dev -t devfs
  220. }
  221.  
  222. do_mount_hotplug() {
  223.     mount -t tmpfs tmpfs /dev -o mode=0755,size=512K
  224. }
  225.  
  226. do_mount_udev() {
  227.     mount -n -t tmpfs -o mode=0755 udev /dev
  228. }
  229.  
  230. choose_device_fs() {
  231.     if grep -q devtmpfs /proc/mounts; then
  232.         do_move_devtmpfs
  233.     elif grep -q devfs /proc/filesystems; then
  234.         do_mount_devfs
  235.     elif [ -x /sbin/hotplug2 ]; then
  236.         do_mount_hotplug
  237.     elif [ -x /sbin/udevd ]; then
  238.         do_mount_udev
  239.     fi
  240. }
  241.  
  242. boot_hook_add preinit_essential choose_device_fs
  243.  
  244.  
  245. ==> ./30_device_fs_daemons <==
  246. #!/bin/sh
  247. # Copyright (C) 2006 OpenWrt.org
  248. # Copyright (C) 2010 Vertical Communications
  249.  
  250. init_devfs() {
  251.     HOTPLUG=/sbin/hotplug-call
  252. }
  253.  
  254. init_hotplug2() {
  255.     [ -c /dev/console ] || mknod /dev/console c 5 1
  256.     /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
  257.     /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --persistent &
  258. }
  259.  
  260. init_udev() {
  261.     [ -d /lib/udev/devices ] && cp -af /lib/udev/devices/* /dev/
  262.     [ -c /dev/console ] || mknod -m 0600 /dev/console c 5 1
  263.     [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
  264.     /sbin/udevd --daemon --resolve-names=never
  265.     /sbin/udevadm trigger
  266.     /sbin/udevadm settle    
  267. }
  268.  
  269. init_device_fs() {
  270.     HOTPLUG=
  271.     if grep -q devfs /proc/filesystems; then
  272.     init_devfs
  273.     elif [ -x /sbin/hotplug2 ]; then
  274.     init_hotplug2
  275.     elif [ -x /sbin/udevd ]; then
  276.     init_udev
  277.     fi
  278. }
  279.  
  280. boot_hook_add preinit_essential init_device_fs
  281.  
  282.  
  283. ==> ./30_failsafe_wait <==
  284. #!/bin/sh
  285. # Copyright (C) 2006-2010 OpenWrt.org
  286. # Copyright (C) 2010 Vertical Communications
  287.  
  288. fs_wait_for_key () {
  289.     local timeout=$3
  290.     local timer
  291.     local do_failsafe
  292.     local keypress_true="$(mktemp)"
  293.     local keypress_wait="$(mktemp)"
  294.     local keypress_sec="$(mktemp)"
  295.     if [ -z "$keypress_wait" ]; then
  296.     keypress_wait=/tmp/.keypress_wait
  297.     touch $keypress_wait
  298.     fi
  299.     if [ -z "$keypress_true" ]; then
  300.     keypress_true=/tmp/.keypress_true
  301.     touch $keypress_true
  302.     fi
  303.     if [ -z "$keypress_sec" ]; then
  304.     keypress_sec=/tmp/.keypress_sec
  305.     touch $keypress_sec
  306.     fi
  307.  
  308.     trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
  309.     trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
  310.  
  311.     [ -n "$timeout" ] || timeout=1
  312.     [ $timeout -ge 1 ] || timeout=1
  313.     timer=$timeout
  314.     lock $keypress_wait
  315.     {
  316.     while [ $timer -gt 0 ]; do
  317.             echo "$timer" >$keypress_sec
  318.         timer=$(($timer - 1))
  319.         sleep 1
  320.     done
  321.     lock -u $keypress_wait
  322.     rm -f $keypress_wait
  323.     } &
  324.  
  325.     bg_pid=$!
  326. #    echo "Press the [$1] key and hit [enter] $2"
  327. #     if we're on the console we wait for input
  328. #    {
  329. #   while [ -r $keypress_wait ]; do
  330. #       timer="$(cat $keypress_sec)"
  331. #
  332. #       [ -n "$timer" ] || timer=1
  333. #       timer="${timer%%\ *}"
  334. #       [ $timer -ge 1 ] || timer=1
  335. #       do_failsafe=""
  336. #       {
  337. #       read -t "$timer" do_failsafe
  338. #       if [ "$do_failsafe" = "$1" ]; then
  339. #           echo "true" >$keypress_true
  340. #           lock -u $keypress_wait
  341. #           rm -f $keypress_wait
  342. #       fi
  343. #       }
  344. #   done
  345. #   wait $bg_pid
  346. #   }
  347.     lock -w $keypress_wait
  348.  
  349.     trap - INT
  350.     trap - USR1
  351.  
  352.     keypressed=1
  353.     [ "$(cat $keypress_true)" = "true" ] && keypressed=0
  354.     rm -f $keypress_true
  355.     rm -f $keypress_wait
  356.     rm -f $keypress_sec
  357.    
  358.     return $keypressed
  359. }
  360.  
  361. failsafe_wait() {
  362.     FAILSAFE=
  363.     pi_failsafe_net_message=true
  364.     preinit_net_echo "Please press button now to enter failsafe"
  365.     pi_failsafe_net_message=false
  366.     fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
  367. }
  368.  
  369. boot_hook_add preinit_main failsafe_wait
  370.  
  371.  
  372. ==> ./40_init_shm <==
  373. #!/bin/sh
  374. # Copyright (C) 2006 OpenWrt.org
  375. # Copyright (C) 2010 Vertical Communications
  376.  
  377. init_shm() {
  378.     [ -d /dev/shm ] || mkdir -p /dev/shm
  379. }
  380.  
  381. boot_hook_add preinit_essential init_shm
  382.  
  383.  
  384. ==> ./40_mount_devpts <==
  385. #!/bin/sh
  386. # Copyright (C) 2006 OpenWrt.org
  387. # Copyright (C) 2010 Vertical Communications
  388.  
  389. init_devpts() {
  390.     [ -d /dev/pts ] || mkdir -p /dev/pts
  391. }
  392.  
  393. do_mount_devpts() {
  394.     mount devpts /dev/pts -t devpts
  395. }
  396.  
  397. boot_hook_add preinit_essential init_devpts
  398. boot_hook_add preinit_essential do_mount_devpts
  399.  
  400.  
  401. ==> ./40_mount_ext4 <==
  402. #!/bin/sh
  403. # Copyright (C) 2006-2010 OpenWrt.org
  404. # Copyright (C) 2010 Vertical Communications
  405.  
  406. ext4_not_mounted() {
  407.     if [ "$pi_ext4_mount_success" != "true" ]; then
  408.     return 0
  409.     else
  410.     return 1
  411.     fi
  412. }
  413.  
  414. do_mount_ext4() {
  415.     check_skip && return
  416.     grep -wqs rootfs_data /sys/block/mmcblk*/*/uevent || return 1
  417.  
  418.     mkdir -p /tmp/overlay
  419.     mount "$(find_mmc_part rootfs_data)" /tmp/overlay -t ext4 &&
  420.         pi_ext4_mount_success=true
  421. }
  422.  
  423. boot_hook_add preinit_mount_root do_mount_ext4
  424.  
  425.  
  426. ==> ./40_mount_jffs2 <==
  427. #!/bin/sh
  428. # Copyright (C) 2006-2010 OpenWrt.org
  429. # Copyright (C) 2010 Vertical Communications
  430.  
  431. find_mount_jffs2() {
  432.     mkdir -p /tmp/overlay
  433.     mount "$(find_mtd_part rootfs_data)" /tmp/overlay -t jffs2
  434.     mtd -qq unlock rootfs_data
  435. }
  436.  
  437. jffs2_not_mounted() {
  438.     if [ "$pi_jffs2_mount_success" != "true" ]; then
  439.     return 0
  440.     else
  441.     return 1
  442.     fi
  443. }
  444.  
  445. do_mount_jffs2() {
  446.     # skip jffs2 mounting even if it's there if we have volume named
  447.     # ubi_rootfs_data
  448.     check_skip && return
  449.     grep -wqs rootfs_data /proc/mtd || return 1
  450.  
  451.     find_mount_jffs2 && pi_jffs2_mount_success=true
  452. }
  453.  
  454. boot_hook_add preinit_mount_root do_mount_jffs2
  455.  
  456.  
  457. ==> ./40_mount_ubifs <==
  458. #!/bin/sh
  459. # Copyright (c) 2013 The Linux Foundation. All rights reserved.
  460.  
  461. ubifs_not_mounted() {
  462.     if [ "$pi_ubifs_mount_success" != "true" ]; then
  463.     return 0
  464.     else
  465.     return 1
  466.     fi
  467. }
  468.  
  469. do_mount_ubifs() {
  470.     check_skip && return
  471.     grep -wqs ubi_rootfs_data /sys/class/ubi/ubi0/ubi0_*/name || return 1
  472.  
  473.     mkdir -p /tmp/overlay
  474.     mount -t ubifs -o sync ubi0:ubi_rootfs_data /tmp/overlay &&
  475.         pi_ubifs_mount_success=true
  476. }
  477.  
  478. boot_hook_add preinit_mount_root do_mount_ubifs
  479.  
  480.  
  481. ==> ./40_run_failsafe_hook <==
  482. #!/bin/sh
  483. # Copyright (C) 2006-2010 OpenWrt.org
  484. # Copyright (C) 2010 Vertical Communications
  485.  
  486. run_failsafe_hook() {
  487.     if [ "$FAILSAFE" = "true" ]; then
  488.     boot_run_hook failsafe
  489.     lock -w /tmp/.failsafe
  490.     fi
  491. }
  492.  
  493. boot_hook_add preinit_main run_failsafe_hook
  494.  
  495.  
  496. ==> ./41_merge_overlay_hooks <==
  497. #!/bin/sh
  498. # Copyright (C) 2010 OpenWrt.org
  499.  
  500. merge_overlay_hooks() {
  501.     (jffs2_not_mounted && ubifs_not_mounted) || [ ! -d /tmp/overlay/lib/preinit ] || {
  502.         echo "- merge overlay components -"
  503.  
  504.         mkdir -p /tmp/preinit-hook-merge
  505.         ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/
  506.  
  507.         boot_hook_splice_start
  508.  
  509.         local pipart
  510.         for pipart in /tmp/preinit-hook-merge/*; do
  511.             . $pipart
  512.         done
  513.  
  514.         boot_hook_splice_finish
  515.  
  516.         rm -rf /tmp/preinit-hook-merge
  517.     }
  518. }
  519.  
  520. boot_hook_add preinit_mount_root merge_overlay_hooks
  521.  
  522. ==> ./50_choose_console <==
  523. #!/bin/sh
  524. # Copyright (C) 2006-2010 OpenWrt.org
  525. # Copyright (C) 2010 Vertical Communications
  526.  
  527. choose_console() {
  528.     # the shell really doesn't like having stdin/out closed
  529.     # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement
  530.     # for /dev/console if there's no serial console available
  531.  
  532.     if grep -q devfs /proc/filesystems; then
  533.     M0=/dev/pty/m0
  534.     M1=/dev/pty/m1
  535.     M2=/dev/pty/m1
  536.     elif [ -x /sbin/hotplug2 ]; then
  537.     M0=/dev/ptmx
  538.     M1=/dev/ptmx
  539.     M2=/dev/ptmx
  540.     elif [ -x /sbin/udevd ]; then
  541.     M0=/dev/pty/ptmx
  542.     M1=/dev/pty/ptmx
  543.     M2=/dev/pty/ptmx
  544.     fi
  545.     dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
  546.     M0=/dev/console
  547.     M1=/dev/console
  548.     M2=/dev/console    
  549.     }
  550. }
  551.  
  552. boot_hook_add preinit_essential choose_console
  553.  
  554.  
  555. ==> ./50_indicate_regular_preinit <==
  556. #!/bin/sh
  557. # Copyright (C) 2006 OpenWrt.org
  558. # Copyright (C) 2010 Vertical Communications
  559.  
  560. indicate_regular_preinit() {
  561.     echo "- regular preinit -"
  562.     preinit_net_echo "Continuing with Regular Preinit\n"
  563.     pi_indicate_led
  564. }
  565.  
  566. boot_hook_add preinit_main indicate_regular_preinit
  567.  
  568.  
  569. ==> ./60_init_hotplug <==
  570. #!/bin/sh
  571. # Copyright (C) 2006 OpenWrt.org
  572. # Copyright (C) 2010 Vertical Communications
  573.  
  574. init_hotplug() {
  575.    echo "$HOTPLUG" > /proc/sys/kernel/hotplug
  576. }
  577.  
  578. boot_hook_add preinit_main init_hotplug
  579.  
  580.  
  581. ==> ./70_initramfs_test <==
  582. #!/bin/sh
  583. # Copyright (C) 2006 OpenWrt.org
  584. # Copyright (C) 2010 Vertical Communications
  585.  
  586. initramfs_test() {
  587.     if [ -n "$INITRAMFS" ]; then
  588.     boot_run_hook initramfs
  589.     preinit_ip_deconfig
  590.     break
  591.     fi
  592. }
  593.  
  594. boot_hook_add preinit_main initramfs_test
  595.  
  596.  
  597. ==> ./70_pivot_ext4_root <==
  598. # Copyright (C) 2006-2010 OpenWrt.org
  599. # Copyright (C) 2010 Vertical Communications
  600.  
  601. rootfs_pivot_ext4() {
  602.     check_skip || ext4_not_mounted || {
  603.     echo "switching to ext4"
  604.     mount -o move /tmp/overlay /overlay 2>&-
  605.     fopivot /overlay /rom && pi_mount_skip_next=true
  606.     }
  607. }
  608.  
  609. boot_hook_add preinit_mount_root rootfs_pivot_ext4
  610.  
  611.  
  612. ==> ./70_pivot_jffs2_root <==
  613. #!/bin/sh
  614. # Copyright (C) 2006-2010 OpenWrt.org
  615. # Copyright (C) 2010 Vertical Communications
  616.  
  617. rootfs_pivot_jffs2() {
  618.     check_skip || jffs2_not_mounted || {
  619.     echo "switching to jffs2"
  620.     mount -o move /tmp/overlay /overlay 2>&-
  621.     fopivot /overlay /rom && pi_mount_skip_next=true
  622.     }
  623. }
  624.  
  625. boot_hook_add preinit_mount_root rootfs_pivot_jffs2
  626.  
  627.  
  628. ==> ./70_pivot_ubifs_root <==
  629. #!/bin/sh
  630. # Copyright (C) 2006-2010 OpenWrt.org
  631. # Copyright (C) 2010 Vertical Communications
  632.  
  633. rootfs_pivot_ubifs() {
  634.     check_skip || ubifs_not_mounted || {
  635.     echo "switching to ubifs"
  636.     mount -o move /tmp/overlay /overlay 2>&-
  637.     fopivot /overlay /rom && pi_mount_skip_next=true
  638.     }
  639. }
  640.  
  641. boot_hook_add preinit_mount_root rootfs_pivot_ubifs
  642.  
  643.  
  644. ==> ./80_mount_root <==
  645. #!/bin/sh
  646. # Copyright (C) 2006 OpenWrt.org
  647. # Copyright (C) 2010 Vertical Communications
  648.  
  649. do_mount_root() {
  650.     boot_run_hook preinit_mount_root
  651. }  
  652.  
  653. boot_hook_add preinit_main do_mount_root
  654.  
  655.  
  656. ==> ./90_init_console <==
  657. #!/bin/sh
  658. # Copyright (C) 2006-2010 OpenWrt.org
  659. # Copyright (C) 2010 Vertical Communications
  660.  
  661. init_console() {
  662.     if [ "$pi_suppress_stderr" = "y" ]; then
  663.     exec <$M0 >$M1 2>&0
  664.     else
  665.     exec <$M0 >$M1 2>$M2
  666.     fi
  667. }
  668.  
  669. boot_hook_add preinit_essential init_console
  670.  
  671.  
  672. ==> ./90_mount_no_jffs2 <==
  673. #!/bin/sh
  674. # Copyright (C) 2006-2010 OpenWrt.org
  675. # Copyright (C) 2010 Vertical Communications
  676.  
  677. do_mount_no_jffs2() {
  678.     check_skip || {
  679.     mount_no_jffs2 && pi_mount_skip_next=true
  680.     }
  681. }
  682.  
  683. boot_hook_add preinit_mount_root do_mount_no_jffs2
  684.  
  685.  
  686. ==> ./90_restore_config <==
  687. #!/bin/sh
  688. # Copyright (C) 2006 OpenWrt.org
  689. # Copyright (C) 2010 Vertical Communications
  690.  
  691. restore_config() {
  692.     [ -f /sysupgrade.tgz ] && {
  693.     echo "- config restore -"
  694.     cd /
  695.     mv sysupgrade.tgz /tmp
  696.     tar xzf /tmp/sysupgrade.tgz
  697.     rm -f /tmp/sysupgrade.tgz
  698.     sync
  699.     }
  700. }
  701.  
  702. boot_hook_add preinit_main restore_config
  703.  
  704.  
  705. ==> ./99_10_failsafe_login <==
  706. #!/bin/sh
  707. # Copyright (C) 2006 OpenWrt.org
  708. # Copyright (C) 2010 Vertical Communications
  709.  
  710. failsafe_netlogin () {
  711.     telnetd -l /bin/login.sh <> /dev/null 2>&1    
  712. }
  713.  
  714. failsafe_shell() {
  715.     lock /tmp/.failsafe
  716.     ash --login
  717.     echo "Please reboot system when done with failsafe network logins"
  718. }
  719.  
  720.  
  721. boot_hook_add failsafe failsafe_netlogin
  722. boot_hook_add failsafe failsafe_shell
  723.  
  724.  
  725. ==> ./99_10_mount_no_mtd <==
  726. #!/bin/sh
  727. # Copyright (C) 2006-2010 OpenWrt.org
  728. # Copyright (C) 2010 Vertical Communications
  729.  
  730. do_mount_no_mtd() {
  731.     check_skip || {
  732.     mount_no_mtd
  733.     }
  734. }
  735.  
  736. boot_hook_add preinit_mount_root do_mount_no_mtd
  737.  
  738.  
  739. ==> ./99_10_run_init <==
  740. #!/bin/sh
  741. # Copyright (C) 2006 OpenWrt.org
  742. # Copyright (C) 2010 Vertical Communications
  743.  
  744. run_init() {
  745.     preinit_echo "- init -"
  746.     preinit_ip_deconfig
  747.     if [ "$pi_init_suppress_stderr" = "y" ]; then
  748.     exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd 2>&0
  749.     else
  750.     exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd
  751.     fi
  752. }
  753.  
  754. boot_hook_add preinit_main run_init
  755.  
  756.  
  757.  
Advertisement
RAW Paste Data Copied
Advertisement