summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kconfig/rootfs/rootfs.kconfig1
-rw-r--r--mk/rootfs/README.busybox.inittab6
-rw-r--r--mk/rootfs/openrc/etc/defaultdomain0
-rw-r--r--mk/rootfs/openrc/etc/init.d/bootmisc215
-rw-r--r--mk/rootfs/openrc/etc/init.d/devfs32
-rw-r--r--mk/rootfs/openrc/etc/init.d/dmesg17
-rw-r--r--mk/rootfs/openrc/etc/init.d/hostname15
-rw-r--r--mk/rootfs/openrc/etc/init.d/killprocs17
-rw-r--r--mk/rootfs/openrc/etc/init.d/loopback30
-rw-r--r--mk/rootfs/openrc/etc/init.d/modules57
-rw-r--r--mk/rootfs/openrc/etc/init.d/mtab35
-rw-r--r--mk/rootfs/openrc/etc/init.d/netmount82
-rw-r--r--mk/rootfs/openrc/etc/init.d/network350
-rw-r--r--mk/rootfs/openrc/etc/init.d/procfs71
-rw-r--r--mk/rootfs/openrc/etc/init.d/root42
-rw-r--r--mk/rootfs/openrc/etc/init.d/staticroute103
-rw-r--r--mk/rootfs/openrc/etc/init.d/sysctl28
-rw-r--r--mk/rootfs/openrc/etc/init.d/sysfs131
-rw-r--r--mk/rootfs/openrc/etc/init.d/urandom39
-rw-r--r--mk/rootfs/openrc/etc/rc.conf0
l---------mk/rootfs/openrc/etc/runlevels/shutdown/killprocs1
-rw-r--r--mk/rootfs/openrc/openrc.mk39
-rw-r--r--mk/rootfs/rootfs.mk4
-rw-r--r--src/rootfs_skel/etc/conf.d/.empty0
-rw-r--r--src/rootfs_skel/etc/fstab5
-rw-r--r--src/rootfs_skel/etc/group1
-rw-r--r--src/rootfs_skel/etc/init.d/.empty0
-rwxr-xr-xsrc/rootfs_skel/etc/init.d/S20urandom54
-rwxr-xr-xsrc/rootfs_skel/etc/init.d/S40network25
-rwxr-xr-xsrc/rootfs_skel/etc/init.d/rcS27
-rw-r--r--src/rootfs_skel/etc/inittab30
-rw-r--r--src/rootfs_skel/etc/local.d/.empty0
-rw-r--r--src/rootfs_skel/etc/passwd1
-rw-r--r--src/rootfs_skel/etc/runlevels/.empty0
-rw-r--r--src/rootfs_skel/etc/sysctl.d/.empty0
l---------src/rootfs_skel/run2
36 files changed, 1322 insertions, 138 deletions
diff --git a/kconfig/rootfs/rootfs.kconfig b/kconfig/rootfs/rootfs.kconfig
index 07b88a9..9cc00bd 100644
--- a/kconfig/rootfs/rootfs.kconfig
+++ b/kconfig/rootfs/rootfs.kconfig
@@ -23,6 +23,7 @@
# \date December 2013
################################################################################
+source "kconfig/rootfs/openrc.kconfig"
source "kconfig/rootfs/fs.kconfig"
source "kconfig/mtdutils.kconfig"
source "kconfig/squashfs.kconfig"
diff --git a/mk/rootfs/README.busybox.inittab b/mk/rootfs/README.busybox.inittab
new file mode 100644
index 0000000..b9eb1e9
--- /dev/null
+++ b/mk/rootfs/README.busybox.inittab
@@ -0,0 +1,6 @@
+# Format for each entry: <id>:<runlevels>:<action>:<process>
+#
+# id == tty to run on, or empty for /dev/console
+# runlevels == ignored
+# action == one of sysinit, respawn, askfirst, wait, and once
+# process == program to run
diff --git a/mk/rootfs/openrc/etc/defaultdomain b/mk/rootfs/openrc/etc/defaultdomain
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mk/rootfs/openrc/etc/defaultdomain
diff --git a/mk/rootfs/openrc/etc/init.d/bootmisc b/mk/rootfs/openrc/etc/init.d/bootmisc
new file mode 100644
index 0000000..e66824d
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/bootmisc
@@ -0,0 +1,215 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+depend()
+{
+ after root sysctl
+ keyword -timeout
+}
+
+: ${wipe_tmp:=${WIPE_TMP:-yes}}
+: ${log_dmesg:=${LOG_DMESG:-yes}}
+
+cleanup_tmp_dir()
+{
+ local dir="$1"
+
+ if ! [ -d "$dir" ]; then
+ mkdir -p "$dir" || return $?
+ fi
+ checkpath -W "$dir" || return 1
+ chmod a+rwt "$dir" 2> /dev/null
+ cd "$dir" || return 1
+ if yesno $wipe_tmp; then
+ ebegin "Wiping $dir directory"
+
+ # Faster than raw find
+ if ! rm -rf -- [!ajlq\.]* 2>/dev/null ; then
+ # Blah, too many files
+ find . -maxdepth 1 -name '[!ajlq\.]*' -exec rm -rf -- {} +
+ fi
+
+ # pam_mktemp creates a .private directory within which
+ # each user gets a private directory with immutable
+ # bit set; remove the immutable bit before trying to
+ # remove it.
+ [ -d /tmp/.private ] && chattr -R -a /tmp/.private 2> /dev/null
+
+ # Prune the paths that are left
+ find . -maxdepth 1 \
+ ! -name . \
+ ! -name lost+found \
+ ! -name quota.user \
+ ! -name aquota.user \
+ ! -name quota.group \
+ ! -name aquota.group \
+ ! -name journal \
+ -exec rm -rf -- {} +
+ eend 0
+ else
+ ebegin "Cleaning $dir directory"
+ rm -rf -- .X*-lock esrv* kio* \
+ jpsock.* .fam* .esd* \
+ orbit-* ssh-* ksocket-* \
+ .*-unix
+ eend 0
+ fi
+}
+
+cleanup_var_run_dir()
+{
+ ebegin "Cleaning /var/run"
+ for x in $(find /var/run ! -type d ! -name utmp \
+ ! -name random-seed ! -name dev.db \
+ ! -name ld-elf.so.hints ! -name ld.so.hints);
+ do
+ # Clean stale sockets
+ if [ -S "$x" ]; then
+ if command -v fuser >/dev/null 2>&1; then
+ fuser "$x" >/dev/null 2>&1 || rm -- "$x"
+ else
+ rm -- "$x"
+ fi
+ fi
+ [ ! -f "$x" ] && continue
+ # Do not remove pidfiles of already running daemons
+ case "$x" in
+ *.pid)
+ start-stop-daemon --test --quiet \
+ --stop --pidfile "$x" && continue
+ ;;
+ esac
+ rm -f -- "$x"
+ done
+ eend 0
+}
+
+mkutmp()
+{
+ : >"$1"
+ # Not all systems have the utmp group
+ chgrp utmp "$1" 2>/dev/null
+ chmod 0664 "$1"
+}
+
+migrate_to_run()
+{
+ src="$1"
+ dst="$2"
+ if [ -L $src -a "$(readlink -f $src)" != $dst ]; then
+ ewarn "$src does not point to $dst."
+ ewarn "Setting $src to point to $dst."
+ rm $src
+ elif [ ! -L $src -a -d $src ]; then
+ ebegin "Migrating $src to $dst"
+ cp -a $src/* $dst/
+ rm -rf $src
+ eend $?
+ fi
+ # If $src doesn't exist at all, just run this
+ if [ ! -e $src ]; then
+ ln -s $dst $src
+ fi
+}
+
+clean_run()
+{
+ [ "$RC_SYS" = VSERVER ] && return 0
+ local dir
+ dir=$(mktemp -d)
+ mount --bind / $dir
+ rm -rf $dir/run/*
+ umount $dir
+ rm -rf $dir
+}
+
+start()
+{
+ # Remove any added console dirs
+ rm -rf "$RC_LIBEXECDIR"/console/*
+
+ local logw=false runw=false extra=
+ # Ensure that our basic dirs exist
+ if [ "$RC_UNAME" = Linux ]; then
+ # Satisfy Linux FHS
+ extra=/var/lib/misc
+ if [ ! -d /run ]; then
+ extra="/var/run $extra"
+ fi
+ else
+ extra=/var/run
+ fi
+ for x in /var/log /tmp $extra; do
+ if ! [ -d $x ]; then
+ if ! mkdir -p $x; then
+ eend 1 "failed to create needed directory $x"
+ return 1
+ fi
+ fi
+ done
+
+ if [ "$RC_UNAME" = Linux -a -d /run ]; then
+ migrate_to_run /var/lock /run/lock
+ migrate_to_run /var/run /run
+ clean_run
+ fi
+
+ if checkpath -W /var/run; then
+ ebegin "Creating user login records"
+ local xtra=
+ [ "$RC_UNAME" = NetBSD ] && xtra=x
+ for x in "" $xtra; do
+ mkutmp /var/run/utmp$x
+ done
+ [ -e /var/log/wtmp ] || mkutmp /var/log/wtmp
+ eend 0
+
+ mountinfo -q -f tmpfs /var/run || cleanup_var_run_dir
+ fi
+
+ # Clean up /tmp directories
+ local tmp=
+ for tmp in ${clean_tmp_dirs:-${wipe_tmp_dirs-/tmp}}; do
+ mountinfo -q -f tmpfs "$tmp" || cleanup_tmp_dir "$tmp"
+ done
+
+ if checkpath -W /tmp; then
+ # Make sure our X11 stuff have the correct permissions
+ # Omit the chown as bootmisc is run before network is up
+ # and users may be using lame LDAP auth #139411
+ rm -rf /tmp/.ICE-unix /tmp/.X11-unix
+ mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
+ chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
+ if [ -x /sbin/restorecon ]; then
+ restorecon /tmp/.ICE-unix /tmp/.X11-unix
+ fi
+ fi
+
+ if yesno $log_dmesg; then
+ if $logw || checkpath -W /var/log; then
+ # Create an 'after-boot' dmesg log
+ if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ -a "$RC_SYS" != LXC ]; then
+ dmesg > /var/log/dmesg
+ chmod 640 /var/log/dmesg
+ fi
+ fi
+ fi
+
+ return 0
+}
+
+stop()
+{
+ # Write a halt record if we're shutting down
+ if [ "$RC_RUNLEVEL" = shutdown ]; then
+ [ "$RC_UNAME" = Linux ] && halt -w
+ if [ "$RC_SYS" = OPENVZ ]; then
+ yesno $RC_REBOOT && printf "" >/reboot
+ fi
+ fi
+
+ return 0
+}
+
+# vim: ft=sh
diff --git a/mk/rootfs/openrc/etc/init.d/devfs b/mk/rootfs/openrc/etc/init.d/devfs
new file mode 100644
index 0000000..bfcb644
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/devfs
@@ -0,0 +1,32 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Mount system critical filesystems in /dev."
+
+start() {
+ # Mount required stuff as user may not have then in /etc/fstab
+ for x in \
+ "mqueue /dev/mqueue 1777 ,nodev mqueue" \
+ "devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" \
+ "tmpfs /dev/shm 1777 ,nodev shm" \
+ ; do
+ set -- $x
+ grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue
+ mountinfo -q $2 && continue
+
+ if [ ! -d $2 ]; then
+ mkdir -m $3 -p $2 >/dev/null 2>&1 || \
+ ewarn "Could not create $2!"
+ fi
+
+ if [ -d $2 ]; then
+ ebegin "Mounting $2"
+ if ! fstabinfo --mount $2; then
+ mount -n -t $1 -o noexec,nosuid$4 $5 $2
+ fi
+ eend $?
+ fi
+ done
+ return 0
+}
diff --git a/mk/rootfs/openrc/etc/init.d/dmesg b/mk/rootfs/openrc/etc/init.d/dmesg
new file mode 100644
index 0000000..34d77bd
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/dmesg
@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Set the dmesg level for a cleaner boot"
+
+depend()
+{
+ before modules
+}
+
+start()
+{
+ if [ -n "$dmesg_level" ]; then
+ dmesg -n$dmesg_level
+ fi
+}
diff --git a/mk/rootfs/openrc/etc/init.d/hostname b/mk/rootfs/openrc/etc/init.d/hostname
new file mode 100644
index 0000000..34acbf8
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/hostname
@@ -0,0 +1,15 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Sets the hostname of the machine."
+
+start()
+{
+ # HOSTNAME variable used to be defined in caps in conf.d/hostname.
+ # It is also a magic variable in bash.
+ hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
+ ebegin "Setting hostname to $hostname"
+ hostname "$hostname"
+ eend $? "Failed to set the hostname"
+}
diff --git a/mk/rootfs/openrc/etc/init.d/killprocs b/mk/rootfs/openrc/etc/init.d/killprocs
new file mode 100644
index 0000000..6c1fa18
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/killprocs
@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Kill all processes so we can unmount disks cleanly."
+
+start()
+{
+ ebegin "Terminating remaining processes"
+ killall5 -15 ${killall5_opts}
+ sleep 1
+ eend 0
+ ebegin "Killing remaining processes"
+ killall5 -9 ${killall5_opts}
+ sleep 1
+ eend 0
+}
diff --git a/mk/rootfs/openrc/etc/init.d/loopback b/mk/rootfs/openrc/etc/init.d/loopback
new file mode 100644
index 0000000..a4dde55
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/loopback
@@ -0,0 +1,30 @@
+#!/sbin/openrc-run
+# Copyright (c) 2013 William Hubbs <w.d.hubbs@gmail.com>
+# Released under the 2-clause BSD license.
+
+description="Configures the loopback interface."
+
+start()
+{
+ if [ "$RC_UNAME" = Linux ]; then
+ ebegin "Bringing up network interface lo"
+ if command -v ip > /dev/null 2>&1; then
+ ip addr add 127.0.0.1/8 dev lo brd + scope host 2>/dev/null
+ ip route add 127.0.0.0/8 dev lo scope host 2>/dev/null
+ ip link set lo up
+ else
+ ifconfig lo 127.0.0.1 netmask 255.0.0.0
+ route add -net 127.0.0.0 netmask 255.0.0.0 gw 127.0.0.1
+ fi
+ else
+ ebegin "Bringing up network interface lo0"
+ ifconfig lo0 127.0.0.1 netmask 255.0.0.0
+ route -q add -inet 127.0.0.0 -netmask 255.0.0.0 127.0.0.1
+ fi
+ eend $?
+}
+
+stop()
+{
+ return 0
+}
diff --git a/mk/rootfs/openrc/etc/init.d/modules b/mk/rootfs/openrc/etc/init.d/modules
new file mode 100644
index 0000000..5daf554
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/modules
@@ -0,0 +1,57 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Loads a user defined list of kernel modules."
+
+start()
+{
+ # Should not fail if kernel do not have module
+ # support compiled in ...
+ [ ! -f /proc/modules ] && return 0
+
+ local KV x y kv_variant_list
+ KV=$(uname -r)
+ # full $KV
+ kv_variant_list="${KV}"
+ # remove any KV_EXTRA options to just get the full version
+ x=${KV%%-*}
+ # now slowly strip them
+ while [ -n "$x" ] && [ "$x" != "$y" ]; do
+ kv_variant_list="${kv_variant_list} $x"
+ y=$x
+ x=${x%.*}
+ done
+
+ local list= x= xx= y= args= mpargs= cnt=0 a=
+ for x in $kv_variant_list ; do
+ eval list=\$modules_$(shell_var "$x")
+ [ -n "$list" ] && break
+ done
+ [ -z "$list" ] && list=$modules
+
+ for x in $list; do
+ a=${x#*:}
+ if [ "$a" = "$x" ]; then
+ unset mpargs
+ ebegin "Loading module $x"
+ else
+ x=${x%%:*}
+ mpargs="-o $a"
+ ebegin "Loading module $x as $a"
+ fi
+ aa=$(shell_var "$a")
+ xx=$(shell_var "$x")
+ for y in $kv_variant_list ; do
+ eval args=\$module_${aa}_args_$(shell_var "$y")
+ [ -n "${args}" ] && break
+ eval args=\$module_${xx}_args_$(shell_var "$y")
+ [ -n "${args}" ] && break
+ done
+ [ -z "$args" ] && eval args=\$module_${aa}_args
+ [ -z "$args" ] && eval args=\$module_${xx}_args
+ eval modprobe -q "$mpargs" "$x" "$args"
+ eend $? "Failed to load $x" && : $(( cnt += 1 ))
+ done
+ einfo "Autoloaded $cnt module(s)"
+}
diff --git a/mk/rootfs/openrc/etc/init.d/mtab b/mk/rootfs/openrc/etc/init.d/mtab
new file mode 100644
index 0000000..21dbae2
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/mtab
@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Update /etc/mtab to match what the kernel knows about"
+
+depend()
+{
+ need root
+}
+
+start()
+{
+ if [ -L /etc/mtab ]
+ then
+ einfo "Skipping mtab update (mtab is a symbolic link)"
+ return 0
+ fi
+
+ ebegin "Updating /etc/mtab"
+ if ! echo 2>/dev/null >/etc/mtab; then
+ ewend 1 "/etc/mtab is not updateable"
+ return 0
+ fi
+
+ # With / as tmpfs we cannot umount -at tmpfs in localmount as that
+ # makes / readonly and dismounts all tmpfs even if in use which is
+ # not good. Luckily, umount uses /etc/mtab instead of /proc/mounts
+ # which allows this hack to work.
+ grep -v "^[! ]* / tmpfs " /proc/mounts > /etc/mtab
+
+ # Remove stale backups
+ rm -f /etc/mtab~ /etc/mtab~~
+ eend 0
+}
diff --git a/mk/rootfs/openrc/etc/init.d/netmount b/mk/rootfs/openrc/etc/init.d/netmount
new file mode 100644
index 0000000..0f3757d
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/netmount
@@ -0,0 +1,82 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Mounts network shares, other than NFS, according to /etc/fstab."
+# We skip all NFS shares in this script because they require extra
+# daemons to be running on the client in order to work correctly.
+# It is best to allow nfs-utils to handle all nfs shares.
+
+depend()
+{
+ config /etc/fstab
+ use dns
+}
+
+start()
+{
+ local x= fs= rc=
+ for x in $net_fs_list $extra_net_fs_list; do
+ case "$x" in
+ nfs|nfs4)
+ continue
+ ;;
+ esac
+ fs="$fs${fs:+,}$x"
+ done
+
+ ebegin "Mounting network filesystems"
+ mount -at $fs
+ rc=$?
+ if [ "$RC_UNAME" = Linux ]; then
+ mount -a -O _netdev
+ rc=$?
+ fi
+ ewend $rc "Could not mount all network filesystems"
+ return 0
+}
+
+stop()
+{
+ local x= fs=
+
+ ebegin "Unmounting network filesystems"
+ . "$RC_LIBEXECDIR"/sh/rc-mount.sh
+
+ for x in $net_fs_list $extra_net_fs_list; do
+ case "$x" in
+ nfs|nfs4)
+ continue
+ ;;
+ *)
+ fs="$fs${fs:+,}$x"
+ ;;
+ esac
+ done
+ if [ -n "$fs" ]; then
+ umount -at $fs || eerror "Failed to simply unmount filesystems"
+ fi
+
+ eindent
+ fs=
+ for x in $net_fs_list $extra_net_fs_list; do
+ case "$x" in
+ nfs|nfs4)
+ continue
+ ;;
+ *)
+ fs="$fs${fs:+|}$x"
+ ;;
+ esac
+ done
+ [ -n "$fs" ] && fs="^($fs)$"
+ do_unmount umount ${fs:+--fstype-regex} $fs --netdev
+ retval=$?
+
+ eoutdent
+ if [ "$RC_UNAME" = Linux ]; then
+ umount -a -O _netdev
+ retval=$?
+ fi
+ eend $retval "Failed to unmount network filesystems"
+}
diff --git a/mk/rootfs/openrc/etc/init.d/network b/mk/rootfs/openrc/etc/init.d/network
new file mode 100644
index 0000000..72557b8
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/network
@@ -0,0 +1,350 @@
+#!/sbin/openrc-run
+# Copyright (c) 2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+# This script was inspired by the equivalent rc.d network from NetBSD.
+
+description="Configures network interfaces."
+__nl="
+"
+
+depend()
+{
+ if [ -n "$(interfaces)" ]; then
+ provide net
+ fi
+}
+
+uniqify()
+{
+ local result= i=
+ for i; do
+ case " $result " in
+ *" $i "*);;
+ *) result="$result $i";;
+ esac
+ done
+ echo "${result# *}"
+}
+
+reverse()
+{
+ local result= i=
+ for i; do
+ result="$i $result"
+ done
+ echo "${result# *}"
+}
+
+sys_interfaces()
+{
+ case "$RC_UNAME" in
+ Linux)
+ local w= rest= i= cmd=$1
+ while read w rest; do
+ i=${w%%:*}
+ case "$i" in
+ "$w") continue ;;
+ lo|lo0) continue ;;
+ *) ;;
+ esac
+ if [ "$cmd" = u ]; then
+ ifconfig "$i" | grep -q "[ ]*UP" || continue
+ fi
+ printf "%s " "$i"
+ done </proc/net/dev
+ ;;
+ *)
+ ifconfig -l$1
+ ;;
+ esac
+}
+
+tentative()
+{
+ local inet= address= rest=
+
+ case "$RC_UNAME" in
+ Linux)
+ [ -x /sbin/ip ] || [ -x /bin/ip ] || return 1
+ [ -n "$(ip -f inet6 addr show tentative)" ]
+ ;;
+ *)
+ local inet= address= rest=
+ LC_ALL=C ifconfig -a | while read inet address rest; do
+ case "${inet}" in
+ inet6)
+ case "${rest}" in
+ *" "tentative*) return 2;;
+ esac
+ ;;
+ esac
+ done
+ [ $? = 2 ]
+ ;;
+ esac
+}
+
+
+auto_interfaces()
+{
+ local ifs= c= f=
+
+ case "$RC_UNAME" in
+ NetBSD)
+ for c in $(ifconfig -C 2>/dev/null); do
+ for f in /etc/ifconfig.${c}[0-9]*; do
+ [ -f "$f" ] && printf "%s" "$f{##*.} "
+ done
+ done
+ ;;
+ *)
+ for f in /etc/ifconfig.*; do
+ [ -f "$f" ] && printf "%s" "${f##*.} "
+ done
+ for f in /etc/ip.*; do
+ [ -f "$f" ] && printf "%s" "${f##*.} "
+ done
+ ;;
+ esac
+ echo
+}
+
+interfaces()
+{
+ uniqify $(sys_interfaces "$@") $interfaces $(auto_interfaces)
+}
+
+dumpargs()
+{
+ local f="$1"
+
+ shift
+ case "$@" in
+ '') [ -f "$f" ] && cat "$f";;
+ *"$__nl"*) echo "$@";;
+ *)
+ (
+ set -o noglob
+ IFS=';'; set -- $@
+ IFS="$__nl"; echo "$*"
+ );;
+ esac
+}
+
+intup=false
+runip()
+{
+ local int="$1" err=
+ shift
+
+ # Ensure we have a valid broadcast address
+ case "$@" in
+ *" broadcast "*|*" brd "*) ;;
+ *:*) ;; # Ignore IPv6
+ *) set -- "$@" brd +;;
+ esac
+
+ err=$(LC_ALL=C ip address add "$@" dev "$int" 2>&1)
+ if [ -z "$err" ]; then
+ # ip does not bring up the interface when adding addresses
+ if ! $intup; then
+ ip link set "$int" up
+ intup=true
+ fi
+ return 0
+ fi
+ if [ "$err" = "RTNETLINK answers: File exists" ]; then
+ ip address del "$@" dev "$int" 2>/dev/null
+ fi
+ # Localise the error
+ ip address add "$@" dev "$int"
+}
+
+routeflush()
+{
+ if [ "$RC_UNAME" = Linux ]; then
+ if [ -x /sbin/ip ] || [ -x /bin/ip ]; then
+ ip route flush scope global
+ ip route delete default 2>/dev/null
+ else
+ # Sadly we also delete some link routes, but
+ # this cannot be helped
+ local dest= gate= net= flags= rest=
+ route -n | while read dest gate net flags rest; do
+ [ -z "$net" ] && continue
+ case "$dest" in
+ [0-9]*) ;;
+ *) continue;;
+ esac
+ local xtra= netmask="netmask $net"
+ case "$flags" in
+ U) continue;;
+ *H*) flags=-host; netmask=;;
+ *!*) flags=-net; xtra=reject;;
+ *) flags=-net;;
+ esac
+ route del $flags $dest $netmask $xtra
+ done
+ # Erase any default dev eth0 routes
+ route del default 2>/dev/null
+ fi
+ else
+ route -qn flush
+ fi
+}
+
+runargs()
+{
+ dumpargs "$@" | while read -r args; do
+ case "$args" in
+ ''|"#"*) ;;
+ *)
+ (
+ eval vebegin "${args#*!}"
+ eval "${args#*!}"
+ veend $?
+ );;
+ esac
+ done
+}
+
+start()
+{
+ local cr=0 r= int= intv= cmd= args= upcmd=
+
+ if [ -z "$domainname" -a -s /etc/defaultdomain ]; then
+ domainname=$(cat /etc/defaultdomain)
+ fi
+ if [ -n "$domainname" ]; then
+ ebegin "Setting NIS domainname: $domainname"
+ domainname "$domainname"
+ eend $?
+ fi
+
+ einfo "Starting network"
+ routeflush
+ eindent
+ for int in $(interfaces); do
+ local func= cf=
+ intv=$(shell_var "$int")
+ eval upcmd=\$ifup_$intv
+ for func in ip ifconfig; do
+ eval cmd=\$${func}_$intv
+ if [ -n "$cmd" -o -f /etc/"$func.$int" ]; then
+ cf=/etc/"$func.$int"
+ break
+ fi
+ done
+ [ -n "$cf" -o -n "$upcmd" -o \
+ -f /etc/ifup."$int" -o -f "$cf" ] || continue
+ veinfo "$int"
+ case "$func" in
+ ip) func=runip; intup=false;;
+ esac
+ eindent
+ runargs /etc/ifup."$int" "$upcmd"
+ r=0
+ dumpargs "$cf" "$cmd" | while read -r args; do
+ case "$args" in
+ ''|"#"*) ;;
+ "!"*)
+ (
+ eval vebegin "${args#*!}"
+ eval "${args#*!}"
+ veend $?
+ );;
+ *)
+ (
+ set -o noglob
+ eval set -- "$args"
+ vebegin "$@"
+ $func "$int" "$@"
+ veend $?
+ );;
+ esac
+ done
+ eoutdent
+ done
+ eoutdent
+ eend $cr
+
+ # Wait for any inet6 tentative addresses
+ r=5
+ while [ $r -gt 0 ]; do
+ tentative || break
+ [ $r = 5 ] && vebegin "Waiting for tentative addresses"
+ sleep 1
+ : $(( r -= 1 ))
+ done
+ if [ $r != 5 ]; then
+ [ $r != 0 ]
+ veend $?
+ fi
+
+ if [ -n "$defaultroute" ]; then
+ ebegin "Setting default route $defaultroute"
+ route add default $defaultroute
+ eend $?
+ elif [ -n "$defaultiproute" ]; then
+ ebegin "Setting default route $defaultiproute"
+ ip route add default $defaultiproute
+ eend $?
+ fi
+
+ if [ -n "$defaultroute6" ]; then
+ ebegin "Setting default route $defaultroute6"
+ if [ "$RC_UNAME" = Linux ]; then
+ routecmd="route -A inet6 add"
+ else
+ routecmd="route -inet6 add"
+ fi
+ $routecmd default $defaultroute6
+ eend $?
+ elif [ -n "$defaultiproute6" ]; then
+ ebegin "Setting default route $defaultiproute6"
+ ip -f inet6 route add default $defaultiproute6
+ eend $?
+ fi
+
+ return 0
+}
+
+stop()
+{
+ # Don't stop the network at shutdown.
+ # We don't use the noshutdown keyword so that we are started again
+ # correctly if we go back to multiuser.
+ yesno ${keep_network:-YES} && yesno $RC_GOINGDOWN && return 0
+
+ local int= intv= cmd= downcmd= r=
+ einfo "Stopping network"
+ routeflush
+ eindent
+ for int in $(reverse $(interfaces u)); do
+ case "$int" in
+ lo|lo0) continue ;;
+ *) ;;
+ esac
+ intv=$(shell_var "$int")
+ eval downcmd=\$ifdown_$intv
+ eval cmd=\$ip_$intv
+ [ -z "$cmd" ] && eval cmd=\$ifconfig_$intv
+ if [ -n "$cmd" -o -f /etc/ip."$int" -o \
+ -f /etc/ifconfig."$int" -o \
+ -n "$downcmd" -o -f /etc/ifdown."$int" ];
+ then
+ veinfo "$int"
+ runargs /etc/ifdown."$int" "$downcmd"
+ if [ -x /sbin/ip ] || [ -x /bin/ip ]; then
+ # We need to do this, otherwise we may
+ # fail to add things correctly on restart
+ ip address flush dev "$int" 2>/dev/null
+ fi
+ ifconfig "$int" down 2>/dev/null
+ ifconfig "$int" destroy 2>/dev/null
+ fi
+ done
+ eoutdent
+ eend 0
+}
diff --git a/mk/rootfs/openrc/etc/init.d/procfs b/mk/rootfs/openrc/etc/init.d/procfs
new file mode 100644
index 0000000..8837750
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/procfs
@@ -0,0 +1,71 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Mounts misc filesystems in /proc."
+
+depend()
+{
+ use modules devfs
+}
+
+start()
+{
+ # Make sure we insert usbcore if it's a module
+ if [ -f /proc/modules -a ! -d /sys/module/usbcore -a ! -d /proc/bus/usb ]; then
+ modprobe -q usbcore
+ fi
+
+ [ -e /proc/filesystems ] || return 0
+
+ # Setup Kernel Support for miscellaneous Binary Formats
+ if [ -d /proc/sys/fs/binfmt_misc -a ! -e /proc/sys/fs/binfmt_misc/register ]; then
+ if grep -qs binfmt_misc /proc/filesystems; then
+ ebegin "Mounting misc binary format filesystem"
+ mount -t binfmt_misc -o nodev,noexec,nosuid \
+ binfmt_misc /proc/sys/fs/binfmt_misc
+ if eend $? ; then
+ local fmts
+ ebegin "Loading custom binary format handlers"
+ fmts=$(grep -hsv -e '^[#;]' -e '^[[:space:]]*$' \
+ /run/binfmt.d/*.conf \
+ /etc/binfmt.d/*.conf \
+ ""/usr/lib/binfmt.d/*.conf)
+ if [ -n "${fmts}" ]; then
+ echo "${fmts}" > /proc/sys/fs/binfmt_misc/register
+ fi
+ eend $?
+ fi
+ fi
+ fi
+
+ [ "$RC_SYS" = "OPENVZ" ] && return 0
+
+ # Check what USB fs the kernel support. Currently
+ # 2.5+ kernels, and later 2.4 kernels have 'usbfs',
+ # while older kernels have 'usbdevfs'.
+ if [ -d /proc/bus/usb -a ! -e /proc/bus/usb/devices ]; then
+ local usbfs=$(grep -Fow usbfs /proc/filesystems ||
+ grep -Fow usbdevfs /proc/filesystems)
+ if [ -n "$usbfs" ]; then
+ ebegin "Mounting USB device filesystem [$usbfs]"
+ local usbgid="$(getent group usb | \
+ sed -e 's/.*:.*:\(.*\):.*/\1/')"
+ mount -t $usbfs \
+ -o ${usbgid:+devmode=0664,devgid=$usbgid,}noexec,nosuid \
+ usbfs /proc/bus/usb
+ eend $?
+ fi
+ fi
+
+ # Setup Kernel Support for SELinux
+ if [ -d /selinux ] && ! mountinfo -q /selinux; then
+ if grep -qs selinuxfs /proc/filesystems; then
+ ebegin "Mounting SELinux filesystem"
+ mount -t selinuxfs selinuxfs /selinux
+ eend $?
+ fi
+ fi
+
+ return 0
+}
diff --git a/mk/rootfs/openrc/etc/init.d/root b/mk/rootfs/openrc/etc/init.d/root
new file mode 100644
index 0000000..973ef1d
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/root
@@ -0,0 +1,42 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Mount the root fs read/write"
+
+start()
+{
+ case ",$(fstabinfo -o /)," in
+ *,ro,*)
+ ;;
+ *)
+ # Check if the rootfs isn't already writable.
+ if ! checkpath -W /; then
+ ebegin "Remounting root filesystem read/write"
+ case "$RC_UNAME" in
+ Linux)
+ mount -n -o remount,rw /
+ ;;
+ *)
+ mount -u -o rw /
+ ;;
+ esac
+ eend $? "Root filesystem could not be mounted read/write"
+ fi
+ ;;
+ esac
+
+ ebegin "Remounting filesystems"
+ local mountpoint
+ for mountpoint in $(fstabinfo); do
+ case "${mountpoint}" in
+ /)
+ ;;
+ /*)
+ mountinfo -q "${mountpoint}" && \
+ fstabinfo --remount "${mountpoint}"
+ ;;
+ esac
+ done
+ eend 0
+}
diff --git a/mk/rootfs/openrc/etc/init.d/staticroute b/mk/rootfs/openrc/etc/init.d/staticroute
new file mode 100644
index 0000000..76d46fa
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/staticroute
@@ -0,0 +1,103 @@
+#!/sbin/openrc-run
+# Copyright (c) 2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+# This script was inspired by the equivalent rc.d staticroute from NetBSD.
+
+description="Configures static routes."
+__nl="
+"
+
+depend()
+{
+ provide net
+ use network
+}
+
+pre_flight_checks()
+{
+ route=route
+ [ -s /etc/route.conf ] && return 0
+
+ if [ -n "$staticiproute" ]; then
+ route="ip route"
+ staticroute="$staticiproute"
+ fi
+}
+
+dump_args()
+{
+ # Route configuration file, as used by the NetBSD RC system
+ if [ -s /etc/route.conf ]; then
+ cat /etc/route.conf
+ return $?
+ fi
+
+ case "$staticroute" in
+ *"$__nl"*)
+ echo "$staticroute"
+ ;;
+ *)
+ (
+ set -o noglob
+ IFS=';'; set -- $staticroute
+ IFS="$__nl"; echo "$*"
+ )
+ ;;
+ esac
+}
+
+do_routes()
+{
+ local xtra= family=
+ [ "$RC_UNAME" != Linux ] && xtra=-q
+
+ ebegin "$1 static routes"
+ eindent
+ pre_flight_checks
+ dump_args | while read args; do
+ [ -z "$args" ] && continue
+ case "$args" in
+ "#"*)
+ ;;
+ "+"*)
+ [ $2 = "add" ] && eval ${args#*+}
+ ;;
+ "-"*)
+ [ $2 = "del" -o $2 = "delete" ] && eval ${args#*-}
+ ;;
+ *)
+ veinfo "$args"
+ case "$route" in
+ "ip route")
+ ip route $2 $args
+ ;;
+ *)
+ # Linux route does cannot work it out ...
+ if [ "$RC_UNAME" = Linux ]; then
+ case "$args" in
+ *:*) family="-A inet6";;
+ *) family=;;
+ esac
+ fi
+ route $family $xtra $2 -$args
+ ;;
+ esac
+ veend $?
+ esac
+ done
+ eoutdent
+ eend 0
+}
+
+start()
+{
+ do_routes "Adding" "add"
+}
+
+stop()
+{
+ local cmd="delete"
+ [ "$RC_UNAME" = Linux ] && cmd="del"
+ do_routes "Deleting" "$cmd"
+}
diff --git a/mk/rootfs/openrc/etc/init.d/sysctl b/mk/rootfs/openrc/etc/init.d/sysctl
new file mode 100644
index 0000000..a9faf59
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/sysctl
@@ -0,0 +1,28 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+start()
+{
+ local conf= retval=0 err errs
+
+ ebegin "Configuring kernel parameters"
+ eindent
+
+ for conf in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
+ if [ -r "$conf" ]; then
+ vebegin "applying $conf"
+ if ! err=$(sysctl -p "$conf" 2>&1 >/dev/null) ; then
+ errs="${errs} ${err}"
+ sysctl -e -p "${conf}" >/dev/null
+ fi
+ veend $? || retval=1
+ fi
+ done
+
+ eoutdent
+ if [ ${retval} -eq 0 ] && [ -n "${errs}" ] ; then
+ ewarn "Unknown keys:${errs}"
+ fi
+ eend $retval "Some errors were encountered: ${errs}"
+}
diff --git a/mk/rootfs/openrc/etc/init.d/sysfs b/mk/rootfs/openrc/etc/init.d/sysfs
new file mode 100644
index 0000000..8a0f794
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/sysfs
@@ -0,0 +1,131 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+description="Mount the sys filesystem."
+
+sysfs_opts=nodev,noexec,nosuid
+
+mount_sys()
+{
+ grep -Eq "[[:space:]]+sysfs$" /proc/filesystems || return 1
+ mountinfo -q /sys && return 0
+
+ if [ ! -d /sys ]; then
+ if ! mkdir -m 0755 /sys; then
+ ewarn "Could not create /sys!"
+ return 1
+ fi
+ fi
+
+ ebegin "Mounting /sys"
+ if ! fstabinfo --mount /sys; then
+ mount -n -t sysfs -o ${sysfs_opts} sysfs /sys
+ fi
+ eend $?
+}
+
+mount_misc()
+{
+ # Setup Kernel Support for securityfs
+ if [ -d /sys/kernel/security ] && \
+ ! mountinfo -q /sys/kernel/security; then
+ if grep -qs securityfs /proc/filesystems; then
+ ebegin "Mounting security filesystem"
+ mount -n -t securityfs -o ${sysfs_opts} \
+ securityfs /sys/kernel/security
+ eend $?
+ fi
+ fi
+
+ # Setup Kernel Support for debugfs
+ if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug; then
+ if grep -qs debugfs /proc/filesystems; then
+ ebegin "Mounting debug filesystem"
+ mount -n -t debugfs -o ${sysfs_opts} debugfs /sys/kernel/debug
+ eend $?
+ fi
+ fi
+
+ # Setup Kernel Support for configfs
+ if [ -d /sys/kernel/config ] && ! mountinfo -q /sys/kernel/config; then
+ if grep -qs configfs /proc/filesystems; then
+ ebegin "Mounting config filesystem"
+ mount -n -t configfs -o ${sysfs_opts} configfs /sys/kernel/config
+ eend $?
+ fi
+ fi
+
+ # set up kernel support for cgroups
+ if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
+ if grep -qs cgroup /proc/filesystems; then
+ ebegin "Mounting cgroup filesystem"
+ local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}"
+ mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
+ eend $?
+ fi
+ fi
+
+ # set up kernel support for fusectl
+ if [ -d /sys/fs/fuse/connections ] \
+ && ! mountinfo -q /sys/fs/fuse/connections; then
+ if grep -qs fusectl /proc/filesystems; then
+ ebegin "Mounting fuse control filesystem"
+ mount -n -t fusectl -o ${sysfs_opts} \
+ fusectl /sys/fs/fuse/connections
+ eend $?
+ fi
+ fi
+
+ # setup up kernel support for efivarfs
+ # slightly complicated, as if it's build as a module but NOT yet loaded,
+ # it will NOT appear in /proc/filesystems yet
+ if [ -d /sys/firmware/efi/efivars ] \
+ && ! mountinfo -q /sys/firmware/efi/efivars; then
+ modprobe -q efivarfs
+ if grep -qs efivarfs /proc/filesystems; then
+ ebegin "Mounting efivarfs filesystem"
+ mount -n -t efivarfs -o ${sysfs_opts} \
+ efivarfs /sys/firmware/efi/efivars
+ eend $?
+ fi
+ fi
+}
+
+mount_cgroups()
+{
+ mountinfo -q /sys/fs/cgroup || return 0
+
+ local agent="/usr/libexec/rc/sh/cgroup-release-agent.sh"
+ mkdir /sys/fs/cgroup/openrc
+ mount -n -t cgroup \
+ -o none,${sysfs_opts},name=openrc,release_agent="$agent" \
+ openrc /sys/fs/cgroup/openrc
+ echo 1 > /sys/fs/cgroup/openrc/notify_on_release
+
+ yesno ${rc_controller_cgroups:-YES} && [ -e /proc/cgroups ] || return 0
+ while read name hier groups enabled rest; do
+ case "${enabled}" in
+ 1) mkdir /sys/fs/cgroup/${name}
+ mount -n -t cgroup -o ${sysfs_opts},${name} \
+ ${name} /sys/fs/cgroup/${name}
+ ;;
+ esac
+ done < /proc/cgroups
+}
+
+start()
+{
+ local retval
+ mount_sys
+ retval=$?
+ if [ $retval -eq 0 ]; then
+ mount_misc
+ retval=$?
+ fi
+ if [ $retval -eq 0 ]; then
+ mount_cgroups
+ retval=$?
+ fi
+ return $retval
+}
diff --git a/mk/rootfs/openrc/etc/init.d/urandom b/mk/rootfs/openrc/etc/init.d/urandom
new file mode 100644
index 0000000..edd645d
--- /dev/null
+++ b/mk/rootfs/openrc/etc/init.d/urandom
@@ -0,0 +1,39 @@
+#!/sbin/openrc-run
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+: ${urandom_seed:=${URANDOM_SEED:-/etc/random-seed}}
+description="Initializes the random number generator."
+
+save_seed()
+{
+ local psz=1
+
+ if [ -e /proc/sys/kernel/random/poolsize ]; then
+ : $(( psz = $(cat /proc/sys/kernel/random/poolsize) / 4096 ))
+ fi
+
+ ( # sub shell to prevent umask pollution
+ umask 077
+ dd if=/dev/urandom of="$urandom_seed" count=${psz} 2>/dev/null
+ )
+}
+
+start()
+{
+ [ -c /dev/urandom ] || return
+ if [ -f "$urandom_seed" ]; then
+ ebegin "Initializing random number generator"
+ cat "$urandom_seed" > /dev/urandom
+ eend $? "Error initializing random number generator"
+ fi
+ rm -f "$urandom_seed" && save_seed
+ return 0
+}
+
+stop()
+{
+ ebegin "Saving random seed"
+ save_seed
+ eend $? "Failed to save random seed"
+}
diff --git a/mk/rootfs/openrc/etc/rc.conf b/mk/rootfs/openrc/etc/rc.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mk/rootfs/openrc/etc/rc.conf
diff --git a/mk/rootfs/openrc/etc/runlevels/shutdown/killprocs b/mk/rootfs/openrc/etc/runlevels/shutdown/killprocs
new file mode 120000
index 0000000..a26adc1
--- /dev/null
+++ b/mk/rootfs/openrc/etc/runlevels/shutdown/killprocs
@@ -0,0 +1 @@
+/etc/init.d/killprocs \ No newline at end of file
diff --git a/mk/rootfs/openrc/openrc.mk b/mk/rootfs/openrc/openrc.mk
index f1ad28f..7472306 100644
--- a/mk/rootfs/openrc/openrc.mk
+++ b/mk/rootfs/openrc/openrc.mk
@@ -29,7 +29,15 @@ OPENRC_PACKAGE := openrc-$(OPENRC_VERSION).tar.bz2
OPENRC_SRC_DIR := $(embtk_pkgb)/openrc-$(OPENRC_VERSION)
OPENRC_BUILD_DIR := $(embtk_pkgb)/openrc-$(OPENRC_VERSION)
-OPENRC_ETC := conf.d init.d.misc init.d local.d rc.conf runlevels sysctl.d
+embtk_openrc_mk := $(EMBTK_ROOT)/mk/rootfs/openrc
+embtk_openrc_sysinit := devfs dmesg sysfs
+embtk_openrc_boot := hostname loopback modules mtab network procfs
+embtk_openrc_boot += root staticroute sysctl urandom
+embtk_openrc_default := netmount
+
+# Installed dir/files in sysroot
+OPENRC_ETC := conf.d init.d.misc init.d local.d rc.conf runlevels
+OPENRC_ETC += sysctl.d
OPENRC_LIBEXECS := rc
ifeq ($(embtk_os),linux)
@@ -54,9 +62,34 @@ define embtk_install_openrc
$(call embtk_makeinstall_pkg,openrc)
endef
+define __embtk_install_openrc_runlevel
+ install -d $(embtk_rootfs)/etc/runlevels/$(1) || exit $$?
+ for f in $(embtk_openrc_$(1)); do \
+ install -m 0755 $(embtk_openrc_mk)/etc/init.d/$$f \
+ $(embtk_rootfs)/etc/init.d/$$f || exit $$?; \
+ ln -snf /etc/init.d/$$f \
+ $(embtk_rootfs)/etc/runlevels/$(1)/$$f || exit $$?; \
+ done
+endef
+
+define embtk_postinstall_openrc
+ install -d $(embtk_rootfs)/etc/conf.d || exit $$?
+ echo "hostname=\"EmbToolkit v$(EMBTK_VERSION)\"" \
+ > $(embtk_rootfs)/etc/conf.d/hostname
+ echo "\"EmbToolkit v$(EMBTK_VERSION)\"" > $(embtk_rootfs)/etc/hostname
+ install -d $(embtk_rootfs)/etc/init.d || exit $$?
+ install -m 0644 $(embtk_openrc_mk)/etc/defaultdomain \
+ $(embtk_rootfs)/etc/defaultdomain || exit $$?
+ install -m 0644 $(embtk_openrc_mk)/etc/rc.conf \
+ $(embtk_rootfs)/etc/rc.conf || exit $$?
+ $(call __embtk_install_openrc_runlevel,sysinit)
+ $(call __embtk_install_openrc_runlevel,boot)
+ $(call __embtk_install_openrc_runlevel,default)
+endef
+
define embtk_cleanup_openrc
- rm -rf $(embtk_sysroot)/$(LIBDIR)/libeinfo.so*
- rm -rf $(embtk_sysroot)/$(LIBDIR)/librc.so*
+ rm -rf $(embtk_sysroot)/$(LIBDIR)/libeinfo.*
+ rm -rf $(embtk_sysroot)/$(LIBDIR)/librc.*
rm -rf $(embtk_sysroot)/bin/rc-status
rm -rf $(embtk_sysroot)/sbin/rc
rm -rf $(embtk_sysroot)/sbin/rc-service
diff --git a/mk/rootfs/rootfs.mk b/mk/rootfs/rootfs.mk
index 39e1371..fa5840a 100644
--- a/mk/rootfs/rootfs.mk
+++ b/mk/rootfs/rootfs.mk
@@ -27,6 +27,9 @@ ifeq ($(CONFIG_EMBTK_HAVE_ROOTFS),y)
# Include various filesystems macros
include mk/rootfs/fs.mk
+include mk/rootfs/openrc/openrc.mk
+ROOTFS_COMPONENTS-$(CONFIG_EMBTK_HAVE_OPENRC) += openrc_install
+
ROOTFS_JFFS2 := $(embtk_generated)/rootfs-$(GNU_TARGET)-$(EMBTK_MCU_FLAG)-$(embtk_clib).jffs2
ROOTFS_TARBZ2 := rootfs-$(GNU_TARGET)-$(EMBTK_MCU_FLAG)-$(embtk_clib).tar.bz2
ROOTFS_SQUASHFS := $(embtk_generated)/rootfs-$(GNU_TARGET)-$(EMBTK_MCU_FLAG)-$(embtk_clib).squashfs
@@ -136,6 +139,7 @@ define __embtk_rootfs_components_install
-cp -R $(embtk_sysroot)/sbin/* $(embtk_rootfs)/sbin/ >/dev/null 2>/dev/null
-cp -R $(embtk_sysroot)/usr/sbin/* $(embtk_rootfs)/usr/sbin/
-cp -R $(embtk_sysroot)/etc/* $(embtk_rootfs)/etc/ >/dev/null 2>/dev/null
+ -rm -rf $$(find $(embtk_rootfs) -type f -name '.empty')
cp -R $(embtk_sysroot)/root $(embtk_rootfs)/
-$(FAKEROOT_BIN) -i $(FAKEROOT_ENV_FILE) -- \
rm -rf `find $(embtk_rootfs) -type f -name *.la`
diff --git a/src/rootfs_skel/etc/conf.d/.empty b/src/rootfs_skel/etc/conf.d/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/rootfs_skel/etc/conf.d/.empty
diff --git a/src/rootfs_skel/etc/fstab b/src/rootfs_skel/etc/fstab
index 359aff7..2715009 100644
--- a/src/rootfs_skel/etc/fstab
+++ b/src/rootfs_skel/etc/fstab
@@ -1,9 +1,4 @@
# /etc/fstab: static file system information.
#
# <file system> <mount pt> <type> <options> <dump> <pass>
-/dev/root / ext2 rw,noauto 0 1
-proc /proc proc defaults 0 0
-tmpfs /dev/shm tmpfs rw 0 0
tmpfs /tmp tmpfs rw 0 0
-devpts /dev/pts devpts gid=5,mode=620 0 0
-sysfs /sys sysfs defaults 0 0
diff --git a/src/rootfs_skel/etc/group b/src/rootfs_skel/etc/group
index f78c22c..2ce50eb 100644
--- a/src/rootfs_skel/etc/group
+++ b/src/rootfs_skel/etc/group
@@ -5,6 +5,7 @@ sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
+uucp:x:9:
wheel:x:10:root
utmp:x:43:
staff:x:50:
diff --git a/src/rootfs_skel/etc/init.d/.empty b/src/rootfs_skel/etc/init.d/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/rootfs_skel/etc/init.d/.empty
diff --git a/src/rootfs_skel/etc/init.d/S20urandom b/src/rootfs_skel/etc/init.d/S20urandom
deleted file mode 100755
index f73cea5..0000000
--- a/src/rootfs_skel/etc/init.d/S20urandom
+++ /dev/null
@@ -1,54 +0,0 @@
-#! /bin/sh
-#
-# urandom This script saves the random seed between reboots.
-# It is called from the boot, halt and reboot scripts.
-#
-# Version: @(#)urandom 1.33 22-Jun-1998 miquels@cistron.nl
-#
-
-[ -c /dev/urandom ] || exit 0
-#. /etc/default/rcS
-
-case "$1" in
- start|"")
- if [ "$VERBOSE" != no ]
- then
- echo -n "Initializing random number generator... "
- fi
- # Load and then save 512 bytes,
- # which is the size of the entropy pool
- if [ -f /etc/random-seed ]
- then
- cat /etc/random-seed >/dev/urandom
- fi
- # check for read only file system
- if ! touch /etc/random-seed 2>/dev/null
- then
- echo "read-only file system detected...done"
- exit
- fi
- rm -f /etc/random-seed
- umask 077
- dd if=/dev/urandom of=/etc/random-seed count=1 \
- >/dev/null 2>&1 || echo "urandom start: failed."
- umask 022
- [ "$VERBOSE" != no ] && echo "done."
- ;;
- stop)
- if ! touch /etc/random-seed 2>/dev/null
- then
- exit
- fi
- # Carry a random seed from shut-down to start-up;
- # see documentation in linux/drivers/char/random.c
- [ "$VERBOSE" != no ] && echo -n "Saving random seed... "
- umask 077
- dd if=/dev/urandom of=/etc/random-seed count=1 \
- >/dev/null 2>&1 || echo "urandom stop: failed."
- [ "$VERBOSE" != no ] && echo "done."
- ;;
- *)
- echo "Usage: urandom {start|stop}" >&2
- exit 1
- ;;
-esac
diff --git a/src/rootfs_skel/etc/init.d/S40network b/src/rootfs_skel/etc/init.d/S40network
deleted file mode 100755
index ad6d250..0000000
--- a/src/rootfs_skel/etc/init.d/S40network
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-#
-# Start the network....
-#
-
-case "$1" in
- start)
- echo "Starting network..."
- /sbin/ifup -a
- ;;
- stop)
- echo -n "Stopping network..."
- /sbin/ifdown -a
- ;;
- restart|reload)
- "$0" stop
- "$0" start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart}"
- exit 1
-esac
-
-exit $?
-
diff --git a/src/rootfs_skel/etc/init.d/rcS b/src/rootfs_skel/etc/init.d/rcS
deleted file mode 100755
index de41153..0000000
--- a/src/rootfs_skel/etc/init.d/rcS
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-
-# Start all init scripts in /etc/init.d
-# executing them in numerical order.
-#
-for i in /etc/init.d/S??* ;do
-
- # Ignore dangling symlinks (if any).
- [ ! -f "$i" ] && continue
-
- case "$i" in
- *.sh)
- # Source shell script for speed.
- (
- trap - INT QUIT TSTP
- set start
- . $i
- )
- ;;
- *)
- # No sh extension, so fork subprocess.
- $i start
- ;;
- esac
-done
-
diff --git a/src/rootfs_skel/etc/inittab b/src/rootfs_skel/etc/inittab
index baf8f6b..a6ea291 100644
--- a/src/rootfs_skel/etc/inittab
+++ b/src/rootfs_skel/etc/inittab
@@ -1,28 +1,12 @@
-# /etc/inittab
-#
-# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
-#
-# Note: BusyBox init doesn't support runlevels. The runlevels field is
-# completely ignored by BusyBox init. If you want runlevels, use
-# sysvinit.
-#
-# Format for each entry: <id>:<runlevels>:<action>:<process>
-#
-# id == tty to run on, or empty for /dev/console
-# runlevels == ignored
-# action == one of sysinit, respawn, askfirst, wait, and once
-# process == program to run
-
-# Startup the system
-null::sysinit:/bin/mount -o remount,rw /
-null::sysinit:/bin/mount -t proc proc /proc
+# Initial system critical filesystems mounting (/proc, /dev, /sys, etc.)
+# FIXME: Cleanup this for /tmp
null::sysinit:/bin/mount -a
-null::sysinit:/bin/hostname -F /etc/hostname
-null::sysinit:/sbin/ifconfig lo 127.0.0.1 up
-null::sysinit:/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
+
+::sysinit:/sbin/openrc sysinit
+::wait:/sbin/openrc boot
+::wait:/sbin/openrc default
+::wait:/sbin/openrc
null::sysinit:/sbin/udhcpc
-# now run any rc scripts
-::sysinit:/etc/init.d/rcS
# Set up a couple of getty's
#tty1::respawn:/sbin/getty 38400 tty1
diff --git a/src/rootfs_skel/etc/local.d/.empty b/src/rootfs_skel/etc/local.d/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/rootfs_skel/etc/local.d/.empty
diff --git a/src/rootfs_skel/etc/passwd b/src/rootfs_skel/etc/passwd
index 377d4df..4e68a53 100644
--- a/src/rootfs_skel/etc/passwd
+++ b/src/rootfs_skel/etc/passwd
@@ -4,6 +4,7 @@ bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:100:sync:/bin:/bin/sync
mail:x:8:8:mail:/var/spool/mail:/bin/sh
+uucp:x:9:9:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
diff --git a/src/rootfs_skel/etc/runlevels/.empty b/src/rootfs_skel/etc/runlevels/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/rootfs_skel/etc/runlevels/.empty
diff --git a/src/rootfs_skel/etc/sysctl.d/.empty b/src/rootfs_skel/etc/sysctl.d/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/rootfs_skel/etc/sysctl.d/.empty
diff --git a/src/rootfs_skel/run b/src/rootfs_skel/run
index 1c2f433..0f0d788 120000
--- a/src/rootfs_skel/run
+++ b/src/rootfs_skel/run
@@ -1 +1 @@
-tmp \ No newline at end of file
+/var/run \ No newline at end of file