diff options
Diffstat (limited to 'mk/rootfs/openrc/etc/init.d')
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/bootmisc | 216 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/devfs | 32 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/dmesg | 17 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/hostname | 15 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/killprocs | 17 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/localmount | 85 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/loopback | 24 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/modules | 57 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/mtab | 35 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/netmount | 82 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/network | 352 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/procfs | 72 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/root | 42 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/staticroute | 103 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/swap | 30 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/sysctl | 33 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/sysfs | 131 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/udhcpc | 15 | ||||
-rw-r--r-- | mk/rootfs/openrc/etc/init.d/urandom | 44 |
19 files changed, 0 insertions, 1402 deletions
diff --git a/mk/rootfs/openrc/etc/init.d/bootmisc b/mk/rootfs/openrc/etc/init.d/bootmisc deleted file mode 100644 index 8a1b008..0000000 --- a/mk/rootfs/openrc/etc/init.d/bootmisc +++ /dev/null @@ -1,216 +0,0 @@ -#!/sbin/openrc-run -# Copyright (c) 2007-2009 Roy Marples <roy@marples.name> -# Released under the 2-clause BSD license. - -depend() -{ - need localmount - 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 deleted file mode 100644 index bfcb644..0000000 --- a/mk/rootfs/openrc/etc/init.d/devfs +++ /dev/null @@ -1,32 +0,0 @@ -#!/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 deleted file mode 100644 index 34d77bd..0000000 --- a/mk/rootfs/openrc/etc/init.d/dmesg +++ /dev/null @@ -1,17 +0,0 @@ -#!/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 deleted file mode 100644 index 34acbf8..0000000 --- a/mk/rootfs/openrc/etc/init.d/hostname +++ /dev/null @@ -1,15 +0,0 @@ -#!/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 deleted file mode 100644 index 6c1fa18..0000000 --- a/mk/rootfs/openrc/etc/init.d/killprocs +++ /dev/null @@ -1,17 +0,0 @@ -#!/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/localmount b/mk/rootfs/openrc/etc/init.d/localmount deleted file mode 100644 index d6ef8fd..0000000 --- a/mk/rootfs/openrc/etc/init.d/localmount +++ /dev/null @@ -1,85 +0,0 @@ -#!/sbin/openrc-run -# Copyright (c) 2007-2009 Roy Marples <roy@marples.name> -# Released under the 2-clause BSD license. - -description="Mounts disks and swap according to /etc/fstab." - -depend() -{ - use modules mtab - after modules -} - -start() -{ - # Mount local filesystems in /etc/fstab. - local types="noproc" x= no_netdev= - for x in $net_fs_list $extra_net_fs_list; do - types="${types},no${x}" - done - - if [ "$RC_UNAME" = Linux ]; then - no_netdev="-O no_netdev" - if mountinfo -q /usr; then - touch "$RC_SVCDIR"/usr_premounted - fi - fi - ebegin "Mounting local filesystems" - mount -at "$types" $no_netdev - eend $? "Some local filesystem failed to mount" - - # Always return 0 - some local mounts may not be critical for boot - return 0 -} - -stop() -{ - yesno $RC_GOINGDOWN || return 0 - # We never unmount / or /dev or $RC_SVCDIR - - # Bug 381783 - local rc_svcdir=$(printf '%s\n' "$RC_SVCDIR" | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g') - - local x= no_umounts_r="/|/dev|/dev/.*|${rc_svcdir}" - no_umounts_r="${no_umounts_r}|/bin|/sbin|/lib(32|64)?|/libexec" - # 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 - no_umounts_r="$no_umounts_r|$x" - done - - if [ "$RC_UNAME" = Linux ]; then - no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*" - if [ -e "$rc_svcdir"/usr_premounted ]; then - no_umounts_r="$no_umounts_r|/usr" - fi - fi - no_umounts_r="^($no_umounts_r)$" - - # Flush all pending disk writes now - sync - - . "$RC_LIBEXECDIR"/sh/rc-mount.sh - - # Umount loop devices - einfo "Unmounting loop devices" - eindent - do_unmount "umount -d" --skip-point-regex "$no_umounts_r" \ - --node-regex "^/dev/loop" - eoutdent - - # Now everything else, except network filesystems as the - # network should be down by this point. - einfo "Unmounting filesystems" - eindent - local fs= - for x in $net_fs_list $extra_net_fs_list; do - fs="$fs${fs:+|}$x" - done - [ -n "$fs" ] && fs="^($fs)$" - do_unmount umount --skip-point-regex "$no_umounts_r" \ - "${fs:+--skip-fstype-regex}" $fs --nonetdev - eoutdent - - return 0 -} diff --git a/mk/rootfs/openrc/etc/init.d/loopback b/mk/rootfs/openrc/etc/init.d/loopback deleted file mode 100644 index 0d8c4a6..0000000 --- a/mk/rootfs/openrc/etc/init.d/loopback +++ /dev/null @@ -1,24 +0,0 @@ -#!/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" - 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 - 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 deleted file mode 100644 index 5daf554..0000000 --- a/mk/rootfs/openrc/etc/init.d/modules +++ /dev/null @@ -1,57 +0,0 @@ -#!/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 deleted file mode 100644 index 21dbae2..0000000 --- a/mk/rootfs/openrc/etc/init.d/mtab +++ /dev/null @@ -1,35 +0,0 @@ -#!/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 deleted file mode 100644 index 0f3757d..0000000 --- a/mk/rootfs/openrc/etc/init.d/netmount +++ /dev/null @@ -1,82 +0,0 @@ -#!/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 deleted file mode 100644 index cebcc0c..0000000 --- a/mk/rootfs/openrc/etc/init.d/network +++ /dev/null @@ -1,352 +0,0 @@ -#!/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() -{ - need localmount - after bootmisc - 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 2>/dev/null)" ] - ;; - *) - 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 deleted file mode 100644 index be016d9..0000000 --- a/mk/rootfs/openrc/etc/init.d/procfs +++ /dev/null @@ -1,72 +0,0 @@ -#!/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 - need localmount -} - -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 deleted file mode 100644 index 973ef1d..0000000 --- a/mk/rootfs/openrc/etc/init.d/root +++ /dev/null @@ -1,42 +0,0 @@ -#!/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 deleted file mode 100644 index 76d46fa..0000000 --- a/mk/rootfs/openrc/etc/init.d/staticroute +++ /dev/null @@ -1,103 +0,0 @@ -#!/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/swap b/mk/rootfs/openrc/etc/init.d/swap deleted file mode 100644 index caff097..0000000 --- a/mk/rootfs/openrc/etc/init.d/swap +++ /dev/null @@ -1,30 +0,0 @@ -#!/sbin/openrc-run -# Copyright (c) 2007-2009 Roy Marples <roy@marples.name> -# Released under the 2-clause BSD license. - -start() -{ - ebegin "Activating swap devices" - case "$RC_UNAME" in - Linux) swapon -a >/dev/null;; - NetBSD|OpenBSD) swapctl -A -t noblk >/dev/null;; - *) swapon -a >/dev/null;; - esac - eend 0 # If swapon has nothing todo it errors, so always return 0 -} - -stop() -{ - ebegin "Deactivating swap devices" - - # Try to unmount all tmpfs filesystems not in use, else a deadlock may - # occur. As $RC_SVCDIR may also be tmpfs we cd to it to lock it - cd "$RC_SVCDIR" - umount -a -t tmpfs 2>/dev/null - - case "$RC_UNAME" in - NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;; - *) swapoff -a >/dev/null;; - esac - eend 0 -} diff --git a/mk/rootfs/openrc/etc/init.d/sysctl b/mk/rootfs/openrc/etc/init.d/sysctl deleted file mode 100644 index 390e72a..0000000 --- a/mk/rootfs/openrc/etc/init.d/sysctl +++ /dev/null @@ -1,33 +0,0 @@ -#!/sbin/openrc-run -# Copyright (c) 2007-2008 Roy Marples <roy@marples.name> -# Released under the 2-clause BSD license. - -depend() -{ - before bootmisc -} - -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 deleted file mode 100644 index 8a0f794..0000000 --- a/mk/rootfs/openrc/etc/init.d/sysfs +++ /dev/null @@ -1,131 +0,0 @@ -#!/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/udhcpc b/mk/rootfs/openrc/etc/init.d/udhcpc deleted file mode 100644 index 9def7b6..0000000 --- a/mk/rootfs/openrc/etc/init.d/udhcpc +++ /dev/null @@ -1,15 +0,0 @@ -#!/sbin/openrc-run -# Copyright (c) 2013 Abdoulaye Walsimou GAYE <awg@embtoolkit.org> -# Released under the 2-clause BSD license. - -command=/sbin/udhcpc -pidfile=${udhcpc_pidfile:=/var/run/udhcpc.pid} -command_args=--pidfile=${pidfile} ${udhcpc_args} -name="Busybox DHCP client" - -depend() -{ - provide net - need localmount - after bootmisc modules -} diff --git a/mk/rootfs/openrc/etc/init.d/urandom b/mk/rootfs/openrc/etc/init.d/urandom deleted file mode 100644 index 1498cc2..0000000 --- a/mk/rootfs/openrc/etc/init.d/urandom +++ /dev/null @@ -1,44 +0,0 @@ -#!/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." - -depend() -{ - need localmount -} - -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" -} |