Skip to content
Snippets Groups Projects
Commit f43b7934 authored by John Crispin's avatar John Crispin
Browse files

make basefiles aware of procd


Signed-off-by: default avatarJohn Crispin <blogic@openwrt.org>

SVN-Revision: 36003
parent 1360067c
No related branches found
No related tags found
No related merge requests found
Showing
with 394 additions and 0 deletions
...@@ -15,6 +15,7 @@ PKG_RELEASE:=134 ...@@ -15,6 +15,7 @@ PKG_RELEASE:=134
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
PKG_BUILD_DEPENDS:=opkg/host PKG_BUILD_DEPENDS:=opkg/host
PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
...@@ -55,6 +56,18 @@ define Package/base-files/description ...@@ -55,6 +56,18 @@ define Package/base-files/description
This package contains a base filesystem and system scripts for OpenWrt. This package contains a base filesystem and system scripts for OpenWrt.
endef endef
define Package/base-files/config
config PROCD_INIT
bool "Use procd as the init process"
default n
endef
ifeq ($(CONFIG_PROCD_INIT),)
define InstallOldFiles
$(CP) ./files.old/* $(1)/
endef
endif
ifneq ($(CONFIG_PREINITOPT),) ifneq ($(CONFIG_PREINITOPT),)
define ImageConfigOptions define ImageConfigOptions
mkdir -p $(1)/lib/preinit mkdir -p $(1)/lib/preinit
...@@ -87,6 +100,7 @@ define Package/base-files/install ...@@ -87,6 +100,7 @@ define Package/base-files/install
if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \ if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
$(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \ $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
fi fi
$(call InstallOldFiles,$(1))
if [ -d $(PLATFORM_DIR)/base-files/. ]; then \ if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
$(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \ $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
fi fi
......
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=10
STOP=98
system_config() {
local cfg="$1"
local hostname conloglevel timezone
config_get hostname "$cfg" hostname 'OpenWrt'
echo "$hostname" > /proc/sys/kernel/hostname
config_get conloglevel "$cfg" conloglevel
config_get buffersize "$cfg" buffersize
[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
config_get timezone "$cfg" timezone 'UTC'
echo "$timezone" > /tmp/TZ
config_get zonename "$cfg" zonename
[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
# apply timezone to kernel
date -k
if [ -x /sbin/syslogd ]; then
local args log_ip log_size log_port log_type log_file
config_get log_ip "$cfg" log_ip
config_get log_size "$cfg" log_size 16
config_get log_port "$cfg" log_port 514
config_get log_type "$cfg" log_type circular
config_get log_file "$cfg" log_file "/var/log/messages"
args="${log_ip:+-L -R ${log_ip}:${log_port}} ${conloglevel:+-l $conloglevel}"
if [ "$log_type" = "file" ]; then
args="$args -s $log_size -O $log_file -S"
else
args="$args -C${log_size}"
fi
service_start /sbin/syslogd $args
fi
if [ -x /sbin/klogd ]; then
config_get klogconloglevel "$cfg" klogconloglevel
args="${klogconloglevel:+-c $klogconloglevel}"
service_start /sbin/klogd $args
fi
}
apply_uci_config() {
sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
}
start() {
[ -f /proc/mounts ] || /sbin/mount_root
[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
[ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
mkdir -p /var/run
mkdir -p /var/log
mkdir -p /var/lock
mkdir -p /var/state
mkdir -p /tmp/.uci
chmod 0700 /tmp/.uci
touch /var/log/wtmp
touch /var/log/lastlog
touch /tmp/resolv.conf.auto
ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
load_modules /etc/modules.d/*
# allow wifi modules time to settle
sleep 1
/sbin/wifi detect > /tmp/wireless.tmp
[ -s /tmp/wireless.tmp ] && {
cat /tmp/wireless.tmp >> /etc/config/wireless
}
rm -f /tmp/wireless.tmp
apply_uci_config
config_load system
config_foreach system_config system
killall -q hotplug2
[ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
--set-rules-file /etc/hotplug2.rules \
--set-coldplug-cmd /sbin/udevtrigger \
--max-children 1 >/dev/null 2>&1 &
# create /dev/root if it doesn't exist
[ -e /dev/root -o -h /dev/root ] || {
rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
}
# early sysctl to avoid networking races
if [ -d /proc/sys/net/ipv6/conf ]; then
for i in /proc/sys/net/ipv6/conf/*/accept_ra; do
echo 0 > $i
done
fi
}
stop() {
service_stop /sbin/klogd
service_stop /sbin/syslogd
}
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
run_scripts() {
for i in /etc/rc.d/$1*; do
[ -x $i ] && $i $2 2>&1
done | $LOGGER
}
system_config() {
config_get_bool foreground $1 foreground 0
}
LOGGER="cat"
[ -x /usr/bin/logger ] && LOGGER="logger -s -p 6 -t sysinit"
. /lib/functions.sh
config_load system
config_foreach system_config system
if [ "$1" = "S" -a "$foreground" != "1" ]; then
run_scripts "$1" "$2" &
else
run_scripts "$1" "$2"
fi
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
ttyS0::askfirst:/bin/ash --login
tty1::askfirst:/bin/ash --login
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
pi_ifname=
pi_ip=192.168.1.1
pi_broadcast=192.168.1.255
pi_netmask=255.255.255.0
fs_failsafe_ifname=
fs_failsafe_ip=192.168.1.1
fs_failsafe_broadcast=192.168.1.255
fs_failsafe_netmask=255.255.255.0
fs_failsafe_wait_timeout=2
pi_suppress_stderr="y"
pi_init_suppress_stderr="y"
pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin"
pi_init_cmd="/sbin/init"
. /lib/functions.sh
boot_hook_init preinit_essential
boot_hook_init preinit_main
boot_hook_init failsafe
boot_hook_init initramfs
boot_hook_init preinit_mount_root
for pi_source_file in /lib/preinit/*; do
. $pi_source_file
done
boot_run_hook preinit_essential
pi_mount_skip_next=false
pi_jffs2_mount_success=false
pi_failsafe_net_message=false
boot_run_hook preinit_main
#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2011 OpenWrt.org
START=97
start() {
[ -c /dev/watchdog ] || return 1
[ -x /sbin/watchdog ] || return 1
service_start /sbin/watchdog -t 5 /dev/watchdog
}
stop() {
service_stop /sbin/watchdog
}
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
INITRAMFS=1
. /etc/preinit
set_state init
echo "- init -"
[ -n "$SWITCH_ROOT_TMPFS" ] && {
mount -o noatime none /mnt -t tmpfs
( cd /; find -xdev -type d ) | ( cd /mnt; xargs mkdir -p )
find / \! -type d -xdev | tar -cT /proc/self/fd/0 | tar -xC /mnt
mkdir /mnt/proc /mnt/dev /mnt/tmp /mnt/sys
mount -o noatime,move /proc /mnt/proc
mount -o noatime,move /dev /mnt/dev
mount -o noatime,move /tmp /mnt/tmp
mount -o noatime,move /sys /mnt/sys
rm -rf /proc /dev /tmp /sys
exec switch_root -c /dev/console /mnt /sbin/init
}
# if we have no root parameter, just go to running from ramfs
[ -z $rootfs ] && {
export NOMOUNT="No Root"
exec /sbin/init
}
#if we have a failsafe boot selected, dont bother
#trying to find or wait for a root mount point
[ -z "$FAILSAFE" ] || {
exec /bin/busybox init
}
# Load the modules we have in initramfs, this should
# make the media accessible, but, it may take some time
. /lib/functions.sh
load_modules /etc/modules /etc/modules.d/*
#wait 10 seconds for the disc to show up
#usb stick typically takes 4 to 6 seconds
#till it's readable
#it's quite possible the disc never shows up
#if we netbooted this kernel
COUNTER=0
while [ $COUNTER -lt 10 ]; do
sleep 1
[ -e $rootfs ] && let COUNTER=10;
let COUNTER=COUNTER+1
done
[ -e $rootfs ] || {
export FAILSAFE="NoDisc"
exec /bin/busybox init
}
# now we'll try mount it, again with a timeout
# This will fail if the inserted stick is formatted
# in a manner we dont understand
COUNTER=0
while [ $COUNTER -lt 10 ]; do
sleep 1
mount -o noatime $rootfs /mnt
[ $? -eq "0" ] && let COUNTER=100;
let COUNTER=COUNTER+1
done
[ $? -ne "0" ] && {
export FAILSAFE="MountFail"
exec /bin/busybox init
}
#It mounted, lets look for a postinit file, again, give it time
#I've seen this take 6 seconds to actually complete
COUNTER=0
while [ $COUNTER -lt 10 ]; do
sleep 1
[ -e /mnt/etc/banner ] && let COUNTER=10;
let COUNTER=COUNTER+1
done
[ -e /mnt/etc/banner ] || {
export FAILSAFE="No Openwrt FS"
exec /bin/busybox init
}
unset rootfs
mount -o noatime,move /proc /mnt/proc
mount -o noatime,move /dev /mnt/dev
mount -o noatime,move /dev/pts /mnt/dev/pts
mount -o noatime,move /tmp /mnt/tmp
mount -o noatime,move /sys /mnt/sys
mount -o noatime none /tmp -t tmpfs
killall -q hotplug2
exec switch_root -c /dev/console /mnt /sbin/init
set_state done
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
with_fo_cleanup() {
# try to get rid of /tmp/root
# this will almost always fail
umount /tmp/root 2>&-
grep -q overlay /proc/filesystems && {
cd /
(
cd /overlay
find -type l
) | while read FILE; do
[ -z "$FILE" ] && break
if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then
rm -f "$FILE"
fi
done
}
exit 0
}
boot_hook_add switch2jffs with_fo_cleanup
#!/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_led() {
set_state preinit
}
pi_indicate_preinit() {
echo "- preinit -"
preinit_net_echo "Doing OpenWRT Preinit\n"
pi_indicate_led
}
boot_hook_add preinit_main preinit_ip
boot_hook_add preinit_main pi_indicate_preinit
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
indicate_regular_preinit() {
echo "- regular preinit -"
preinit_net_echo "Continuing with Regular Preinit\n"
pi_indicate_led
}
boot_hook_add preinit_main indicate_regular_preinit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment