diff options
Diffstat (limited to 'package/base-files/files/lib/preinit')
22 files changed, 20 insertions, 353 deletions
diff --git a/package/base-files/files/lib/preinit/05_mount_skip b/package/base-files/files/lib/preinit/05_mount_skip deleted file mode 100644 index c2b7ee79d..000000000 --- a/package/base-files/files/lib/preinit/05_mount_skip +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -check_skip() { - if [ "$pi_mount_skip_next" = "true" ]; then - return 0 - else - return 1 - fi -} - diff --git a/package/base-files/files/lib/preinit/10_check_for_mtd b/package/base-files/files/lib/preinit/10_check_for_mtd deleted file mode 100644 index 66f185e1a..000000000 --- a/package/base-files/files/lib/preinit/10_check_for_mtd +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -mount_no_mtd() { - mtd unlock rootfs - mount -o remount,rw /dev/root / -} - -check_for_mtd() { - check_skip || { - grep -qs rootfs_data /proc/mtd || { - mount_no_mtd && pi_mount_skip_next=true - } - } -} - -boot_hook_add preinit_mount_root check_for_mtd - diff --git a/package/base-files/files/lib/preinit/10_essential_fs b/package/base-files/files/lib/preinit/10_essential_fs deleted file mode 100644 index 5d979fd49..000000000 --- a/package/base-files/files/lib/preinit/10_essential_fs +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_mount_procfs() { - mount -t proc proc /proc -} - -do_mount_sysfs() { - mount -t sysfs sysfs /sys -} - -calc_tmpfs_size() { - pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)&&(mt>l)?mt-l:s}' /proc/meminfo) -} - -do_mount_tmpfs() { - calc_tmpfs_size - mount -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp -} - -boot_hook_add preinit_essential do_mount_procfs -boot_hook_add preinit_essential do_mount_sysfs -boot_hook_add preinit_essential do_mount_tmpfs - diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit index 4a0109cc1..da70b97c4 100644 --- a/package/base-files/files/lib/preinit/10_indicate_preinit +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -41,7 +41,6 @@ pi_indicate_led() { } pi_indicate_preinit() { - echo "- preinit -" preinit_net_echo "Doing OpenWRT Preinit\n" pi_indicate_led } diff --git a/package/base-files/files/lib/preinit/20_check_jffs2_ready b/package/base-files/files/lib/preinit/20_check_jffs2_ready deleted file mode 100644 index 3c5cf67e8..000000000 --- a/package/base-files/files/lib/preinit/20_check_jffs2_ready +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -mount_no_jffs2() { - echo "jffs2 not ready yet; using ramdisk" - ramoverlay -} - -check_for_jffs2() { - check_skip || { - jffs2_ready || { - mount_no_jffs2 && pi_mount_skip_next=true - } - } -} - -boot_hook_add preinit_mount_root check_for_jffs2 - diff --git a/package/base-files/files/lib/preinit/20_device_fs_mount b/package/base-files/files/lib/preinit/20_device_fs_mount deleted file mode 100644 index ed59b5b23..000000000 --- a/package/base-files/files/lib/preinit/20_device_fs_mount +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_move_devtmpfs() { - local mnt="$(grep devtmpfs /proc/mounts)" - mnt="${mnt#* }"; mnt="${mnt%% *}" - - [ "$mnt" = "/dev" ] || mount -o move "$mnt" /dev -} - -do_mount_devfs() { - mount -t devfs devfs /dev -} - -do_mount_hotplug() { - mount -t tmpfs -o mode=0755,size=512K tmpfs /dev -} - -do_mount_udev() { - mount -n -t tmpfs -o mode=0755 udev /dev -} - -choose_device_fs() { - if grep -q devtmpfs /proc/mounts; then - do_move_devtmpfs - elif grep -q devfs /proc/filesystems; then - do_mount_devfs - elif [ -x /sbin/hotplug2 ]; then - do_mount_hotplug - elif [ -x /sbin/udevd ]; then - do_mount_udev - fi -} - -boot_hook_add preinit_essential choose_device_fs - diff --git a/package/base-files/files/lib/preinit/30_device_fs_daemons b/package/base-files/files/lib/preinit/30_device_fs_daemons deleted file mode 100644 index 5b3e2ad00..000000000 --- a/package/base-files/files/lib/preinit/30_device_fs_daemons +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_devfs() { - HOTPLUG=/sbin/hotplug-call -} - -init_hotplug2() { - [ -c /dev/console ] || mknod /dev/console c 5 1 - /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger - /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --persistent & -} - -init_udev() { - [ -d /lib/udev/devices ] && cp -af /lib/udev/devices/* /dev/ - [ -c /dev/console ] || mknod -m 0600 /dev/console c 5 1 - [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3 - /sbin/udevd --daemon --resolve-names=never - /sbin/udevadm trigger - /sbin/udevadm settle -} - -init_device_fs() { - HOTPLUG= - if grep -q devfs /proc/filesystems; then - init_devfs - elif [ -x /sbin/hotplug2 ]; then - init_hotplug2 - elif [ -x /sbin/udevd ]; then - init_udev - fi -} - -boot_hook_add preinit_essential init_device_fs - diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait index 04dc57df2..bcf24f8bb 100644 --- a/package/base-files/files/lib/preinit/30_failsafe_wait +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -61,11 +61,10 @@ fs_wait_for_key () { } lock -w $keypress_wait - trap - INT - trap - USR1 - keypressed=1 [ "$(cat $keypress_true)" = "true" ] && keypressed=0 + [ -f "/tmp/failsafe_button" ] && keypressed=1 + rm -f $keypress_true rm -f $keypress_wait rm -f $keypress_sec @@ -75,10 +74,13 @@ fs_wait_for_key () { failsafe_wait() { FAILSAFE= - pi_failsafe_net_message=true - preinit_net_echo "Please press button now to enter failsafe" - pi_failsafe_net_message=false - fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE + grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE + if [ "$FAILSAFE" != "true" ]; then + pi_failsafe_net_message=true + preinit_net_echo "Please press button now to enter failsafe" + pi_failsafe_net_message=false + fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE + fi } boot_hook_add preinit_main failsafe_wait diff --git a/package/base-files/files/lib/preinit/40_init_shm b/package/base-files/files/lib/preinit/40_init_shm deleted file mode 100644 index 8971116a4..000000000 --- a/package/base-files/files/lib/preinit/40_init_shm +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_shm() { - [ -d /dev/shm ] || mkdir -p /dev/shm -} - -boot_hook_add preinit_essential init_shm - diff --git a/package/base-files/files/lib/preinit/40_mount_devpts b/package/base-files/files/lib/preinit/40_mount_devpts deleted file mode 100644 index b75d69287..000000000 --- a/package/base-files/files/lib/preinit/40_mount_devpts +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_devpts() { - [ -d /dev/pts ] || mkdir -p /dev/pts -} - -do_mount_devpts() { - mount -t devpts devpts /dev/pts -} - -boot_hook_add preinit_essential init_devpts -boot_hook_add preinit_essential do_mount_devpts - diff --git a/package/base-files/files/lib/preinit/40_mount_jffs2 b/package/base-files/files/lib/preinit/40_mount_jffs2 deleted file mode 100644 index 00f45a890..000000000 --- a/package/base-files/files/lib/preinit/40_mount_jffs2 +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -find_mount_jffs2() { - mkdir -p /tmp/overlay - mount "$(find_mtd_part rootfs_data)" /tmp/overlay -t jffs2 - mtd -qq unlock rootfs_data -} - -jffs2_not_mounted() { - if [ "$pi_jffs2_mount_success" != "true" ]; then - return 0 - else - return 1 - fi -} - -do_mount_jffs2() { - check_skip || { - find_mount_jffs2 && pi_jffs2_mount_success=true - } -} - -boot_hook_add preinit_mount_root do_mount_jffs2 - diff --git a/package/base-files/files/lib/preinit/41_merge_overlay_hooks b/package/base-files/files/lib/preinit/41_merge_overlay_hooks deleted file mode 100644 index 4ca6877be..000000000 --- a/package/base-files/files/lib/preinit/41_merge_overlay_hooks +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# Copyright (C) 2010 OpenWrt.org - -merge_overlay_hooks() { - jffs2_not_mounted || [ ! -d /tmp/overlay/lib/preinit ] || { - echo "- merge overlay components -" - - mkdir -p /tmp/preinit-hook-merge - ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/ - - boot_hook_splice_start - - local pipart - for pipart in /tmp/preinit-hook-merge/*; do - . $pipart - done - - boot_hook_splice_finish - - rm -rf /tmp/preinit-hook-merge - } -} - -boot_hook_add preinit_mount_root merge_overlay_hooks diff --git a/package/base-files/files/lib/preinit/50_choose_console b/package/base-files/files/lib/preinit/50_choose_console deleted file mode 100644 index ecbc2eaf4..000000000 --- a/package/base-files/files/lib/preinit/50_choose_console +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -choose_console() { - # the shell really doesn't like having stdin/out closed - # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement - # for /dev/console if there's no serial console available - - if grep -q devfs /proc/filesystems; then - M0=/dev/pty/m0 - M1=/dev/pty/m1 - M2=/dev/pty/m1 - elif [ -x /sbin/hotplug2 ]; then - M0=/dev/ptmx - M1=/dev/ptmx - M2=/dev/ptmx - elif [ -x /sbin/udevd ]; then - M0=/dev/pty/ptmx - M1=/dev/pty/ptmx - M2=/dev/pty/ptmx - fi - dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && { - M0=/dev/console - M1=/dev/console - M2=/dev/console - } -} - -boot_hook_add preinit_essential choose_console - diff --git a/package/base-files/files/lib/preinit/50_indicate_regular_preinit b/package/base-files/files/lib/preinit/50_indicate_regular_preinit index 9cc01f219..c200dad67 100644 --- a/package/base-files/files/lib/preinit/50_indicate_regular_preinit +++ b/package/base-files/files/lib/preinit/50_indicate_regular_preinit @@ -3,7 +3,6 @@ # Copyright (C) 2010 Vertical Communications indicate_regular_preinit() { - echo "- regular preinit -" preinit_net_echo "Continuing with Regular Preinit\n" pi_indicate_led } diff --git a/package/base-files/files/lib/preinit/60_init_hotplug b/package/base-files/files/lib/preinit/60_init_hotplug deleted file mode 100644 index dc05e0ed0..000000000 --- a/package/base-files/files/lib/preinit/60_init_hotplug +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_hotplug() { - echo "$HOTPLUG" > /proc/sys/kernel/hotplug -} - -boot_hook_add preinit_main init_hotplug - diff --git a/package/base-files/files/lib/preinit/70_pivot_jffs2_root b/package/base-files/files/lib/preinit/70_pivot_jffs2_root deleted file mode 100644 index 821bfb14f..000000000 --- a/package/base-files/files/lib/preinit/70_pivot_jffs2_root +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -rootfs_pivot() { - check_skip || jffs2_not_mounted || { - echo "switching to jffs2" - mount -o move /tmp/overlay /overlay 2>&- - fopivot /overlay /rom && pi_mount_skip_next=true - } -} - -boot_hook_add preinit_mount_root rootfs_pivot - diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root index ad24fb8ac..0292d82d4 100644 --- a/package/base-files/files/lib/preinit/80_mount_root +++ b/package/base-files/files/lib/preinit/80_mount_root @@ -3,8 +3,16 @@ # Copyright (C) 2010 Vertical Communications do_mount_root() { - boot_run_hook preinit_mount_root + mount_root + boot_run_hook preinit_mount_root + [ -f /sysupgrade.tgz ] && { + echo "- config restore -" + cd / + mv sysupgrade.tgz /tmp + tar xzf /tmp/sysupgrade.tgz + rm -f /tmp/sysupgrade.tgz + sync + } } -boot_hook_add preinit_main do_mount_root - +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root diff --git a/package/base-files/files/lib/preinit/90_init_console b/package/base-files/files/lib/preinit/90_init_console deleted file mode 100644 index ca05755fd..000000000 --- a/package/base-files/files/lib/preinit/90_init_console +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_console() { - if [ "$pi_suppress_stderr" = "y" ]; then - exec <$M0 >$M1 2>&0 - else - exec <$M0 >$M1 2>$M2 - fi -} - -boot_hook_add preinit_essential init_console - diff --git a/package/base-files/files/lib/preinit/90_mount_no_jffs2 b/package/base-files/files/lib/preinit/90_mount_no_jffs2 deleted file mode 100644 index d8ad4ae11..000000000 --- a/package/base-files/files/lib/preinit/90_mount_no_jffs2 +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_mount_no_jffs2() { - check_skip || { - mount_no_jffs2 && pi_mount_skip_next=true - } -} - -boot_hook_add preinit_mount_root do_mount_no_jffs2 - diff --git a/package/base-files/files/lib/preinit/90_restore_config b/package/base-files/files/lib/preinit/90_restore_config deleted file mode 100644 index 210bf6184..000000000 --- a/package/base-files/files/lib/preinit/90_restore_config +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -restore_config() { - [ -f /sysupgrade.tgz ] && { - echo "- config restore -" - cd / - mv sysupgrade.tgz /tmp - tar xzf /tmp/sysupgrade.tgz - rm -f /tmp/sysupgrade.tgz - sync - } -} - -boot_hook_add preinit_main restore_config - diff --git a/package/base-files/files/lib/preinit/99_10_mount_no_mtd b/package/base-files/files/lib/preinit/99_10_mount_no_mtd deleted file mode 100644 index c4f38e415..000000000 --- a/package/base-files/files/lib/preinit/99_10_mount_no_mtd +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_mount_no_mtd() { - check_skip || { - mount_no_mtd - } -} - -boot_hook_add preinit_mount_root do_mount_no_mtd - diff --git a/package/base-files/files/lib/preinit/99_10_run_init b/package/base-files/files/lib/preinit/99_10_run_init index fef3a503e..a8f330f89 100644 --- a/package/base-files/files/lib/preinit/99_10_run_init +++ b/package/base-files/files/lib/preinit/99_10_run_init @@ -3,13 +3,7 @@ # Copyright (C) 2010 Vertical Communications run_init() { - preinit_echo "- init -" preinit_ip_deconfig - if [ "$pi_init_suppress_stderr" = "y" ]; then - exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd 2>&0 - else - exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd - fi } boot_hook_add preinit_main run_init |