committing ipk sources
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
define_default_set_state() {
|
||||
. /etc/diag.sh
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main define_default_set_state
|
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
# commands for emitting messages to network in failsafe mode
|
||||
|
||||
indicate_failsafe_led () {
|
||||
set_state failsafe
|
||||
}
|
||||
|
||||
indicate_failsafe() {
|
||||
echo "- failsafe -"
|
||||
preinit_net_echo "Entering Failsafe!\n"
|
||||
indicate_failsafe_led
|
||||
}
|
||||
|
||||
boot_hook_add failsafe indicate_failsafe
|
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
preinit_ip() {
|
||||
# if the preinit interface isn't specified and ifname is set in
|
||||
# preinit.arch use that interface
|
||||
if [ -z "$pi_ifname" ]; then
|
||||
pi_ifname=$ifname
|
||||
fi
|
||||
|
||||
[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
|
||||
ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
|
||||
}
|
||||
}
|
||||
|
||||
preinit_ip_deconfig() {
|
||||
[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
|
||||
ifconfig $pi_ifname 0.0.0.0 down
|
||||
}
|
||||
}
|
||||
|
||||
preinit_net_echo() {
|
||||
[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
|
||||
{
|
||||
[ "$pi_preinit_net_messages" = "y" ] || {
|
||||
[ "$pi_failsafe_net_message" = "true" ] &&
|
||||
[ "$pi_preinit_no_failsafe_netmsg" != "y" ]
|
||||
}
|
||||
} && netmsg $pi_broadcast "$1"
|
||||
}
|
||||
}
|
||||
|
||||
preinit_echo() {
|
||||
preinit_net_echo $1
|
||||
echo $1
|
||||
}
|
||||
|
||||
pi_indicate_preinit() {
|
||||
preinit_net_echo "Doing OpenWrt Preinit\n"
|
||||
set_state preinit
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_ip
|
||||
boot_hook_add preinit_main pi_indicate_preinit
|
@ -0,0 +1,10 @@
|
||||
do_sysinfo_generic() {
|
||||
[ -d /proc/device-tree ] || return
|
||||
mkdir -p /tmp/sysinfo
|
||||
[ -e /tmp/sysinfo/board_name ] || \
|
||||
echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name
|
||||
[ -e /tmp/sysinfo/model ] || \
|
||||
echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_generic
|
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
do_mount_procfs() {
|
||||
mount -o noatime -t proc none /proc
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
check_for_iso() {
|
||||
grep -qE '/dev/root.*iso9660' /proc/mounts && ramoverlay
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root check_for_iso
|
@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
fs_wait_for_key () {
|
||||
local timeout=$3
|
||||
local timer
|
||||
local do_keypress
|
||||
local keypress_true="$(mktemp)"
|
||||
local keypress_wait="$(mktemp)"
|
||||
local keypress_sec="$(mktemp)"
|
||||
if [ -z "$keypress_wait" ]; then
|
||||
keypress_wait=/tmp/.keypress_wait
|
||||
touch $keypress_wait
|
||||
fi
|
||||
if [ -z "$keypress_true" ]; then
|
||||
keypress_true=/tmp/.keypress_true
|
||||
touch $keypress_true
|
||||
fi
|
||||
if [ -z "$keypress_sec" ]; then
|
||||
keypress_sec=/tmp/.keypress_sec
|
||||
touch $keypress_sec
|
||||
fi
|
||||
|
||||
trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
|
||||
trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
|
||||
|
||||
[ -n "$timeout" ] || timeout=1
|
||||
[ $timeout -ge 1 ] || timeout=1
|
||||
timer=$timeout
|
||||
lock $keypress_wait
|
||||
{
|
||||
while [ $timer -gt 0 ]; do
|
||||
echo "$timer" >$keypress_sec
|
||||
timer=$(($timer - 1))
|
||||
sleep 1
|
||||
done
|
||||
lock -u $keypress_wait
|
||||
rm -f $keypress_wait
|
||||
} &
|
||||
|
||||
echo "Press the [$1] key and hit [enter] $2"
|
||||
echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level"
|
||||
# if we're on the console we wait for input
|
||||
{
|
||||
while [ -r $keypress_wait ]; do
|
||||
timer="$(cat $keypress_sec)"
|
||||
|
||||
[ -n "$timer" ] || timer=1
|
||||
timer="${timer%%\ *}"
|
||||
[ $timer -ge 1 ] || timer=1
|
||||
do_keypress=""
|
||||
{
|
||||
read -t "$timer" do_keypress
|
||||
case "$do_keypress" in
|
||||
$1)
|
||||
echo "true" >$keypress_true
|
||||
;;
|
||||
1 | 2 | 3 | 4)
|
||||
echo "$do_keypress" >/tmp/debug_level
|
||||
;;
|
||||
*)
|
||||
continue;
|
||||
;;
|
||||
esac
|
||||
lock -u $keypress_wait
|
||||
rm -f $keypress_wait
|
||||
}
|
||||
done
|
||||
}
|
||||
lock -w $keypress_wait
|
||||
|
||||
keypressed=1
|
||||
[ "$(cat $keypress_true)" = "true" ] && keypressed=0
|
||||
|
||||
rm -f $keypress_true
|
||||
rm -f $keypress_wait
|
||||
rm -f $keypress_sec
|
||||
|
||||
return $keypressed
|
||||
}
|
||||
|
||||
failsafe_wait() {
|
||||
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
|
||||
[ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
|
||||
[ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main failsafe_wait
|
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
run_failsafe_hook() {
|
||||
if [ "$FAILSAFE" = "true" ]; then
|
||||
boot_run_hook failsafe
|
||||
lock -w /tmp/.failsafe
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main run_failsafe_hook
|
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
indicate_regular_preinit() {
|
||||
preinit_net_echo "Continuing with Regular Preinit\n"
|
||||
set_state preinit_regular
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main indicate_regular_preinit
|
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
initramfs_test() {
|
||||
if [ -n "$INITRAMFS" ]; then
|
||||
boot_run_hook initramfs
|
||||
preinit_ip_deconfig
|
||||
break
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main initramfs_test
|
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2012-2015 OpenWrt.org
|
||||
|
||||
move_config() {
|
||||
. /lib/upgrade/platform.sh
|
||||
|
||||
if platform_export_bootpart; then
|
||||
mount -t ext4 -o rw,noatime "$BOOTPART" /mnt
|
||||
mv -f /mnt/sysupgrade.tgz /
|
||||
umount /mnt
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root move_config
|
||||
|
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
do_mount_root() {
|
||||
mount_root
|
||||
boot_run_hook preinit_mount_root
|
||||
[ -f /sysupgrade.tgz ] && {
|
||||
echo "- config restore -"
|
||||
cd /
|
||||
tar xzf /sysupgrade.tgz
|
||||
}
|
||||
}
|
||||
|
||||
[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root
|
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
failsafe_netlogin () {
|
||||
telnetd -l /bin/login.sh <> /dev/null 2>&1
|
||||
}
|
||||
|
||||
failsafe_shell() {
|
||||
lock /tmp/.failsafe
|
||||
ash --login
|
||||
echo "Please reboot system when done with failsafe network logins"
|
||||
}
|
||||
|
||||
boot_hook_add failsafe failsafe_netlogin
|
||||
boot_hook_add failsafe failsafe_shell
|
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
run_init() {
|
||||
preinit_ip_deconfig
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main run_init
|
Reference in New Issue
Block a user