diff --git a/cfg/alix/INIT b/cfg/alix/INIT new file mode 100644 index 0000000..1b494f9 --- /dev/null +++ b/cfg/alix/INIT @@ -0,0 +1 @@ +GETTY_TTY="ttyS0" diff --git a/cfg/alix/ROOTFS b/cfg/alix/ROOTFS index d165e58..88439ae 100644 --- a/cfg/alix/ROOTFS +++ b/cfg/alix/ROOTFS @@ -19,3 +19,4 @@ iproute2 unbound dnsmasq shadow +openrc diff --git a/cfg/rpi3/INIT b/cfg/rpi3/INIT new file mode 100644 index 0000000..52c76dc --- /dev/null +++ b/cfg/rpi3/INIT @@ -0,0 +1 @@ +GETTY_TTY="tty1 tty2 tty3 tty4 tty5 tty6 tty7" diff --git a/cfg/rpi3/ROOTFS b/cfg/rpi3/ROOTFS index ae74261..b302c5c 100644 --- a/cfg/rpi3/ROOTFS +++ b/cfg/rpi3/ROOTFS @@ -22,3 +22,4 @@ iproute2 unbound dnsmasq shadow +openrc diff --git a/pkg/openrc/0001.patch b/pkg/openrc/0001.patch new file mode 100644 index 0000000..a5ad101 --- /dev/null +++ b/pkg/openrc/0001.patch @@ -0,0 +1,48 @@ +--- a/src/rc/openrc-init.c ++++ b/src/rc/openrc-init.c +@@ -53,7 +53,7 @@ static pid_t do_openrc(const char *runlevel) + sigemptyset(&signals); + sigprocmask(SIG_SETMASK, &signals, NULL); + printf("Starting %s runlevel\n", runlevel); +- execl("/sbin/openrc", "/sbin/openrc", runlevel, NULL); ++ execl("/bin/openrc", "/bin/openrc", runlevel, NULL); + perror("exec"); + break; + default: +--- a/src/rc/rc-selinux.c ++++ b/src/rc/rc-selinux.c +@@ -400,8 +400,8 @@ void selinux_setup(char **argv) + * which will open the pty with initrc_devpts_t, if it doesnt exist, + * fall back to plain exec + */ +- if (!access("/usr/sbin/open_init_pty", X_OK)) { +- if (execvp("/usr/sbin/open_init_pty", argv)) { ++ if (!access("/bin/open_init_pty", X_OK)) { ++ if (execvp("/bin/open_init_pty", argv)) { + perror("execvp"); + exit(-1); + } +--- a/src/rc/rc.c ++++ b/src/rc/rc.c +@@ -78,8 +78,8 @@ const char *usagestring = "" \ + #define INITSH RC_LIBEXECDIR "/sh/init.sh" + #define INITEARLYSH RC_LIBEXECDIR "/sh/init-early.sh" + +-#define SHUTDOWN "/sbin/shutdown" +-#define SULOGIN "/sbin/sulogin" ++#define SHUTDOWN "/bin/shutdown" ++#define SULOGIN "/bin/sulogin" + + #define INTERACTIVE RC_SVCDIR "/interactive" + +@@ -288,8 +288,8 @@ open_shell(void) + /* VSERVER systems cannot really drop to shells */ + if (sys && strcmp(sys, RC_SYS_VSERVER) == 0) + { +- execl("/sbin/halt", "/sbin/halt", "-f", (char *) NULL); +- eerrorx("%s: unable to exec `/sbin/halt': %s", ++ execl("/bin/halt", "/bin/halt", "-f", (char *) NULL); ++ eerrorx("%s: unable to exec `/bin/halt': %s", + applet, strerror(errno)); + } + #endif diff --git a/pkg/openrc/build b/pkg/openrc/build new file mode 100755 index 0000000..b6bb482 --- /dev/null +++ b/pkg/openrc/build @@ -0,0 +1,86 @@ +VERSION="0.34.11" +SRCDIR="openrc-${VERSION}" +TARBALL="${VERSION}.tar.gz" +URL="https://github.com/OpenRC/openrc/archive" +SHA256SUM="4e7b7510c363e99622400feba4b009ec0e0b57dbb99fd4cc678a7b5d2036e00a" +DEPENDS="ncurses" + +prepare() { + return +} + +build() { + local SOURCE="$1" + local BUILD="$2" + local DEPLOY="$3" + + cp -R ${SOURCE}/* ${BUILD} + + for i in ${SCRIPTDIR}/${PKGDIR}/${PKGNAME}/*.patch; do + patch -p1 < $i + done + + unset -v i + + make CC=${TARGET}-gcc AR=${TARGET}-ar RANLIB=${TARGET}-ranlib \ + LD=${TARGET}-ld LIBTERMCAP="-lncursesw" \ + SBINDIR="/bin" INCDIR="/include" LIBNAME="lib" \ + DESTDIR="$DEPLOY" OS=Linux BRANDING="distroname" \ + MKNET=no MKSELINUX=no MKSTATICLIBS=no MKSYSVINIT=yes \ + MKTERMCAP=ncurses UPREFIX="" \ + -j $NUMJOBS +} + +deploy() { + local SOURCE="$1" + local BUILD="$2" + local DEPLOY="$3" + local DEVDEPLOY="$4" + + make SBINDIR="/bin" INCDIR="/include" LIBNAME="lib" \ + DESTDIR="$DEPLOY" OS=Linux BRANDING="distroname" UPREFIX="" \ + install + + mv ${DEPLOY}/include ${DEVDEPLOY} + cp -R ${DEPLOY}/lib ${DEVDEPLOY} + rm -r ${DEPLOY}/lib/pkgconfig + rm ${DEPLOY}/lib/*.a + rm -r ${DEPLOY}/share + rm -r ${DEPLOY}/etc + + for i in ${DEPLOY}/bin/*; do + if [ -f $i ]; then + ${TARGET}-strip --discard-all $i + fi + done + + for i in $(find "$DEPLOY/libexec/rc/bin" -type f -print | \ + xargs file | grep ELF | cut -d: -f1); do + ${TARGET}-strip --discard-all $i + done + + for i in $(find "$DEPLOY/libexec/rc/sbin" -type f -print | \ + xargs file | grep ELF | cut -d: -f1); do + ${TARGET}-strip --discard-all $i + done + + mkdir -p ${DEPLOY}/etc/{conf.d,init.d,runlevels,sysctl.d} + mkdir -p ${DEPLOY}/etc/runlevels/{boot,sysinit,shutdown,default} + cp -R "$SCRIPTDIR/$PKGDIR/$PKGNAME/etc" "$DEPLOY" + + source "$SCRIPTDIR/cfg/$CFG/INIT" + + for i in $GETTY_TTY; do + cat > "$DEPLOY/etc/conf.d/agetty.$i" << _EOF +#quiet="yes" +#baud="38400" +term_type="linux" +#agetty_options="" +_EOF + + ln -s "/etc/init.d/agetty" "$DEPLOY/etc/init.d/agetty.$i" + ln -s "/etc/init.d/agetty.$i" "$DEPLOY/etc/runlevels/default/agetty.$i" + done + + unset -v i GETTY_TTY +} diff --git a/pkg/openrc/etc/conf.d/hostname b/pkg/openrc/etc/conf.d/hostname new file mode 100644 index 0000000..ebdc8f1 --- /dev/null +++ b/pkg/openrc/etc/conf.d/hostname @@ -0,0 +1,2 @@ +# Set to the hostname of this machine +hostname="localhost" diff --git a/pkg/openrc/etc/conf.d/hwclock b/pkg/openrc/etc/conf.d/hwclock new file mode 100644 index 0000000..ce9b40a --- /dev/null +++ b/pkg/openrc/etc/conf.d/hwclock @@ -0,0 +1,20 @@ +# Set CLOCK to "UTC" if your Hardware Clock is set to UTC (also known as +# Greenwich Mean Time). If that clock is set to the local time, then +# set CLOCK to "local". Note that if you dual boot with Windows, then +# you should set it to "local". +clock="UTC" + +# If you want the hwclock script to set the system time (software clock) +# to match the current hardware clock during bootup, leave this +# commented out. +# However, you can set this to "NO" if you are running a modern kernel +# and using NTP to synchronize your system clock. +#clock_hctosys="YES" + +# If you do not want to set the hardware clock to the current system +# time (software clock) during shutdown, set this to no. +#clock_systohc="YES" + +# If you wish to pass any other arguments to hwclock during bootup, +# you may do so here. Alpha users may wish to use --arc or --srm here. +clock_args="" diff --git a/pkg/openrc/etc/conf.d/killprocs b/pkg/openrc/etc/conf.d/killprocs new file mode 100644 index 0000000..76a2bc9 --- /dev/null +++ b/pkg/openrc/etc/conf.d/killprocs @@ -0,0 +1,6 @@ +# If you wish to pass any options to kill_all during shutdown, +# you should do so here. +# +# The setting is called killall5_opts because the options here are meant +# to be identical to those you could pass to killall5. +killall5_opts="" diff --git a/pkg/openrc/etc/conf.d/modules b/pkg/openrc/etc/conf.d/modules new file mode 100644 index 0000000..c35b9ed --- /dev/null +++ b/pkg/openrc/etc/conf.d/modules @@ -0,0 +1,27 @@ +# Linux users can define a list of modules for a specific kernel version, +# a released kernel version, a main kernel version or all kernel versions. +# The most specific versioned variable will take precedence. +# FreeBSD users can only use the modules="foo bar" setting. +#modules_2_6_23_gentoo_r5="ieee1394 ohci1394" +#modules_2_6_23="tun ieee1394" +#modules_2_6="tun" +#modules_2="ipv6" +#modules="ohci1394" + +# Linux users can give modules a different name when they load - the new name +# will also be used to pick arguments below. +# This is not supported on FreeBSD. +#modules="dummy:dummy1" + +# Linux users can give the modules some arguments if needed, per version +# if necessary. +# Again, the most specific versioned variable will take precedence. +# This is not supported on FreeBSD. +#module_ieee1394_args="debug" +#module_ieee1394_args_2_6_23_gentoo_r5="debug2" +#module_ieee1394_args_2_6_23="debug3" +#module_ieee1394_args_2_6="debug4" +#module_ieee1394_args_2="debug5" + +# You should consult your kernel documentation and configuration +# for a list of modules and their options. diff --git a/pkg/openrc/etc/conf.d/urandom b/pkg/openrc/etc/conf.d/urandom new file mode 100644 index 0000000..f721a24 --- /dev/null +++ b/pkg/openrc/etc/conf.d/urandom @@ -0,0 +1,5 @@ +# Sometimes you want to have urandom start before "localmount" +# (say for crypt swap), so you will need to customize this +# behavior. If you have /var on a separate partition, then +# make sure this path lives on your root device somewhere. +urandom_seed="/var/lib/misc/random-seed" diff --git a/pkg/openrc/etc/init.d/agetty b/pkg/openrc/etc/init.d/agetty new file mode 100755 index 0000000..98b44c5 --- /dev/null +++ b/pkg/openrc/etc/init.d/agetty @@ -0,0 +1,33 @@ +#!/bin/openrc-run +# Copyright (c) 2017 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +description="start agetty on a terminal line" +supervisor=supervise-daemon +port="${RC_SVCNAME#*.}" +term_type="${term_type:-linux}" +command=/bin/agetty +command_args_foreground="${agetty_options} ${port} ${baud} ${term_type}" +pidfile="/run/${RC_SVCNAME}.pid" +export EINFO_QUIET="${quiet:-yes}" + +depend() { + after local + keyword -prefix +} + +start_pre() { + if [ -z "$port" ]; then + eerror "${RC_SVCNAME} cannot be started directly. You must create" + eerror "symbolic links to it for the ports you want to start" + eerror "agetty on and add those to the appropriate runlevels." + return 1 + fi +} diff --git a/pkg/openrc/etc/init.d/functions.sh b/pkg/openrc/etc/init.d/functions.sh new file mode 120000 index 0000000..974cf64 --- /dev/null +++ b/pkg/openrc/etc/init.d/functions.sh @@ -0,0 +1 @@ +/libexec/rc/sh/functions.sh \ No newline at end of file diff --git a/pkg/openrc/etc/init.d/hostname b/pkg/openrc/etc/init.d/hostname new file mode 100755 index 0000000..ecb01a6 --- /dev/null +++ b/pkg/openrc/etc/init.d/hostname @@ -0,0 +1,38 @@ +#!/bin/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +description="Sets the hostname of the machine." + +depend() +{ + after clock + keyword -docker -lxc -prefix -systemd-nspawn +} + +start() +{ + local h source x + if [ -s /etc/hostname ] && [ -r /etc/hostname ]; then + read h x &1 >/dev/null)" + + [ -z "$err" ] && return 0 + echo "${err}" >&2 + return 1 +} + +get_noadjfile() +{ + if ! yesno $clock_adjfile; then + # Some implementations don't handle adjustments + if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-noadjfile"; then + echo --noadjfile + fi + fi +} + +rtc_exists() +{ + local rtc= + for rtc in /dev/rtc /dev/rtc[0-9]*; do + [ -e "$rtc" ] && break + done + [ -e "$rtc" ] +} + +start() +{ + local retval=0 errstr="" modname + setupopts + + if [ -z "$utc_cmd" ]; then + ewarn "Not setting clock for $utc system" + return 0 + fi + + ebegin "Setting system clock using the hardware clock [$utc]" + if [ -e /proc/modules ]; then + if ! rtc_exists; then + for x in rtc-cmos rtc genrtc; do + modprobe -q $x && rtc_exists && modname="$x" && break + done + [ -n "$modname" ] && + ewarn "The $modname module needs to be configured in" \ + "/etc/conf.d/modules or built in." + fi + fi + + # Always set the kernel's time zone. + _hwclock --systz $utc_cmd $(get_noadjfile) $clock_args + : $(( retval += $? )) + + if [ -e /etc/adjtime ] && yesno $clock_adjfile; then + _hwclock --adjust $utc_cmd $(get_noadjfile) + : $(( retval += $? )) + fi + + if yesno ${clock_hctosys:-YES}; then + _hwclock --hctosys $utc_cmd $(get_noadjfile) $clock_args + : $(( retval += $? )) + fi + + eend $retval "Failed to set the system clock" + + return 0 +} + +stop() +{ + # Don't tweak the hardware clock on LiveCD halt. + [ -n "$CDBOOT" ] && return 0 + yesno ${clock_systohc:-YES} || return 0 + + local retval=0 errstr="" + setupopts + + [ -z "$utc_cmd" ] && return 0 + + ebegin "Setting hardware clock using the system clock" "[$utc]" + + _hwclock --systohc $utc_cmd $(get_noadjfile) $clock_args + retval=$? + + eend $retval "Failed to sync clocks" +} + +save() +{ + clock_systohc=yes + stop +} + +show() +{ + setupopts + hwclock --show "$utc_cmd" $(get_noadjfile) $clock_args +} diff --git a/pkg/openrc/etc/init.d/killprocs b/pkg/openrc/etc/init.d/killprocs new file mode 100755 index 0000000..f8f58d5 --- /dev/null +++ b/pkg/openrc/etc/init.d/killprocs @@ -0,0 +1,27 @@ +#!/bin/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +description="Kill all processes so we can unmount disks cleanly." + +depend() +{ + keyword -prefix +} + +start() +{ + ebegin "Terminating remaining processes" + kill_all 15 ${killall5_opts} + eend 0 + ebegin "Killing remaining processes" + kill_all 9 ${killall5_opts} + eend 0 +} diff --git a/pkg/openrc/etc/init.d/loopback b/pkg/openrc/etc/init.d/loopback new file mode 100755 index 0000000..7665c0b --- /dev/null +++ b/pkg/openrc/etc/init.d/loopback @@ -0,0 +1,35 @@ +#!/bin/openrc-run +# Copyright (c) 2013-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +description="Configures the loopback interface." + +depend() +{ + after clock + keyword -jail -prefix -systemd-nspawn -vserver +} + +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 + + ip link set lo up + else + ifconfig lo 127.0.0.1 netmask 255.0.0.0 + fi + else + ebegin "Bringing up network interface lo0" + ifconfig lo0 127.0.0.1 netmask 255.0.0.0 + fi + eend $? +} diff --git a/pkg/openrc/etc/init.d/modules b/pkg/openrc/etc/init.d/modules new file mode 100755 index 0000000..07fac0e --- /dev/null +++ b/pkg/openrc/etc/init.d/modules @@ -0,0 +1,70 @@ +#!/bin/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +description="Loads a user defined list of kernel modules." + +depend() +{ + use isapnp + want modules-load + keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver +} + +start() +{ + # Should not fail if kernel does 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= a= + for x in $kv_variant_list ; do + eval list=\$modules_$(shell_var "$x") + [ -n "$list" ] && break + done + [ -z "$list" ] && list=$modules + + [ -n "$list" ] && ebegin "Loading kernel modules" + for x in $list; do + a=${x#*:} + if [ "$a" = "$x" ]; then + unset mpargs + else + x=${x%%:*} + mpargs="-o $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 --use-blacklist --verbose "$mpargs" "$x" "$args" + done + [ -n "$list" ] && eend + return 0 +} diff --git a/pkg/openrc/etc/init.d/mount-ro b/pkg/openrc/etc/init.d/mount-ro new file mode 100755 index 0000000..6e2edd6 --- /dev/null +++ b/pkg/openrc/etc/init.d/mount-ro @@ -0,0 +1,59 @@ +#!/bin/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +description="Re-mount filesytems read-only for a clean reboot." + +depend() +{ + after killprocs + keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver +} + +start() +{ + local ret=0 + + # Flush all pending disk writes now + sync + + ebegin "Remounting remaining filesystems read-only" + # We need the do_unmount function + . "$RC_LIBEXECDIR"/sh/rc-mount.sh + eindent + + # Bug 381783 + local rc_svcdir=$(echo $RC_SVCDIR | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g') + + local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|/run|${rc_svcdir}" x= fs= + m="$m|/bin|/sbin|/lib(32|64)?|/libexec" + if [ -e "$rc_svcdir"/usr_premounted ]; then + m="$m|/usr" + fi + # RC_NO_UMOUNTS is an env var that can be set by plugins + local IFS="$IFS:" + for x in $no_umounts $RC_NO_UMOUNTS; do + m="$m|$x" + done + m="^($m)$" + fs= + for x in $net_fs_list $extra_net_fs_list; do + fs="$fs${fs:+|}$x" + done + [ -n "$fs" ] && fs="^($fs)$" + do_unmount "umount -r" \ + --skip-point-regex "$m" \ + "${fs:+--skip-fstype-regex}" $fs --nonetdev + ret=$? + + eoutdent + + eend $ret +} diff --git a/pkg/openrc/etc/init.d/sysctl b/pkg/openrc/etc/init.d/sysctl new file mode 100755 index 0000000..0b990d6 --- /dev/null +++ b/pkg/openrc/etc/init.d/sysctl @@ -0,0 +1,24 @@ +#!/bin/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +depend() +{ + after clock + before bootmisc logger + keyword -prefix -systemd-nspawn -vserver +} + +start() +{ + ebegin "Configuring kernel parameters" + sysctl --system + eend $? "Unable to configure some kernel parameters" +} diff --git a/pkg/openrc/etc/init.d/termencoding b/pkg/openrc/etc/init.d/termencoding new file mode 100755 index 0000000..544bb42 --- /dev/null +++ b/pkg/openrc/etc/init.d/termencoding @@ -0,0 +1,55 @@ +#!/bin/openrc-run +# Copyright (c) 2008-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +description="Configures terminal encoding." + +ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} +: ${unicode:=${UNICODE}} + +depend() +{ + keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + use root + after bootmisc clock +} + +start() +{ + local ttydev=/dev/tty n= + [ -d /dev/vc ] && ttydev=/dev/vc/ + + # Set terminal encoding to either ASCII or UNICODE. + # See utf-8(7) for more information. + local termencoding="%@" termmsg="ASCII" + if yesno ${unicode}; then + termencoding="%G" + termmsg="UTF-8" + fi + + ebegin "Setting terminal encoding [$termmsg]" + n=1 + while [ ${n} -le "$ttyn" ]; do + printf "\033%s" "$termencoding" >$ttydev$n + : $(( n += 1 )) + done + + # Save the encoding for use immediately at boot + if checkpath -W "$RC_LIBEXECDIR"; then + mkdir -p "$RC_LIBEXECDIR"/console + if yesno ${unicode:-${UNICODE}}; then + echo "" > "$RC_LIBEXECDIR"/console/unicode + else + rm -f "$RC_LIBEXECDIR"/console/unicode + fi + fi + + eend 0 +} diff --git a/pkg/openrc/etc/init.d/urandom b/pkg/openrc/etc/init.d/urandom new file mode 100755 index 0000000..d6f93f8 --- /dev/null +++ b/pkg/openrc/etc/init.d/urandom @@ -0,0 +1,52 @@ +#!/bin/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +: ${urandom_seed:=${URANDOM_SEED:-/var/lib/misc/random-seed}} +description="Initializes the random number generator." + +depend() +{ + after clock + keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn +} + +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/pkg/openrc/etc/rc.conf b/pkg/openrc/etc/rc.conf new file mode 100644 index 0000000..b7296d3 --- /dev/null +++ b/pkg/openrc/etc/rc.conf @@ -0,0 +1,309 @@ +# Global OpenRC configuration settings + +# Set to "YES" if you want the rc system to try and start services +# in parallel for a slight speed improvement. When running in parallel we +# prefix the service output with its name as the output will get +# jumbled up. +# WARNING: whilst we have improved parallel, it can still potentially lock +# the boot process. Don't file bugs about this unless you can supply +# patches that fix it without breaking other things! +#rc_parallel="NO" + +# Set rc_interactive to "YES" and you'll be able to press the I key during +# boot so you can choose to start specific services. Set to "NO" to disable +# this feature. This feature is automatically disabled if rc_parallel is +# set to YES. +#rc_interactive="YES" + +# If we need to drop to a shell, you can specify it here. +# If not specified we use $SHELL, otherwise the one specified in /etc/passwd, +# otherwise /bin/sh +# Linux users could specify /sbin/sulogin +#rc_shell=/bin/sh + +# Do we allow any started service in the runlevel to satisfy the dependency +# or do we want all of them regardless of state? For example, if net.eth0 +# and net.eth1 are in the default runlevel then with rc_depend_strict="NO" +# both will be started, but services that depend on 'net' will work if either +# one comes up. With rc_depend_strict="YES" we would require them both to +# come up. +#rc_depend_strict="YES" + +# rc_hotplug controls which services we allow to be hotplugged. +# A hotplugged service is one started by a dynamic dev manager when a matching +# hardware device is found. +# Hotplugged services appear in the "hotplugged" runlevel. +# If rc_hotplug is set to any value, we compare the name of this service +# to every pattern in the value, from left to right, and we allow the +# service to be hotplugged if it matches a pattern, or if it matches no +# patterns. Patterns can include shell wildcards. +# To disable services from being hotplugged, prefix patterns with "!". +#If rc_hotplug is not set or is empty, all hotplugging is disabled. +# Example - rc_hotplug="net.wlan !net.*" +# This allows net.wlan and any service not matching net.* to be hotplugged. +# Example - rc_hotplug="!net.*" +# This allows services that do not match "net.*" to be hotplugged. + +# rc_logger launches a logging daemon to log the entire rc process to +# /var/log/rc.log +# NOTE: Linux systems require the devfs service to be started before +# logging can take place and as such cannot log the sysinit runlevel. +#rc_logger="NO" + +# Through rc_log_path you can specify a custom log file. +# The default value is: /var/log/rc.log +#rc_log_path="/var/log/rc.log" + +# If you want verbose output for OpenRC, set this to yes. If you want +# verbose output for service foo only, set it to yes in /etc/conf.d/foo. +#rc_verbose=no + +# By default we filter the environment for our running scripts. To allow other +# variables through, add them here. Use a * to allow all variables through. +#rc_env_allow="VAR1 VAR2" + +# By default we assume that all daemons will start correctly. +# However, some do not - a classic example is that they fork and return 0 AND +# then child barfs on a configuration error. Or the daemon has a bug and the +# child crashes. You can set the number of milliseconds start-stop-daemon +# waits to check that the daemon is still running after starting here. +# The default is 0 - no checking. +#rc_start_wait=100 + +# rc_nostop is a list of services which will not stop when changing runlevels. +# This still allows the service itself to be stopped when called directly. +#rc_nostop="" + +# rc will attempt to start crashed services by default. +# However, it will not stop them by default as that could bring down other +# critical services. +#rc_crashed_stop=NO +#rc_crashed_start=YES + +# Set rc_nocolor to yes if you do not want colors displayed in OpenRC +# output. +#rc_nocolor=NO + +############################################################################## +# MISC CONFIGURATION VARIABLES +# There variables are shared between many init scripts + +# Set unicode to YES to turn on unicode support for keyboards and screens. +#unicode="NO" + +# This is how long fuser should wait for a remote server to respond. The +# default is 60 seconds, but it can be adjusted here. +#rc_fuser_timeout=60 + +# Below is the default list of network fstypes. +# +# afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre ncpfs +# nfs nfs4 ocfs2 shfs smbfs +# +# If you would like to add to this list, you can do so by adding your +# own fstypes to the following variable. +#extra_net_fs_list="" + +############################################################################## +# SERVICE CONFIGURATION VARIABLES +# These variables are documented here, but should be configured in +# /etc/conf.d/foo for service foo and NOT enabled here unless you +# really want them to work on a global basis. +# If your service has characters in its name which are not legal in +# shell variable names and you configure the variables for it in this +# file, those characters should be replaced with underscores in the +# variable names as shown below. + +# Some daemons are started and stopped via start-stop-daemon. +# We can set some things on a per service basis, like the nicelevel. +#SSD_NICELEVEL="-19" +# Or the ionice level. The format is class[:data] , just like the +# --ionice start-stop-daemon parameter. +#SSD_IONICELEVEL="2:2" + +# Pass ulimit parameters +# If you are using bash in POSIX mode for your shell, note that the +# ulimit command uses a block size of 512 bytes for the -c and -f +# options +#rc_ulimit="-u 30" + +# It's possible to define extra dependencies for services like so +#rc_config="/etc/foo" +#rc_need="openvpn" +#rc_use="net.eth0" +#rc_after="clock" +#rc_before="local" +#rc_provide="!net" + +# You can also enable the above commands here for each service. Below is an +# example for service foo. +#rc_foo_config="/etc/foo" +#rc_foo_need="openvpn" +#rc_foo_after="clock" + +# Below is an example for service foo-bar. Note that the '-' is illegal +# in a shell variable name, so we convert it to an underscore. +# example for service foo-bar. +#rc_foo_bar_config="/etc/foo-bar" +#rc_foo_bar_need="openvpn" +#rc_foo_bar_after="clock" + +# You can also remove dependencies. +# This is mainly used for saying which services do NOT provide net. +#rc_net_tap0_provide="!net" + +# This is the subsystem type. +# It is used to match against keywords set by the keyword call in the +# depend function of service scripts. +# +# It should be set to the value representing the environment this file is +# PRESENTLY in, not the virtualization the environment is capable of. +# If it is commented out, automatic detection will be used. +# +# The list below shows all possible settings as well as the host +# operating systems where they can be used and autodetected. +# +# "" - nothing special +# "docker" - Docker container manager (Linux) +# "jail" - Jail (DragonflyBSD or FreeBSD) +# "lxc" - Linux Containers +# "openvz" - Linux OpenVZ +# "prefix" - Prefix +# "rkt" - CoreOS container management system (Linux) +# "subhurd" - Hurd subhurds (to be checked) +# "systemd-nspawn" - Container created by systemd-nspawn (Linux) +# "uml" - Usermode Linux +# "vserver" - Linux vserver +# "xen0" - Xen0 Domain (Linux and NetBSD) +# "xenU" - XenU Domain (Linux and NetBSD) +#rc_sys="" + +# if you use openrc-init, which is currently only available on Linux, +# this is the default runlevel to activate after "sysinit" and "boot" +# when booting. +#rc_default_runlevel="default" + +# on Linux and Hurd, this is the number of ttys allocated for logins +# It is used in the consolefont, keymaps, numlock and termencoding +# service scripts. +rc_tty_number=12 + +############################################################################## +# LINUX CGROUPS RESOURCE MANAGEMENT + +# This sets the mode used to mount cgroups. +# "hybrid" mounts cgroups version 2 on /sys/fs/cgroup/unified and +# cgroups version 1 on /sys/fs/cgroup. +# "legacy" mounts cgroups version 1 on /sys/fs/cgroup +# "unified" mounts cgroups version 2 on /sys/fs/cgroup +#rc_cgroup_mode="hybrid" + +# This is a list of controllers which should be enabled for cgroups version 2. +# If hybrid mode is being used, controllers listed here will not be +# available for cgroups version 1. +# This is a global setting. +#rc_cgroup_controllers="" + +# This variable contains the cgroups version 2 settings for your services. +# If this is set in this file, the settings will apply to all services. +# If you want different settings for each service, place the settings in +# /etc/conf.d/foo for service foo. +# The format is to specify the setting and value followed by a newline. +# Multiple settings and values can be specified. +# For example, you would use this to set the maximum memory and maximum +# number of pids for a service. +#rc_cgroup_settings=" +#memory.max 10485760 +#pids.max max +#" +# +# For more information about the adjustments that can be made with +# cgroups version 2, see Documentation/cgroups-v2.txt in the linux kernel +# source tree. +#rc_cgroup_settings="" + +# This switch controls whether or not cgroups version 1 controllers are +# individually mounted under +# /sys/fs/cgroup in hybrid or legacy mode. +#rc_controller_cgroups="YES" + +# The following settings allow you to set up values for the cgroups version 1 +# controllers for your services. +# They can be set in this file;, however, if you do this, the settings +# will apply to all of your services. +# If you want different settings for each service, place the settings in +# /etc/conf.d/foo for service foo. +# The format is to specify the names of the settings followed by their +# values. Each variable can hold multiple settings. +# For example, you would use this to set the cpu.shares setting in the +# cpu controller to 512 for your service. +# rc_cgroup_cpu=" +# cpu.shares 512 +# " +# +# For more information about the adjustments that can be made with +# cgroups version 1, see Documentation/cgroups-v1/* in the linux kernel +# source tree. + +# Set the blkio controller settings for this service. +#rc_cgroup_blkio="" + +# Set the cpu controller settings for this service. +#rc_cgroup_cpu="" + +# Add this service to the cpuacct controller (any value means yes). +#rc_cgroup_cpuacct="" + +# Set the cpuset controller settings for this service. +#rc_cgroup_cpuset="" + +# Set the devices controller settings for this service. +#rc_cgroup_devices="" + +# Set the hugetlb controller settings for this service. +#rc_cgroup_hugetlb="" + +# Set the memory controller settings for this service. +#rc_cgroup_memory="" + +# Set the net_cls controller settings for this service. +#rc_cgroup_net_cls="" + +# Set the net_prio controller settings for this service. +#rc_cgroup_net_prio="" + +# Set the pids controller settings for this service. +#rc_cgroup_pids="" + +# Set this to YES if you want all of the processes in a service's cgroup +# killed when the service is stopped or restarted. +# Be aware that setting this to yes means all of a service's +# child processes will be killed. Keep this in mind if you set this to +# yes here instead of for the individual services in +# /etc/conf.d/. +# To perform this cleanup manually for a stopped service, you can +# execute cgroup_cleanup with /etc/init.d/ cgroup_cleanup or +# rc-service cgroup_cleanup. +# The process followed in this cleanup is the following: +# 1. send stopsig (sigterm if it isn't set) to all processes left in the +# cgroup immediately followed by sigcont. +# 2. Send sighup to all processes in the cgroup if rc_send_sighup is +# yes. +# 3. delay for rc_timeout_stopsec seconds. +# 4. send sigkill to all processes in the cgroup unless disabled by +# setting rc_send_sigkill to no. +# rc_cgroup_cleanup="NO" + +# If this is yes, we will send sighup to the processes in the cgroup +# immediately after stopsig and sigcont. +#rc_send_sighup="NO" + +# This is the amount of time in seconds that we delay after sending sigcont +# and optionally sighup, before we optionally send sigkill to all +# processes in the # cgroup. +# The default is 90 seconds. +#rc_timeout_stopsec="90" + +# If this is set to no, we do not send sigkill to all processes in the +# cgroup. +#rc_send_sigkill="YES" diff --git a/pkg/openrc/etc/runlevels/boot/hostname b/pkg/openrc/etc/runlevels/boot/hostname new file mode 120000 index 0000000..2920d24 --- /dev/null +++ b/pkg/openrc/etc/runlevels/boot/hostname @@ -0,0 +1 @@ +/etc/init.d/hostname \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/boot/hwclock b/pkg/openrc/etc/runlevels/boot/hwclock new file mode 120000 index 0000000..84d9672 --- /dev/null +++ b/pkg/openrc/etc/runlevels/boot/hwclock @@ -0,0 +1 @@ +/etc/init.d/hwclock \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/boot/loopback b/pkg/openrc/etc/runlevels/boot/loopback new file mode 120000 index 0000000..22878c6 --- /dev/null +++ b/pkg/openrc/etc/runlevels/boot/loopback @@ -0,0 +1 @@ +/etc/init.d/loopback \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/boot/modules b/pkg/openrc/etc/runlevels/boot/modules new file mode 120000 index 0000000..4886563 --- /dev/null +++ b/pkg/openrc/etc/runlevels/boot/modules @@ -0,0 +1 @@ +/etc/init.d/modules \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/boot/sysctl b/pkg/openrc/etc/runlevels/boot/sysctl new file mode 120000 index 0000000..b4ac535 --- /dev/null +++ b/pkg/openrc/etc/runlevels/boot/sysctl @@ -0,0 +1 @@ +/etc/init.d/sysctl \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/boot/termencoding b/pkg/openrc/etc/runlevels/boot/termencoding new file mode 120000 index 0000000..f7d1d33 --- /dev/null +++ b/pkg/openrc/etc/runlevels/boot/termencoding @@ -0,0 +1 @@ +/etc/init.d/termencoding \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/boot/urandom b/pkg/openrc/etc/runlevels/boot/urandom new file mode 120000 index 0000000..0bae59f --- /dev/null +++ b/pkg/openrc/etc/runlevels/boot/urandom @@ -0,0 +1 @@ +/etc/init.d/urandom \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/shutdown/killprocs b/pkg/openrc/etc/runlevels/shutdown/killprocs new file mode 120000 index 0000000..a26adc1 --- /dev/null +++ b/pkg/openrc/etc/runlevels/shutdown/killprocs @@ -0,0 +1 @@ +/etc/init.d/killprocs \ No newline at end of file diff --git a/pkg/openrc/etc/runlevels/shutdown/mount-ro b/pkg/openrc/etc/runlevels/shutdown/mount-ro new file mode 120000 index 0000000..87cc256 --- /dev/null +++ b/pkg/openrc/etc/runlevels/shutdown/mount-ro @@ -0,0 +1 @@ +/etc/init.d/mount-ro \ No newline at end of file