mirror of
https://github.com/lxsang/meta-rpi-diya.git
synced 2024-12-26 02:38:22 +01:00
use sysvinit
This commit is contained in:
parent
a3ece685aa
commit
d6e79e0c32
@ -1,82 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2011 O.S. Systems Software LTDA.
|
||||
# Licensed on MIT
|
||||
|
||||
# Adds support to dynamic debugging of initramfs using bootparam in
|
||||
# following format:
|
||||
# shell : starts a shell before and after each module
|
||||
# shell=before:<module> : starts a shell before <module> is loaded and run
|
||||
# shell=after:<module> : starts a shell after <module> is loaded and run
|
||||
#
|
||||
# shell-debug : run set -x as soon as possible
|
||||
# shell-debug=before:<module> : run set -x before <module> is loaded and run
|
||||
# shell-debug=after:<module> : run set -x after <module> is loaded and run
|
||||
|
||||
DEBUG_SHELL="false"
|
||||
|
||||
debug_hook_handler() {
|
||||
status=$1
|
||||
module=$2
|
||||
|
||||
if [ -n "$bootparam_shell" ] && [ "$bootparam_shell" != "true" ]; then
|
||||
shell_wanted_status=`expr $bootparam_shell : '\(.*\):.*'`
|
||||
shell_wanted_module=`expr $bootparam_shell : '.*:\(.*\)'`
|
||||
|
||||
if [ "$shell_wanted_status" = "before" ]; then
|
||||
shell_wanted_status=pre
|
||||
else
|
||||
shell_wanted_status=post
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$bootparam_shell" = "true" ] ||
|
||||
( [ "$status" = "$shell_wanted_status" ] &&
|
||||
[ "$module" = "$shell_wanted_module" ] ); then
|
||||
if [ "$status" = "pre" ]; then
|
||||
status_msg="before"
|
||||
else
|
||||
status_msg="after"
|
||||
fi
|
||||
|
||||
msg "Starting shell $status_msg $module..."
|
||||
sh
|
||||
fi
|
||||
|
||||
if [ -n "$bootparam_shell_debug" ] && [ "$bootparam_shell_debug" != "true" ]; then
|
||||
shell_debug_wanted_status=`expr $bootparam_shell_debug : '\(.*\):.*'`
|
||||
shell_debug_wanted_module=`expr $bootparam_shell_debug : '.*:\(.*\)'`
|
||||
|
||||
if [ "$shell_debug_wanted_status" = "before" ]; then
|
||||
shell_debug_wanted_status=pre
|
||||
else
|
||||
shell_debug_wanted_status=post
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$bootparam_shell_debug" = "true" ] ||
|
||||
( [ "$status" = "$shell_debug_wanted_status" ] &&
|
||||
[ "$module" = "$shell_debug_wanted_module" ] ); then
|
||||
if [ "$DEBUG_SHELL" = "true" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$status" = "pre" ]; then
|
||||
status_msg="before"
|
||||
else
|
||||
status_msg="after"
|
||||
fi
|
||||
|
||||
msg "Starting shell debugging $status_msg $module..."
|
||||
DEBUG_SHELL="true"
|
||||
set -x
|
||||
fi
|
||||
}
|
||||
|
||||
debug_enabled() {
|
||||
return 0
|
||||
}
|
||||
|
||||
debug_run() {
|
||||
add_module_pre_hook "debug_hook_handler"
|
||||
add_module_post_hook "debug_hook_handler"
|
||||
}
|
@ -15,19 +15,6 @@
|
||||
# 'foo' as 'bootparam_foo=true'
|
||||
# 'foo.bar[=value] as 'foo_bar=[value|true]'
|
||||
|
||||
# Register a function to be called before running a module
|
||||
# The hook is called as:
|
||||
# <function> pre <module>
|
||||
add_module_pre_hook() {
|
||||
MODULE_PRE_HOOKS="$MODULE_PRE_HOOKS $1"
|
||||
}
|
||||
|
||||
# Register a function to be called after running a module
|
||||
# The hook is called as:
|
||||
# <function> post <module>
|
||||
add_module_post_hook() {
|
||||
MODULE_POST_HOOKS="$MODULE_POST_HOOKS $1"
|
||||
}
|
||||
|
||||
# Load kernel module
|
||||
load_kernel_module() {
|
||||
@ -68,9 +55,6 @@ fatal() {
|
||||
}
|
||||
|
||||
# Variables shared amoung modules
|
||||
MODULE_PRE_HOOKS="" # functions to call before running each module
|
||||
MODULE_POST_HOOKS="" # functions to call after running each module
|
||||
MODULES_DIR=/init.d # place to look for modules
|
||||
EFI_DIR=/sys/firmware/efi # place to store device firmware information
|
||||
|
||||
# make mount stop complaining about missing /etc/fstab
|
||||
@ -122,45 +106,5 @@ fi
|
||||
|
||||
exec /sbin/init
|
||||
|
||||
# active the back light
|
||||
echo 0 > /sys/class/backlight/backlight/bl_power
|
||||
|
||||
# Load and run modules
|
||||
for m in $MODULES_DIR/*; do
|
||||
# Skip backup files
|
||||
if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
module=`basename $m | cut -d'-' -f 2`
|
||||
debug "Loading module $module"
|
||||
|
||||
# pre hooks
|
||||
for h in $MODULE_PRE_HOOKS; do
|
||||
debug "Calling module hook (pre): $h"
|
||||
eval "$h pre $module"
|
||||
debug "Finished module hook (pre): $h"
|
||||
done
|
||||
|
||||
# process module
|
||||
. $m
|
||||
|
||||
if ! eval "${module}_enabled"; then
|
||||
debug "Skipping module $module"
|
||||
continue
|
||||
fi
|
||||
|
||||
debug "Running ${module}_run"
|
||||
eval "${module}_run"
|
||||
|
||||
# post hooks
|
||||
for h in $MODULE_POST_HOOKS; do
|
||||
debug "Calling module hook (post): $h"
|
||||
eval "$h post $module"
|
||||
debug "Finished module hook (post): $h"
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
# Catch all
|
||||
fatal "ERROR: Initramfs failed to initialize the system."
|
||||
|
@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2011, 2012 O.S. Systems Software LTDA.
|
||||
# Licensed on MIT
|
||||
|
||||
udev_shutdown_hook_handler() {
|
||||
status=$1
|
||||
module=$2
|
||||
if [ "$status" = "pre" ] && [ "$module" = "finish" ]; then
|
||||
udevadm settle
|
||||
killall `basename $_UDEV_DAEMON` 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
udev_daemon() {
|
||||
OPTIONS="/sbin/udev/udevd /sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd"
|
||||
|
||||
for o in $OPTIONS; do
|
||||
if [ -x "$o" ]; then
|
||||
echo $o
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
_UDEV_DAEMON=`udev_daemon`
|
||||
|
||||
udev_enabled() {
|
||||
if [ -z "$_UDEV_DAEMON" ]; then
|
||||
msg "WARNING: Cannot find the udev daemon; daemon will not be started in initramfs."
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
udev_run() {
|
||||
add_module_pre_hook "udev_shutdown_hook_handler"
|
||||
|
||||
mkdir -p /run
|
||||
mkdir -p /var/run
|
||||
|
||||
# Workaround if console=null, systemd-udevd needs valid stdin, stdout and stderr to work
|
||||
sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; }
|
||||
|
||||
$_UDEV_DAEMON --daemon
|
||||
udevadm trigger --action=add
|
||||
udevadm settle
|
||||
}
|
Loading…
Reference in New Issue
Block a user