From d05c59bf6285ded99ed696054a03301df664ef43 Mon Sep 17 00:00:00 2001 From: frank Date: Sat, 28 Jan 2012 21:59:04 +0100 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- .etckeeper | 69 +- conf.d/fsck | 7 + conf.d/udev | 16 +- conf.d/urandom | 2 +- config-archive/etc/conf.d/fsck | 27 + .../etc/conf.d/fsck.dist | 0 config-archive/etc/conf.d/udev | 64 ++ .../etc/conf.d/udev.dist | 0 config-archive/etc/conf.d/urandom | 5 + .../etc/conf.d/urandom.dist | 0 config-archive/etc/init.d/bootmisc | 171 ++++ .../etc/init.d/bootmisc.dist | 0 config-archive/etc/init.d/consolefont | 67 ++ .../etc/init.d/consolefont.dist | 0 config-archive/etc/init.d/fsck | 109 +++ .../etc/init.d/fsck.dist | 0 config-archive/etc/init.d/hwclock | 146 ++++ .../etc/init.d/hwclock.dist | 0 config-archive/etc/init.d/keymaps | 70 ++ .../etc/init.d/keymaps.dist | 0 config-archive/etc/init.d/modules | 63 ++ .../etc/init.d/modules.dist | 0 config-archive/etc/init.d/net.lo | 737 ++++++++++++++++++ .../etc/init.d/net.lo.dist | 0 config-archive/etc/init.d/network | 352 +++++++++ .../etc/init.d/network.dist | 0 config-archive/etc/init.d/numlock | 42 + .../etc/init.d/numlock.dist | 0 config-archive/etc/init.d/staticroute | 104 +++ .../etc/init.d/staticroute.dist | 0 config-archive/etc/init.d/sysfs | 64 ++ .../etc/init.d/sysfs.dist | 0 config-archive/etc/init.d/termencoding | 48 ++ .../etc/init.d/termencoding.dist | 0 config-archive/etc/init.d/udev | 272 +++++++ config-archive/etc/init.d/udev-mount | 107 +++ .../etc/init.d/udev-mount.dist | 0 config-archive/etc/init.d/udev-postmount | 53 ++ .../etc/init.d/udev-postmount.dist | 0 .../etc/init.d/udev.dist | 0 config-archive/etc/init.d/urandom | 45 ++ .../etc/init.d/urandom.dist | 0 config-archive/etc/lvm/lvm.conf | 525 +++++++++++++ .../etc/lvm/lvm.conf.dist | 0 config-archive/etc/pam.d/system-login | 19 + .../etc/pam.d/system-login.dist | 0 config-archive/etc/rc.conf | 148 ++++ .../etc/rc.conf.dist.new | 0 dispatch-conf.conf | 9 +- init.d/bootmisc | 47 +- init.d/consolefont | 2 +- init.d/fsck | 15 +- init.d/hwclock | 4 +- init.d/keymaps | 2 +- init.d/modules | 2 +- init.d/net.lo | 98 ++- init.d/network | 8 +- init.d/numlock | 2 +- init.d/staticroute | 5 + init.d/sysfs | 42 + init.d/termencoding | 2 +- init.d/udev | 265 +++---- init.d/udev-mount | 43 +- init.d/udev-postmount | 37 +- init.d/urandom | 4 +- lvm/lvm.conf | 147 +++- motd | 6 +- pam.d/system-login | 3 + 68 files changed, 3791 insertions(+), 284 deletions(-) create mode 100644 config-archive/etc/conf.d/fsck rename conf.d/._cfg0000_fsck => config-archive/etc/conf.d/fsck.dist (100%) create mode 100644 config-archive/etc/conf.d/udev rename conf.d/._cfg0000_udev => config-archive/etc/conf.d/udev.dist (100%) create mode 100644 config-archive/etc/conf.d/urandom rename conf.d/._cfg0000_urandom => config-archive/etc/conf.d/urandom.dist (100%) create mode 100755 config-archive/etc/init.d/bootmisc rename init.d/._cfg0000_bootmisc => config-archive/etc/init.d/bootmisc.dist (100%) create mode 100755 config-archive/etc/init.d/consolefont rename init.d/._cfg0000_consolefont => config-archive/etc/init.d/consolefont.dist (100%) create mode 100755 config-archive/etc/init.d/fsck rename init.d/._cfg0000_fsck => config-archive/etc/init.d/fsck.dist (100%) create mode 100755 config-archive/etc/init.d/hwclock rename init.d/._cfg0000_hwclock => config-archive/etc/init.d/hwclock.dist (100%) create mode 100755 config-archive/etc/init.d/keymaps rename init.d/._cfg0000_keymaps => config-archive/etc/init.d/keymaps.dist (100%) create mode 100755 config-archive/etc/init.d/modules rename init.d/._cfg0000_modules => config-archive/etc/init.d/modules.dist (100%) create mode 100755 config-archive/etc/init.d/net.lo rename init.d/._cfg0000_net.lo => config-archive/etc/init.d/net.lo.dist (100%) create mode 100755 config-archive/etc/init.d/network rename init.d/._cfg0000_network => config-archive/etc/init.d/network.dist (100%) create mode 100755 config-archive/etc/init.d/numlock rename init.d/._cfg0000_numlock => config-archive/etc/init.d/numlock.dist (100%) create mode 100755 config-archive/etc/init.d/staticroute rename init.d/._cfg0000_staticroute => config-archive/etc/init.d/staticroute.dist (100%) create mode 100755 config-archive/etc/init.d/sysfs rename init.d/._cfg0000_sysfs => config-archive/etc/init.d/sysfs.dist (100%) create mode 100755 config-archive/etc/init.d/termencoding rename init.d/._cfg0000_termencoding => config-archive/etc/init.d/termencoding.dist (100%) create mode 100755 config-archive/etc/init.d/udev create mode 100755 config-archive/etc/init.d/udev-mount rename init.d/._cfg0000_udev-mount => config-archive/etc/init.d/udev-mount.dist (100%) create mode 100755 config-archive/etc/init.d/udev-postmount rename init.d/._cfg0000_udev-postmount => config-archive/etc/init.d/udev-postmount.dist (100%) rename init.d/._cfg0000_udev => config-archive/etc/init.d/udev.dist (100%) create mode 100755 config-archive/etc/init.d/urandom rename init.d/._cfg0000_urandom => config-archive/etc/init.d/urandom.dist (100%) create mode 100644 config-archive/etc/lvm/lvm.conf rename lvm/._cfg0000_lvm.conf => config-archive/etc/lvm/lvm.conf.dist (100%) create mode 100644 config-archive/etc/pam.d/system-login rename pam.d/._cfg0000_system-login => config-archive/etc/pam.d/system-login.dist (100%) create mode 100644 config-archive/etc/rc.conf rename ._cfg0000_rc.conf => config-archive/etc/rc.conf.dist.new (100%) diff --git a/.etckeeper b/.etckeeper index cc1b3c5..3e60efe 100755 --- a/.etckeeper +++ b/.etckeeper @@ -25,7 +25,6 @@ mkdir -p './texmf/dvipdfm/config' mkdir -p './texmf/dvips.d' mkdir -p './unixODBC/ODBCDataSources' maybe chmod 0755 '.' -maybe chmod 0644 './._cfg0000_rc.conf' maybe chmod 0700 './.etckeeper' maybe chmod 0644 './.gitignore' maybe chmod 0600 './.pwd.lock' @@ -105,9 +104,6 @@ maybe chmod 0644 './clamd.conf' maybe chmod 0644 './colordiffrc' maybe chmod 0644 './colordiffrc-lightbg' maybe chmod 0755 './conf.d' -maybe chmod 0644 './conf.d/._cfg0000_fsck' -maybe chmod 0644 './conf.d/._cfg0000_udev' -maybe chmod 0644 './conf.d/._cfg0000_urandom' maybe chmod 0644 './conf.d/apache2' maybe chmod 0644 './conf.d/auditd' maybe chmod 0644 './conf.d/bootmisc' @@ -156,8 +152,14 @@ maybe chmod 0644 './config-archive/etc/bash/bashrc.dist.new' maybe chmod 0755 './config-archive/etc/conf.d' maybe chmod 0644 './config-archive/etc/conf.d/apache2' maybe chmod 0644 './config-archive/etc/conf.d/apache2.dist' +maybe chmod 0644 './config-archive/etc/conf.d/fsck' +maybe chmod 0644 './config-archive/etc/conf.d/fsck.dist' maybe chmod 0644 './config-archive/etc/conf.d/keymaps' maybe chmod 0644 './config-archive/etc/conf.d/keymaps.dist.new' +maybe chmod 0644 './config-archive/etc/conf.d/udev' +maybe chmod 0644 './config-archive/etc/conf.d/udev.dist' +maybe chmod 0644 './config-archive/etc/conf.d/urandom' +maybe chmod 0644 './config-archive/etc/conf.d/urandom.dist' maybe chmod 0755 './config-archive/etc/courier' maybe chmod 0755 './config-archive/etc/courier/authlib' maybe chmod 0660 './config-archive/etc/courier/authlib/authdaemonrc' @@ -165,11 +167,52 @@ maybe chmod 0660 './config-archive/etc/courier/authlib/authdaemonrc.dist' maybe chmod 0660 './config-archive/etc/courier/authlib/authdaemonrc.dist.dist' maybe chmod 0644 './config-archive/etc/hosts' maybe chmod 0644 './config-archive/etc/hosts.dist.new' +maybe chmod 0755 './config-archive/etc/init.d' +maybe chmod 0755 './config-archive/etc/init.d/bootmisc' +maybe chmod 0755 './config-archive/etc/init.d/bootmisc.dist' +maybe chmod 0755 './config-archive/etc/init.d/consolefont' +maybe chmod 0755 './config-archive/etc/init.d/consolefont.dist' +maybe chmod 0755 './config-archive/etc/init.d/fsck' +maybe chmod 0755 './config-archive/etc/init.d/fsck.dist' +maybe chmod 0755 './config-archive/etc/init.d/hwclock' +maybe chmod 0755 './config-archive/etc/init.d/hwclock.dist' +maybe chmod 0755 './config-archive/etc/init.d/keymaps' +maybe chmod 0755 './config-archive/etc/init.d/keymaps.dist' +maybe chmod 0755 './config-archive/etc/init.d/modules' +maybe chmod 0755 './config-archive/etc/init.d/modules.dist' +maybe chmod 0755 './config-archive/etc/init.d/net.lo' +maybe chmod 0755 './config-archive/etc/init.d/net.lo.dist' +maybe chmod 0755 './config-archive/etc/init.d/network' +maybe chmod 0755 './config-archive/etc/init.d/network.dist' +maybe chmod 0755 './config-archive/etc/init.d/numlock' +maybe chmod 0755 './config-archive/etc/init.d/numlock.dist' +maybe chmod 0755 './config-archive/etc/init.d/staticroute' +maybe chmod 0755 './config-archive/etc/init.d/staticroute.dist' +maybe chmod 0755 './config-archive/etc/init.d/sysfs' +maybe chmod 0755 './config-archive/etc/init.d/sysfs.dist' +maybe chmod 0755 './config-archive/etc/init.d/termencoding' +maybe chmod 0755 './config-archive/etc/init.d/termencoding.dist' +maybe chmod 0755 './config-archive/etc/init.d/udev' +maybe chmod 0755 './config-archive/etc/init.d/udev-mount' +maybe chmod 0755 './config-archive/etc/init.d/udev-mount.dist' +maybe chmod 0755 './config-archive/etc/init.d/udev-postmount' +maybe chmod 0755 './config-archive/etc/init.d/udev-postmount.dist' +maybe chmod 0755 './config-archive/etc/init.d/udev.dist' +maybe chmod 0755 './config-archive/etc/init.d/urandom' +maybe chmod 0755 './config-archive/etc/init.d/urandom.dist' +maybe chmod 0755 './config-archive/etc/lvm' +maybe chmod 0644 './config-archive/etc/lvm/lvm.conf' +maybe chmod 0644 './config-archive/etc/lvm/lvm.conf.dist' +maybe chmod 0755 './config-archive/etc/pam.d' +maybe chmod 0644 './config-archive/etc/pam.d/system-login' +maybe chmod 0644 './config-archive/etc/pam.d/system-login.dist' maybe chmod 0755 './config-archive/etc/portage' maybe chmod 0755 './config-archive/etc/portage/savedconfig' maybe chmod 0755 './config-archive/etc/portage/savedconfig/sys-apps' maybe chmod 0644 './config-archive/etc/portage/savedconfig/sys-apps/busybox-1.19.3-r1' maybe chmod 0644 './config-archive/etc/portage/savedconfig/sys-apps/busybox-1.19.3-r1.dist' +maybe chmod 0644 './config-archive/etc/rc.conf' +maybe chmod 0644 './config-archive/etc/rc.conf.dist.new' maybe chmod 0644 './config-archive/etc/screenrc' maybe chmod 0644 './config-archive/etc/screenrc.dist.new' maybe chmod 0755 './config-archive/etc/skel' @@ -461,22 +504,6 @@ maybe chmod 0644 './idn.conf.sample' maybe chmod 0644 './idnalias.conf' maybe chmod 0644 './idnalias.conf.sample' maybe chmod 0755 './init.d' -maybe chmod 0755 './init.d/._cfg0000_bootmisc' -maybe chmod 0755 './init.d/._cfg0000_consolefont' -maybe chmod 0755 './init.d/._cfg0000_fsck' -maybe chmod 0755 './init.d/._cfg0000_hwclock' -maybe chmod 0755 './init.d/._cfg0000_keymaps' -maybe chmod 0755 './init.d/._cfg0000_modules' -maybe chmod 0755 './init.d/._cfg0000_net.lo' -maybe chmod 0755 './init.d/._cfg0000_network' -maybe chmod 0755 './init.d/._cfg0000_numlock' -maybe chmod 0755 './init.d/._cfg0000_staticroute' -maybe chmod 0755 './init.d/._cfg0000_sysfs' -maybe chmod 0755 './init.d/._cfg0000_termencoding' -maybe chmod 0755 './init.d/._cfg0000_udev' -maybe chmod 0755 './init.d/._cfg0000_udev-mount' -maybe chmod 0755 './init.d/._cfg0000_udev-postmount' -maybe chmod 0755 './init.d/._cfg0000_urandom' maybe chmod 0755 './init.d/apache2' maybe chmod 0755 './init.d/atd' maybe chmod 0755 './init.d/auditd' @@ -602,7 +629,6 @@ maybe chmod 0644 './logrotate.d/openrc' maybe chmod 0644 './logrotate.d/rsyncd' maybe chmod 0644 './logrotate.d/syslog-ng' maybe chmod 0755 './lvm' -maybe chmod 0644 './lvm/._cfg0000_lvm.conf' maybe chmod 0700 './lvm/archive' maybe chmod 0600 './lvm/archive/vg00_00000.vg' maybe chmod 0700 './lvm/backup' @@ -695,7 +721,6 @@ maybe chown ldap './openldap/ssl/ldap.pem' maybe chgrp ldap './openldap/ssl/ldap.pem' maybe chmod 0400 './openldap/ssl/ldap.pem' maybe chmod 0755 './pam.d' -maybe chmod 0644 './pam.d/._cfg0000_system-login' maybe chmod 0644 './pam.d/atd' maybe chmod 0644 './pam.d/chage' maybe chmod 0644 './pam.d/chfn' diff --git a/conf.d/fsck b/conf.d/fsck index 5d42c9d..16aa575 100644 --- a/conf.d/fsck +++ b/conf.d/fsck @@ -13,6 +13,13 @@ #fsck_passno=">1" #fsck_passno="<2" +# If passno is not enough granularity, you can also specify mountpoints to +# check. This should NOT be used for the default non-multiplexed fsck, or your +# system might not be checked. Additionally, it is mutually exclusive with +# the fsck_passno setting. +#fsck_mnt="" +#fsck_mnt="/home" + # Most modern fs's don't require a full fsck on boot, but for those that do # it may be advisable to skip this when running on battery. # WARNING: Do not turn this off if you have any JFS partitions. diff --git a/conf.d/udev b/conf.d/udev index 6fd1470..12c2afa 100644 --- a/conf.d/udev +++ b/conf.d/udev @@ -11,15 +11,6 @@ persistent_net_disable="no" # as /dev/{cdrom,cdrw,dvd,dvdrw} persistent_cd_disable="no" -# Set to "yes" if you want to save /dev to a tarball on shutdown -# and restore it on startup. This is useful if you have a lot of -# custom device nodes that udev does not handle/know about. -# -# As this option is fragile, we recommend you -# to create your devices in /lib64/udev/devices. -# These will be copied to /dev on boot. -#rc_device_tarball="NO" - # udev can trigger coldplug events which cause services to start and # kernel modules to be loaded. # Services are deferred to start in the boot runlevel. @@ -36,9 +27,6 @@ persistent_cd_disable="no" # Expert options: -# Disable warning about unreliable kernel/udev combination -#unreliable_kernel_warning="no" - # Timeout in seconds to wait for processing of uevents at boot. # There should be no need to change this. #udev_settle_timeout="60" @@ -47,12 +35,12 @@ persistent_cd_disable="no" # udevd --help for possible values #udev_opts="" -# Run udevd --debug and write output to /dev/.udev/udev.log +# Run udevd --debug and write output to $RUNDIR/udev.log # Should not be kept on as it fills diskspace slowly #udev_debug="YES" # Run udevadmin monitor to get a log of all events -# in /dev/.udev/udevmonitor.log +# in $RUNDIR/udevmonitor.log #udev_monitor="YES" # Keep udevmonitor running after populating /dev. diff --git a/conf.d/urandom b/conf.d/urandom index fbaf4e8..f721a24 100644 --- a/conf.d/urandom +++ b/conf.d/urandom @@ -2,4 +2,4 @@ # (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/run/random-seed" +urandom_seed="/var/lib/misc/random-seed" diff --git a/config-archive/etc/conf.d/fsck b/config-archive/etc/conf.d/fsck new file mode 100644 index 0000000..5d42c9d --- /dev/null +++ b/config-archive/etc/conf.d/fsck @@ -0,0 +1,27 @@ +# Pass any arguments to fsck. +# By default we preen. +# Linux systems also force -C0 and -T. +# If fsck_args is not specified then Linux systems also use -A +# (and -R if / is rw) +#fsck_args="-p" + +# We can also specify the passno in /etc/fstab to check +# If you multiplex fsck (ie ln -s fsck /etc/init.d/fsck.late) then you can +# do an fsck outside of the normal scope, say for /home. +# Here are some exampes:- +#fsck_passno="=1 =2" +#fsck_passno=">1" +#fsck_passno="<2" + +# Most modern fs's don't require a full fsck on boot, but for those that do +# it may be advisable to skip this when running on battery. +# WARNING: Do not turn this off if you have any JFS partitions. +fsck_on_battery="YES" + +# fsck_shutdown causes fsck to trigger during shutdown as well as startup. +# The end result of this is that if any periodic non-root filesystem checks are +# scheduled, under normal circumstances the actual check will happen during +# shutdown rather than at next boot. +# This is useful when periodic filesystem checks are causing undesirable +# delays at startup, but such delays at shutdown are acceptable. +fsck_shutdown="NO" diff --git a/conf.d/._cfg0000_fsck b/config-archive/etc/conf.d/fsck.dist similarity index 100% rename from conf.d/._cfg0000_fsck rename to config-archive/etc/conf.d/fsck.dist diff --git a/config-archive/etc/conf.d/udev b/config-archive/etc/conf.d/udev new file mode 100644 index 0000000..6fd1470 --- /dev/null +++ b/config-archive/etc/conf.d/udev @@ -0,0 +1,64 @@ +# /etc/conf.d/udev: config file for udev + +# We discourage to disable persistent-net!! +# this may lead to random interface naming + +# Disable adding new rules for persistent-net +persistent_net_disable="no" + +# Disable adding new rules for persistent-cd +# Disabling this will stop new cdrom devices to appear +# as /dev/{cdrom,cdrw,dvd,dvdrw} +persistent_cd_disable="no" + +# Set to "yes" if you want to save /dev to a tarball on shutdown +# and restore it on startup. This is useful if you have a lot of +# custom device nodes that udev does not handle/know about. +# +# As this option is fragile, we recommend you +# to create your devices in /lib64/udev/devices. +# These will be copied to /dev on boot. +#rc_device_tarball="NO" + +# udev can trigger coldplug events which cause services to start and +# kernel modules to be loaded. +# Services are deferred to start in the boot runlevel. +# Set rc_coldplug="NO" if you don't want this. +# If you want module coldplugging but not coldplugging of services then you +# can disable service coldplugging in baselayout/openrc config files. +# The setting is named different in different versions. +# in /etc/rc.conf: rc_hotplug="!*" or +# in /etc/conf.d/rc: rc_plug_services="!*" +#rc_coldplug="YES" + + + + +# Expert options: + +# Disable warning about unreliable kernel/udev combination +#unreliable_kernel_warning="no" + +# Timeout in seconds to wait for processing of uevents at boot. +# There should be no need to change this. +#udev_settle_timeout="60" + +# Add extra command line options to udevd, use with care +# udevd --help for possible values +#udev_opts="" + +# Run udevd --debug and write output to /dev/.udev/udev.log +# Should not be kept on as it fills diskspace slowly +#udev_debug="YES" + +# Run udevadmin monitor to get a log of all events +# in /dev/.udev/udevmonitor.log +#udev_monitor="YES" + +# Keep udevmonitor running after populating /dev. +#udev_monitor_keep_running="no" + +# Set cmdline options for udevmonitor. +# could be some of --env --kernel --udev +#udev_monitor_opts="--env" + diff --git a/conf.d/._cfg0000_udev b/config-archive/etc/conf.d/udev.dist similarity index 100% rename from conf.d/._cfg0000_udev rename to config-archive/etc/conf.d/udev.dist diff --git a/config-archive/etc/conf.d/urandom b/config-archive/etc/conf.d/urandom new file mode 100644 index 0000000..fbaf4e8 --- /dev/null +++ b/config-archive/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/run/random-seed" diff --git a/conf.d/._cfg0000_urandom b/config-archive/etc/conf.d/urandom.dist similarity index 100% rename from conf.d/._cfg0000_urandom rename to config-archive/etc/conf.d/urandom.dist diff --git a/config-archive/etc/init.d/bootmisc b/config-archive/etc/init.d/bootmisc new file mode 100755 index 0000000..35af097 --- /dev/null +++ b/config-archive/etc/init.d/bootmisc @@ -0,0 +1,171 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +depend() +{ + need localmount + before logger + after clock sysctl + keyword -prefix -timeout +} + +dir_writeable() +{ + mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$ +} + +: ${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 + dir_writeable "$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 +} + +mkutmp() +{ + : >"$1" + # Not all systems have the utmp group + chgrp utmp "$1" 2>/dev/null + chmod 0664 "$1" +} + +start() +{ + # Remove any added console dirs + rm -rf "$RC_LIBEXECDIR"/console/* + + local logw=false runw=false extra= + # Ensure that our basic dirs exist + [ "$RC_UNAME" = Linux ] && extra=/var/lib/misc # Satisfy Linux FHS + for x in /var/log /var/run /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 dir_writeable /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 + + 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 type 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 + fi + + # Clean up /tmp directories + local tmp= + for tmp in ${clean_tmp_dirs:-${wipe_tmp_dirs-/tmp}}; do + cleanup_tmp_dir "$tmp" + done + + if dir_writeable /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 || dir_writeable /var/log; then + # Create an 'after-boot' dmesg log + if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ ]; then + dmesg > /var/log/dmesg + chmod 640 /var/log/dmesg + fi + fi + fi + + [ -w /etc/nologin ] && rm -f /etc/nologin + 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 +} diff --git a/init.d/._cfg0000_bootmisc b/config-archive/etc/init.d/bootmisc.dist similarity index 100% rename from init.d/._cfg0000_bootmisc rename to config-archive/etc/init.d/bootmisc.dist diff --git a/config-archive/etc/init.d/consolefont b/config-archive/etc/init.d/consolefont new file mode 100755 index 0000000..ca9ee31 --- /dev/null +++ b/config-archive/etc/init.d/consolefont @@ -0,0 +1,67 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +description="Sets a font for the consoles." + +depend() +{ + need localmount termencoding + after hotplug bootmisc + keyword -openvz -prefix -uml -vserver -xenu -lxc +} + +start() +{ + ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} + consolefont=${consolefont:-${CONSOLEFONT}} + unicodemap=${unicodemap:-${UNICODEMAP}} + consoletranslation=${consoletranslation:-${CONSOLETRANSLATION}} + + if [ -z "$consolefont" ]; then + ebegin "Using the default console font" + eend 0 + return 0 + fi + + if [ "$ttyn" = 0 ]; then + ebegin "Skipping font setup (rc_tty_number == 0)" + eend 0 + return 0 + fi + + local x= param= sf_param= retval=0 ttydev=/dev/tty + + # Get additional parameters + if [ -n "$consoletranslation" ]; then + param="$param -m $consoletranslation" + fi + if [ -n "${unicodemap}" ]; then + param="$param -u $unicodemap" + fi + + # Set the console font + ebegin "Setting console font [$consolefont]" + [ -d /dev/vc ] && ttydev=/dev/vc/ + x=1 + while [ $x -le $ttyn ]; do + if ! setfont $consolefont $param -C $ttydev$x >/dev/null; then + retval=1 + break + fi + x=$(($x + 1)) + done + eend $retval + + # Store the last font so we can use it ASAP on boot + if [ $retval -eq 0 -a -w "$RC_LIBEXECDIR" ]; then + mkdir -p "$RC_LIBEXECDIR"/console + for font in /usr/share/consolefonts/"$consolefont".*; do + : + done + cp "$font" "$RC_LIBEXECDIR"/console + echo "${font##*/}" >"$RC_LIBEXECDIR"/console/font + fi + + return $retval +} diff --git a/init.d/._cfg0000_consolefont b/config-archive/etc/init.d/consolefont.dist similarity index 100% rename from init.d/._cfg0000_consolefont rename to config-archive/etc/init.d/consolefont.dist diff --git a/config-archive/etc/init.d/fsck b/config-archive/etc/init.d/fsck new file mode 100755 index 0000000..3960553 --- /dev/null +++ b/config-archive/etc/init.d/fsck @@ -0,0 +1,109 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +description="Check and repair filesystems according to /etc/fstab" +_IFS=" +" + +depend() +{ + use dev clock modules + keyword -jail -openvz -prefix -timeout -vserver -lxc +} + +_abort() { + rc-abort + return 1 +} + +# We should only reboot when first booting +_reboot() { + if [ "$RC_RUNLEVEL" = "$RC_BOOTLEVEL" ]; then + reboot "$@" + _abort || return 1 + fi +} + +_forcefsck() +{ + [ -e /forcefsck ] || get_bootparam forcefsck +} + +start() +{ + local fsck_opts= p= check_extra= + + if [ -e /fastboot ]; then + ewarn "Skipping fsck due to /fastboot" + return 0 + fi + if _forcefsck; then + fsck_opts="$fsck_opts -f" + check_extra="(check forced)" + elif ! yesno ${fsck_on_battery:-YES} && ! on_ac_power; then + ewarn "Skipping fsck due to not being on AC power" + return 0 + fi + + if [ -n "$fsck_passno" ]; then + check_extra="[passno $fsck_passno] $check_extra" + fi + ebegin "Checking local filesystems $check_extra" + for p in $fsck_passno; do + local IFS="$_IFS" + case "$p" in + [0-9]*) p="=$p";; + esac + set -- "$@" $(fstabinfo --passno "$p") + unset IFS + done + + if [ "$RC_UNAME" = Linux ]; then + fsck_opts="$fsck_opts -C0 -T" + if [ -z "$fsck_passno" ]; then + fsck_args=${fsck_args--A -p} + if echo 2>/dev/null >/.test.$$; then + rm -f /.test.$$ + fsck_opts="$fsck_opts -R" + fi + fi + fi + + trap : INT QUIT + fsck ${fsck_args--p} $fsck_opts "$@" + case $? in + 0) eend 0; return 0;; + 1) ewend 1 "Filesystems repaired"; return 0;; + 2|3) if [ "$RC_UNAME" = Linux ]; then + ewend 1 "Filesystems repaired, but reboot needed" + _reboot -f + else + ewend 1 "Filesystems still have errors;" \ + "manual fsck required" + _abort + fi;; + 4) if [ "$RC_UNAME" = Linux ]; then + ewend 1 "Fileystem errors left uncorrected, aborting" + _abort + else + ewend 1 "Filesystems repaired, but reboot needed" + _reboot + fi;; + 8) ewend 1 "Operational error"; return 0;; + 12) ewend 1 "fsck interupted";; + *) eend 2 "Filesystems couldn't be fixed";; + esac + _abort || return 1 +} + +stop() +{ + # Fake function so we always shutdown correctly. + _abort() { return 0; } + _reboot() { return 0; } + _forcefsck() { return 1; } + + yesno $fsck_shutdown && start + return 0 +} diff --git a/init.d/._cfg0000_fsck b/config-archive/etc/init.d/fsck.dist similarity index 100% rename from init.d/._cfg0000_fsck rename to config-archive/etc/init.d/fsck.dist diff --git a/config-archive/etc/init.d/hwclock b/config-archive/etc/init.d/hwclock new file mode 100755 index 0000000..20a9859 --- /dev/null +++ b/config-archive/etc/init.d/hwclock @@ -0,0 +1,146 @@ +#!/sbin/runscript +# Copyright (c) 2007-2008 Roy Marples +# Released under the 2-clause BSD license. + +extra_commands="save show" + +description="Sets the local clock to UTC or Local Time." +description_save="Saves the current time in the BIOS." +description_show="Displays the current time in the BIOS." + +: ${clock_adjfile:=${CLOCK_ADJFILE}} +: ${clock_args:=${CLOCK_OPTS}} +: ${clock_systohc:=${CLOCK_SYSTOHC}} +: ${clock:=${CLOCK:-UTC}} +if [ "$clock" = "UTC" ]; then + utc="UTC" + utc_cmd="--utc" +else + utc="Local Time" + utc_cmd="--localtime" +fi + +depend() +{ + provide clock + if yesno $clock_adjfile; then + use root + else + before * + fi + keyword -openvz -prefix -uml -vserver -xenu -lxc +} + +setupopts() +{ + case "$(uname -m)" in + s390*) + utc="s390" + ;; + *) + if [ -e /proc/devices ] && \ + grep -q " cobd$" /proc/devices + then + utc="coLinux" + fi + ;; + esac + + case "$utc" in + UTC|Local" "Time);; + *) unset utc_cmd;; + esac +} + +# hwclock doesn't always return non zero on error +_hwclock() +{ + local err="$(hwclock "$@" 2>&1 >/dev/null)" + + [ -z "$err" ] && return 0 + echo "${err}" >&2 + return 1 +} + +start() +{ + local retval=0 errstr="" + 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 + local rtc= + for rtc in /dev/rtc /dev/rtc[0-9]*; do + [ -e "$rtc" ] && break + done + if [ ! -e "${rtc}" ]; then + modprobe -q rtc-cmos || modprobe -q rtc || modprobe -q genrtc + fi + fi + + if [ -e /etc/adjtime ] && yesno $clock_adjfile; then + _hwclock --adjust $utc_cmd + retval=$(($retval + $?)) + fi + + # If setting UTC, don't bother to run hwclock when first booting + # as that's the default + if [ "$PREVLEVEL" != N -o \ + "$utc_cmd" != --utc -o \ + -n "$clock_args" ]; + then + if yesno $clock_hctosys; then + _hwclock --hctosys $utc_cmd $clock_args + else + _hwclock --systz $utc_cmd $clock_args + fi + retval=$(($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 || return 0 + + local retval=0 errstr="" + setupopts + + [ -z "$utc_cmd" ] && return 0 + + ebegin "Setting hardware clock using the system clock" "[$utc]" + + if ! yesno $clock_adjfile; then + # Some implementations don't handle adjustments + if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-noadjfile"; then + utc_cmd="$utc_cmd --noadjfile" + fi + fi + + _hwclock --systohc $utc_cmd $clock_args + retval=$? + + eend $retval "Failed to sync clocks" +} + +save() +{ + clock_systohc=yes + stop +} + +show() +{ + setupopts + hwclock --show "$utc_cmd" $clock_args +} diff --git a/init.d/._cfg0000_hwclock b/config-archive/etc/init.d/hwclock.dist similarity index 100% rename from init.d/._cfg0000_hwclock rename to config-archive/etc/init.d/hwclock.dist diff --git a/config-archive/etc/init.d/keymaps b/config-archive/etc/init.d/keymaps new file mode 100755 index 0000000..8ab72fd --- /dev/null +++ b/config-archive/etc/init.d/keymaps @@ -0,0 +1,70 @@ +#!/sbin/runscript +# Copyright (c) 2007-2008 Roy Marples +# Released under the 2-clause BSD license. + +description="Applies a keymap for the consoles." + +depend() +{ + need localmount termencoding + after bootmisc + keyword -openvz -prefix -uml -vserver -xenu -lxc +} + +start() +{ + ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} + : ${unicode:=$UNICODE} + : ${keymap:=$KEYMAP} + : ${extended_keymaps:=$EXTENDED_KEYMAPS} + : ${windowkeys:=$SET_WINDOWSKEYS} + : ${fix_euro:=$FIX_EURO} + : ${dumpkeys_charset:=${DUMPKEYS_CHARSET}} + + if [ -z "$keymap" ]; then + eerror "You need to setup keymap in /etc/conf.d/keymaps first" + return 1 + fi + + local ttydev=/dev/tty n= + [ -d /dev/vc ] && ttydev=/dev/vc/ + + # Force linux keycodes for PPC. + if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]; then + echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes + fi + + local wkeys= kmode="-a" msg="ASCII" + if yesno $unicode; then + kmode="-u" + msg="UTF-8" + fi + yesno $windowkeys && wkeys="windowkeys" + + # Set terminal encoding to either ASCII or UNICODE. + # See utf-8(7) for more information. + ebegin "Setting keyboard mode [$msg]" + n=1 + while [ $n -le $ttyn ]; do + kbd_mode $kmode -C $ttydev$n + n=$(($n + 1)) + done + eend 0 + + ebegin "Loading key mappings [$keymap]" + loadkeys -q $wkeys $keymap $extended_keymaps + eend $? "Error loading key mappings" || return $? + + if yesno $fix_euro; then + ebegin "Fixing font for euro symbol" + # Fix some fonts displaying the Euro, #173528. + echo "altgr keycode 18 = U+20AC" | loadkeys -q + eend $? + fi + + # Save the keymapping for use immediately at boot + if [ -w "$RC_LIBEXECDIR" ]; then + mkdir -p "$RC_LIBEXECDIR"/console + dumpkeys >"$RC_LIBEXECDIR"/console/keymap + fi +} diff --git a/init.d/._cfg0000_keymaps b/config-archive/etc/init.d/keymaps.dist similarity index 100% rename from init.d/._cfg0000_keymaps rename to config-archive/etc/init.d/keymaps.dist diff --git a/config-archive/etc/init.d/modules b/config-archive/etc/init.d/modules new file mode 100755 index 0000000..3fa5867 --- /dev/null +++ b/config-archive/etc/init.d/modules @@ -0,0 +1,63 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +description="Loads a user defined list of kernel modules." + +depend() +{ + use isapnp + keyword -openvz -prefix -vserver -lxc +} + +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=$(($cnt + 1)) + done + einfo "Autoloaded $cnt module(s)" +} diff --git a/init.d/._cfg0000_modules b/config-archive/etc/init.d/modules.dist similarity index 100% rename from init.d/._cfg0000_modules rename to config-archive/etc/init.d/modules.dist diff --git a/config-archive/etc/init.d/net.lo b/config-archive/etc/init.d/net.lo new file mode 100755 index 0000000..6f8b5b1 --- /dev/null +++ b/config-archive/etc/init.d/net.lo @@ -0,0 +1,737 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +MODULESDIR="${RC_LIBEXECDIR}/net" +MODULESLIST="${RC_SVCDIR}/nettree" +_config_vars="config routes" + +[ -z "${IN_BACKGROUND}" ] && IN_BACKGROUND="NO" + +description="Configures network interfaces." + +# Handy var so we don't have to embed new lines everywhere for array splitting +__IFS=" +" +depend() +{ + local IFACE=${RC_SVCNAME#*.} + local IFVAR=$(shell_var "${IFACE}") + + need localmount + after bootmisc + provide net + keyword -jail -prefix -vserver + + case "${IFACE}" in + lo|lo0);; + *) after net.lo net.lo0;; + esac + + if [ "$(command -v "depend_${IFVAR}")" = "depend_${IFVAR}" ]; then + depend_${IFVAR} + fi + + local dep= prov= + for dep in need use before after provide keyword; do + eval prov=\$rc_${dep}_${IFVAR} + if [ -n "${prov}" ]; then + ${dep} ${prov} + fi + done +} + +# Support bash arrays - sigh +_array_helper() +{ + local _a= + + eval _a=\$$1 + _a=$(echo "${_a}" | sed -e 's:^[[:space:]]*::' -e 's:[[:space:]]*$::' -e '/^$/d' -e 's:[[:space:]]\{1,\}: :g') + + [ -n "${_a}" ] && printf "%s\n" "${_a}" +} + +_get_array() +{ + local _a= + if [ -n "${BASH}" ]; then + case "$(declare -p "$1" 2>/dev/null)" in + "declare -a "*) + ewarn "You are using a bash array for $1." + ewarn "This feature will be removed in the future." + ewarn "Please see net.example for the correct format for $1." + eval "set -- \"\${$1[@]}\"" + for _a; do + printf "%s\n" "${_a}" + done + return 0 + ;; + esac + fi + + _array_helper $1 +} + +# Flatten bash arrays to simple strings +_flatten_array() +{ + if [ -n "${BASH}" ]; then + case "$(declare -p "$1" 2>/dev/null)" in + "declare -a "*) + ewarn "You are using a bash array for $1." + ewarn "This feature will be removed in the future." + ewarn "Please see net.example for the correct format for $1." + eval "set -- \"\${$1[@]}\"" + for x; do + printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")" + done + return 0 + ;; + esac + fi + + _array_helper $1 +} + +_wait_for_carrier() +{ + local timeout= efunc=einfon + + _has_carrier && return 0 + + eval timeout=\$carrier_timeout_${IFVAR} + timeout=${timeout:-${carrier_timeout:-5}} + + # Incase users don't want this nice feature ... + [ ${timeout} -le 0 ] && return 0 + + yesno ${RC_PARALLEL} && efunc=einfo + ${efunc} "Waiting for carrier (${timeout} seconds) " + while [ ${timeout} -gt 0 ]; do + sleep 1 + if _has_carrier; then + [ "${efunc}" = "einfon" ] && echo + eend 0 + return 0 + fi + timeout=$((${timeout} - 1)) + [ "${efunc}" = "einfon" ] && printf "." + done + + [ "${efunc}" = "einfon" ] && echo + eend 1 + return 1 +} + +_netmask2cidr() +{ + # Some shells cannot handle hex arithmetic, so we massage it slightly + # Buggy shells include FreeBSD sh, dash and busybox. + # bash and NetBSD sh don't need this. + case $1 in + 0x*) + local hex=${1#0x*} quad= + while [ -n "${hex}" ]; do + local lastbut2=${hex#??*} + quad=${quad}${quad:+.}0x${hex%${lastbut2}*} + hex=${lastbut2} + done + set -- ${quad} + ;; + esac + + local i= len= + local IFS=. + for i in $1; do + while [ ${i} != "0" ]; do + len=$((${len} + ${i} % 2)) + i=$((${i} >> 1)) + done + done + + echo "${len}" +} + +_configure_variables() +{ + local var= v= t= + + for var in ${_config_vars}; do + local v= + for t; do + eval v=\$${var}_${t} + if [ -n "${v}" ]; then + eval ${var}_${IFVAR}=\$${var}_${t} + continue 2 + fi + done + done +} + +_show_address() +{ + einfo "received address $(_get_inet_address "${IFACE}")" +} + +# Basically sorts our modules into order and saves the list +_gen_module_list() +{ + local x= f= force=$1 + if ! ${force} && [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt "${MODULESDIR}" ]; then + local update=false + for x in "${MODULESDIR}"/*.sh; do + [ -e "${x}" ] || continue + if [ "${x}" -nt "${MODULESLIST}" ]; then + update=true + break + fi + done + ${update} || return 0 + fi + + einfo "Caching network module dependencies" + # Run in a subshell to protect the main script + ( + after() { + eval ${MODULE}_after="\"\${${MODULE}_after}\${${MODULE}_after:+ }$*\"" + } + + before() { + local mod=${MODULE} + local MODULE= + for MODULE; do + after "${mod}" + done + } + + program() { + if [ "$1" = "start" -o "$1" = "stop" ]; then + local s="$1" + shift + eval ${MODULE}_program_${s}="\"\${${MODULE}_program_${s}}\${${MODULE}_program_${s}:+ }$*\"" + else + eval ${MODULE}_program="\"\${${MODULE}_program}\${${MODULE}_program:+ }$*\"" + fi + } + + provide() { + eval ${MODULE}_provide="\"\${${MODULE}_provide}\${${MODULE}_provide:+ }$*\"" + local x + for x in $*; do + eval ${x}_providedby="\"\${${MODULE}_providedby}\${${MODULE}_providedby:+ }${MODULE}\"" + done + } + + for MODULE in "${MODULESDIR}"/*.sh; do + sh -n "${MODULE}" || continue + . "${MODULE}" || continue + MODULE=${MODULE#${MODULESDIR}/} + MODULE=${MODULE%.sh} + eval ${MODULE}_depend + MODULES="${MODULES} ${MODULE}" + done + + VISITED= + SORTED= + visit() { + case " ${VISITED} " in + *" $1 "*) return;; + esac + VISITED="${VISITED} $1" + + eval AFTER=\$${1}_after + for MODULE in ${AFTER}; do + eval PROVIDEDBY=\$${MODULE}_providedby + if [ -n "${PROVIDEDBY}" ]; then + for MODULE in ${PROVIDEDBY}; do + visit "${MODULE}" + done + else + visit "${MODULE}" + fi + done + + eval PROVIDE=\$${1}_provide + for MODULE in ${PROVIDE}; do + visit "${MODULE}" + done + + eval PROVIDEDBY=\$${1}_providedby + [ -z "${PROVIDEDBY}" ] && SORTED="${SORTED} $1" + } + + for MODULE in ${MODULES}; do + visit "${MODULE}" + done + + printf "" > "${MODULESLIST}" + i=0 + for MODULE in ${SORTED}; do + eval PROGRAM=\$${MODULE}_program + eval PROGRAM_START=\$${MODULE}_program_start + eval PROGRAM_STOP=\$${MODULE}_program_stop + eval PROVIDE=\$${MODULE}_provide + echo "module_${i}='${MODULE}'" >> "${MODULESLIST}" + echo "module_${i}_program='${PROGRAM}'" >> "${MODULESLIST}" + echo "module_${i}_program_start='${PROGRAM_START}'" >> "${MODULESLIST}" + echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> "${MODULESLIST}" + echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}" + i=$((${i} + 1)) + done + echo "module_${i}=" >> "${MODULESLIST}" + ) + + return 0 +} + +_load_modules() +{ + local starting=$1 mymods= + + # Ensure our list is up to date + _gen_module_list false + if ! . "${MODULESLIST}"; then + _gen_module_list true + . "${MODULESLIST}" + fi + + MODULES= + if [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then + eval mymods=\$modules_${IFVAR} + [ -z "${mymods}" ] && mymods=${modules} + fi + + local i=-1 x= mod= f= provides= + while true; do + i=$((${i} + 1)) + eval mod=\$module_${i} + [ -z "${mod}" ] && break + [ -e "${MODULESDIR}/${mod}.sh" ] || continue + + eval set -- \$module_${i}_program + if [ -n "$1" ]; then + x= + for x; do + [ -x "${x}" ] && break + done + [ -x "${x}" ] || continue + fi + if ${starting}; then + eval set -- \$module_${i}_program_start + else + eval set -- \$module_${i}_program_stop + fi + if [ -n "$1" ]; then + x= + for x; do + case "${x}" in + /*) [ -x "${x}" ] && break;; + *) type "${x}" >/dev/null 2>&1 && break;; + esac + unset x + done + [ -n "${x}" ] || continue + fi + + eval provides=\$module_${i}_provide + if ${starting}; then + case " ${mymods} " in + *" !${mod} "*) continue;; + *" !${provides} "*) [ -n "${provides}" ] && continue;; + esac + fi + MODULES="${MODULES}${MODULES:+ }${mod}" + + # Now load and wrap our functions + if ! . "${MODULESDIR}/${mod}.sh"; then + eend 1 "${RC_SVCNAME}: error loading module \`${mod}'" + exit 1 + fi + + [ -z "${provides}" ] && continue + + # Wrap our provides + local f= + for f in pre_start start post_start; do + eval "${provides}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }" + done + + eval module_${mod}_provides="${provides}" + eval module_${provides}_providedby="${mod}" + done + + # Wrap our preferred modules + for mod in ${mymods}; do + case " ${MODULES} " in + *" ${mod} "*) + eval x=\$module_${mod}_provides + [ -z "${x}" ] && continue + for f in pre_start start post_start; do + eval "${x}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }" + done + eval module_${x}_providedby="${mod}" + ;; + esac + done + + # Finally remove any duplicated provides from our list if we're starting + # Otherwise reverse the list + local LIST="${MODULES}" p= + MODULES= + if ${starting}; then + for mod in ${LIST}; do + eval x=\$module_${mod}_provides + if [ -n "${x}" ]; then + eval p=\$module_${x}_providedby + [ "${mod}" != "${p}" ] && continue + fi + MODULES="${MODULES}${MODULES:+ }${mod}" + done + else + for mod in ${LIST}; do + MODULES="${mod}${MODULES:+ }${MODULES}" + done + fi + + veinfo "Loaded modules: ${MODULES}" +} + +_load_config() +{ + local config="$(_get_array "config_${IFVAR}")" + local fallback="$(_get_array fallback_${IFVAR})" + + config_index=0 + local IFS="$__IFS" + set -- ${config} + + # We should support a space separated array for cidr configs + if [ $# = 1 ]; then + unset IFS + set -- ${config} + # Of course, we may have a single address added old style. + case "$2" in + netmask|broadcast|brd|brd+|peer|pointopoint) + local IFS="$__IFS" + set -- ${config} + ;; + esac + fi + + # Ensure that loopback has the correct address + if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then + if [ "$1" != "null" ]; then + config_0="127.0.0.1/8" + config_index=1 + fi + else + if [ -z "$1" ]; then + ewarn "No configuration specified; defaulting to DHCP" + config_0="dhcp" + config_index=1 + fi + fi + + + # We store our config in an array like vars + # so modules can influence it + for cmd; do + eval config_${config_index}="'${cmd}'" + config_index=$((${config_index} + 1)) + done + # Terminate the list + eval config_${config_index}= + + config_index=0 + for cmd in ${fallback}; do + eval fallback_${config_index}="'${cmd}'" + config_index=$((${config_index} + 1)) + done + # Terminate the list + eval fallback_${config_index}= + + # Don't set to zero, so any net modules don't have to do anything extra + config_index=-1 +} + +# Support functions +_run_if() +{ + local cmd=$1 iface=$2 ifr=${IFACE} ifv=${IFVAR} + # Ensure that we don't stamp on real values + local IFACE= IFVAR= + shift + if [ -n "${iface}" ]; then + IFACE="${iface}" + [ "${iface}" != "${ifr}" ] && IFVAR=$(shell_var "${IFACE}") + else + IFACE=${ifr} + IFVAR=${ifv} + fi + ${cmd} +} +interface_exists() +{ + _run_if _exists "$@" +} +interface_up() +{ + _run_if _up "$@" +} +interface_down() +{ + _run_if _down "$@" +} + +start() +{ + local IFACE=${RC_SVCNAME#*.} oneworked=false fallback=false module= + local IFVAR=$(shell_var "${IFACE}") cmd= our_metric= + local metric=0 + + einfo "Bringing up interface ${IFACE}" + eindent + + if [ -z "${MODULES}" ]; then + local MODULES= + _load_modules true + fi + + # We up the iface twice if we have a preup to ensure it's up if + # available in preup and afterwards incase the user inadvertently + # brings it down + if [ "$(command -v preup)" = "preup" ]; then + _up 2>/dev/null + ebegin "Running preup" + eindent + preup || return 1 + eoutdent + fi + + _up 2>/dev/null + + for module in ${MODULES}; do + if [ "$(command -v "${module}_pre_start")" = "${module}_pre_start" ]; then + ${module}_pre_start || exit $? + fi + done + + if ! _exists; then + eerror "ERROR: interface ${IFACE} does not exist" + eerror "Ensure that you have loaded the correct kernel module for your hardware" + return 1 + fi + + if ! _wait_for_carrier; then + if service_started devd; then + ewarn "no carrier, but devd will start us when we have one" + mark_service_inactive "${RC_SVCNAME}" + else + eerror "no carrier" + fi + return 1 + fi + + local config= config_index= + _load_config + config_index=0 + + eval our_metric=\$metric_${IFVAR} + if [ -n "${our_metric}" ]; then + metric=${our_metric} + elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then + metric=$((${metric} + $(_ifindex))) + fi + + while true; do + eval config=\$config_${config_index} + [ -z "${config}" ] && break + + set -- ${config} + if [ "$1" != "null" -a "$1" != "noop" ]; then + ebegin "$1" + fi + eindent + case "$1" in + noop) + if [ -n "$(_get_inet_address)" ]; then + oneworked=true + break + fi + ;; + null) :;; + [0-9]*|*:*) _add_address ${config};; + *) + if [ "$(command -v "${config}_start")" = "${config}_start" ]; then + "${config}"_start + else + eerror "nothing provides \`${config}'" + fi + ;; + esac + if eend $?; then + oneworked=true + else + eval config=\$fallback_${config_index} + if [ -n "${config}" ]; then + fallback=true + eoutdent + ewarn "Trying fallback configuration ${config}" + eindent + eval config_${config_index}=\$config + unset fallback_${config_index} + config_index=$((${config_index} - 1)) + fi + fi + eoutdent + config_index=$((${config_index} + 1)) + done + + if ! ${oneworked}; then + if [ "$(command -v failup)" = "failup" ]; then + ebegin "Running failup" + eindent + failup + eoutdent + fi + return 1 + fi + + local hidefirstroute=false first=true routes= + if ${fallback}; then + routes="$(_get_array "fallback_routes_${IFVAR}")" + fi + if [ -z "${routes}" ]; then + routes="$(_get_array "routes_${IFVAR}")" + fi + if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then + if [ "${config_0}" != "null" ]; then + routes="127.0.0.0/8 via 127.0.0.1 +${routes}" + hidefirstroute=true + fi + fi + + local OIFS="${IFS}" SIFS="${IFS-y}" + local IFS="$__IFS" + for cmd in ${routes}; do + unset IFS + if ${first}; then + first=false + einfo "Adding routes" + fi + eindent + ebegin ${cmd} + # Work out if we're a host or a net if not told + case ${cmd} in + -net" "*|-host" "*);; + *" "netmask" "*) cmd="-net ${cmd}";; + *.*.*.*/32*) cmd="-host ${cmd}";; + *.*.*.*/*|0.0.0.0|0.0.0.0" "*) cmd="-net ${cmd}";; + default|default" "*) cmd="-net ${cmd}";; + *) cmd="-host ${cmd}";; + esac + if ${hidefirstroute}; then + _add_route ${cmd} >/dev/null 2>&1 + hidefirstroute=false + else + _add_route ${cmd} >/dev/null + fi + eend $? + eoutdent + done + if [ "${SIFS}" = "y" ]; then + unset IFS + else + IFS="${OIFS}" + fi + + for module in ${MODULES}; do + if [ "$(command -v "${module}_post_start")" = "${module}_post_start" ]; then + ${module}_post_start || exit $? + fi + done + + if [ "$(command -v postup)" = "postup" ]; then + ebegin "Running postup" + eindent + postup + eoutdent + fi + + return 0 +} + +stop() +{ + local IFACE=${RC_SVCNAME#*.} module= + local IFVAR=$(shell_var "${IFACE}") opts= + + einfo "Bringing down interface ${IFACE}" + eindent + + if [ -z "${MODULES}" ]; then + local MODULES= + _load_modules false + fi + + if [ "$(command -v predown)" = "predown" ]; then + ebegin "Running predown" + eindent + predown || return 1 + eoutdent + else + if is_net_fs /; then + eerror "root filesystem is network mounted -- can't stop ${IFACE}" + return 1 + fi + fi + + for module in ${MODULES}; do + if [ "$(command -v "${module}_pre_stop")" = "${module}_pre_stop" ]; then + ${module}_pre_stop || exit $? + fi + done + + for module in ${MODULES}; do + if [ "$(command -v "${module}_stop")" = "${module}_stop" ]; then + ${module}_stop + fi + done + + # Only delete addresses for interfaces that exist + if _exists; then + # PPP can manage it's own addresses when IN_BACKGROUND + # Important in case "demand" set on the ppp link + if ! (yesno ${IN_BACKGROUND} && is_ppp) ; then + _delete_addresses "${IFACE}" + fi + fi + + for module in ${MODULES}; do + if [ "$(command -v "${module}_post_stop")" = "${module}_post_stop" ]; then + ${module}_post_stop + fi + done + + # If not in background, and not loopback then bring the interface down + # unless overridden. + if ! yesno ${IN_BACKGROUND} && \ + [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then + eval module=\$ifdown_${IFVAR} + module=${module:-${ifdown:-YES}} + yesno ${module} && _down 2>/dev/null + fi + + type resolvconf >/dev/null 2>&1 && resolvconf -d "${IFACE}" 2>/dev/null + + if [ "$(command -v "postdown")" = "postdown" ]; then + ebegin "Running postdown" + eindent + postdown + eoutdent + fi + + return 0 +} diff --git a/init.d/._cfg0000_net.lo b/config-archive/etc/init.d/net.lo.dist similarity index 100% rename from init.d/._cfg0000_net.lo rename to config-archive/etc/init.d/net.lo.dist diff --git a/config-archive/etc/init.d/network b/config-archive/etc/init.d/network new file mode 100755 index 0000000..9f8ac71 --- /dev/null +++ b/config-archive/etc/init.d/network @@ -0,0 +1,352 @@ +#!/sbin/runscript +# Copyright (c) 2009 Roy Marples +# 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 + provide net + keyword -jail -prefix -vserver +} + +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%%:*} + [ "$i" != "$w" ] || continue + if [ "$cmd" = u ]; then + ifconfig "$i" | grep -q "[ ]*UP" || continue + fi + printf "%s " "$i" + done /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 + if [ "$RC_UNAME" = "Linux" ]; then + ifconfig lo 127.0.0.1 netmask 255.0.0.0 || cr=1 + route add -net 127.0.0.0 netmask 255.0.0.0 \ + gw 127.0.0.1 reject 2>/dev/null + else + ifconfig lo0 127.0.0.1 netmask 255.0.0.0 || cr=1 + route -q add -inet 127.0.0.0 -netmask 255.0.0.0 \ + 127.0.0.1 -reject || cr=1 + fi + 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=$(($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 ${shutdown_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 + 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/init.d/._cfg0000_network b/config-archive/etc/init.d/network.dist similarity index 100% rename from init.d/._cfg0000_network rename to config-archive/etc/init.d/network.dist diff --git a/config-archive/etc/init.d/numlock b/config-archive/etc/init.d/numlock new file mode 100755 index 0000000..bfa6add --- /dev/null +++ b/config-archive/etc/init.d/numlock @@ -0,0 +1,42 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +description="Turns numlock on for the consoles." + +ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} + +depend() +{ + need localmount + keyword -openvz -prefix -vserver -lxc +} + +_setleds() +{ + [ -z "$1" ] && return 1 + + local dev=/dev/tty t= i=1 retval=0 + [ -d /dev/vc ] && dev=/dev/vc/ + + while [ $i -le $ttyn ]; do + setleds -D "$1"num < $dev$i || retval=1 + i=$(($i + 1)) + done + + return $retval +} + +start() +{ + ebegin "Enabling numlock on ttys" + _setleds + + eend $? "Failed to enable numlock" +} + +stop() +{ + ebegin "Disabling numlock on ttys" + _setleds - + eend $? "Failed to disable numlock" +} diff --git a/init.d/._cfg0000_numlock b/config-archive/etc/init.d/numlock.dist similarity index 100% rename from init.d/._cfg0000_numlock rename to config-archive/etc/init.d/numlock.dist diff --git a/config-archive/etc/init.d/staticroute b/config-archive/etc/init.d/staticroute new file mode 100755 index 0000000..558d57e --- /dev/null +++ b/config-archive/etc/init.d/staticroute @@ -0,0 +1,104 @@ +#!/sbin/runscript +# Copyright (c) 2009 Roy Marples +# 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 + keyword -jail -prefix -vserver +} + +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/init.d/._cfg0000_staticroute b/config-archive/etc/init.d/staticroute.dist similarity index 100% rename from init.d/._cfg0000_staticroute rename to config-archive/etc/init.d/staticroute.dist diff --git a/config-archive/etc/init.d/sysfs b/config-archive/etc/init.d/sysfs new file mode 100755 index 0000000..2433d84 --- /dev/null +++ b/config-archive/etc/init.d/sysfs @@ -0,0 +1,64 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +description="Mount the sys filesystem." + +depend() +{ + keyword -prefix -vserver +} + +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 noexec,nosuid,nodev 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 nodev,noexec,nosuid \ + 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 nodev,noexec,nosuid \ + debugfs /sys/kernel/debug + eend $? + fi + fi +} + +start() +{ + local retval + mount_sys + retval=$? + if [ $retval -eq 0 ]; then + mount_misc + fi + return $retval +} diff --git a/init.d/._cfg0000_sysfs b/config-archive/etc/init.d/sysfs.dist similarity index 100% rename from init.d/._cfg0000_sysfs rename to config-archive/etc/init.d/sysfs.dist diff --git a/config-archive/etc/init.d/termencoding b/config-archive/etc/init.d/termencoding new file mode 100755 index 0000000..2c2e6b0 --- /dev/null +++ b/config-archive/etc/init.d/termencoding @@ -0,0 +1,48 @@ +#!/sbin/runscript +# Copyright (c) 2008-2009 Roy Marples +# Released under the 2-clause BSD license. + +description="Configures terminal encoding." + +ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} +: ${unicode:=${UNICODE}} + +depend() +{ + keyword -openvz -prefix -uml -vserver -xenu + need root + after bootmisc +} + +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=$(($n + 1)) + done + + # Save the encoding for use immediately at boot + if [ -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/init.d/._cfg0000_termencoding b/config-archive/etc/init.d/termencoding.dist similarity index 100% rename from init.d/._cfg0000_termencoding rename to config-archive/etc/init.d/termencoding.dist diff --git a/config-archive/etc/init.d/udev b/config-archive/etc/init.d/udev new file mode 100755 index 0000000..833cca0 --- /dev/null +++ b/config-archive/etc/init.d/udev @@ -0,0 +1,272 @@ +#!/sbin/runscript +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Run udevd and create the device-nodes" + +[ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf + +rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}} + +depend() +{ + if [ -f /etc/init.d/sysfs ]; then + # require new enough openrc with sysinit being extra runlevel + # on linux we just check if sysfs init-script exists + # this is to silence out ugly warnings about not-existing sysfs script + provide dev + if yesno "${rc_device_tarball:-no}"; then + need sysfs udev-mount udev-dev-tarball + else + need sysfs udev-mount + fi + before checkfs fsck + + # udev does not work inside vservers + keyword novserver nolxc + fi +} + +cleanup() +{ + # fail more gracely and not leave udevd running + start-stop-daemon --stop --exec /sbin/udevd + exit 1 +} + +disable_hotplug_agent() +{ + if [ -e /proc/sys/kernel/hotplug ]; then + echo "" >/proc/sys/kernel/hotplug + fi +} + +root_link() +{ + /lib64/udev/write_root_link_rule +} + +rules_disable_switch() +{ + # this function disables rules files + # by creating new files with the same name + # in a temp rules directory with higher priority + local f=/dev/.udev/rules.d/"$1" bname="$1" onoff="$2" + + if yesno "${onoff}"; then + echo "# This file disables ${bname} due to /etc/conf.d/udev" \ + > "${f}" + else + rm -f "${f}" + fi +} + +# only called on openrc +is_service_enabled() { + local svc="$1" + + [ ! -e "/etc/init.d/${svc}" ] && return 1 + + [ -e "/etc/runlevels/${RC_BOOTLEVEL}/${svc}" ] && return 0 + [ -e "/etc/runlevels/${RC_DEFAULTLEVEL}/${svc}" ] && return 0 + return 1 +} + +check_openrc_net() +{ + local f=/dev/.udev/rules.d/90-network.rules + is_service_enabled network || return 0 + + # disable network hotplugging + echo "# This file disables network hotplug events calling old-style openrc net scripts" >> "${f}" + echo "# as we use new-style network init script /etc/init.d/network" >> "${f}" +} + +start_udevd() +{ + # load unix domain sockets if built as module, Bug #221253 + if [ -e /proc/modules ] ; then + modprobe -q unix 2>/dev/null + fi + local opts="${udev_opts}" + + ebegin "Starting udevd" + if yesno "${udev_debug:-no}"; then + /sbin/udevd --daemon ${opts} --debug 2>/dev/.udev/udev.log + else + start-stop-daemon --start --exec /sbin/udevd -- --daemon ${opts} + fi + + eend $? +} + +# populate /dev with devices already found by the kernel +populate_dev() +{ + if get_bootparam "nocoldplug" ; then + rc_coldplug="NO" + ewarn "Skipping udev coldplug as requested in kernel cmdline" + fi + + ebegin "Populating /dev with existing devices through uevents" + udevadm control --property=STARTUP=1 + if yesno "${rc_coldplug}"; then + udevadm trigger --action="add" + else + # Do not run any init-scripts, Bug #206518 + udevadm control --property=do_not_run_plug_service=1 + + # only create device nodes + udevadm trigger --action="add" --attr-match=dev + + # run persistent-net stuff, bug 191466 + udevadm trigger --action="add" --subsystem-match=net + fi + eend $? + + # we can speed up booting under these conditions: + # * using devtmpfs so kernel creates device nodes for us + # * only using kernel created device nodes at boot (in /etc/fstab and elsewhere) + # + ebegin "Waiting for uevents to be processed" + udevadm settle --timeout=${udev_settle_timeout:-60} + eend $? + + udevadm control --property=do_not_run_plug_service= + udevadm control --property=STARTUP= + return 0 +} + +# for debugging +start_udevmonitor() +{ + yesno "${udev_monitor:-no}" || return 0 + + udevmonitor_log=/dev/.udev/udevmonitor.log + udevmonitor_pid=/dev/.udev/udevmonitor.pid + + einfo "udev: Running udevadm monitor ${udev_monitor_opts} to get a log of all events" + start-stop-daemon --start --stdout "${udevmonitor_log}" \ + --make-pidfile --pidfile "${udevmonitor_pid}" \ + --background --exec /sbin/udevadm -- monitor ${udev_monitor_opts} +} + +stop_udevmonitor() +{ + yesno "${udev_monitor:-no}" || return 0 + + if yesno "${udev_monitor_keep_running:-no}"; then + ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}" + else + einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}" + start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /sbin/udevadm + fi +} + +display_hotplugged_services() { + local svcfile= svc= services= + for svcfile in "${RC_SVCDIR}"/hotplugged/*; do + svc="${svcfile##*/}" + [ -x "${svcfile}" ] || continue + + services="${services} ${svc}" + done + [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" +} + +check_persistent_net() +{ + # check if there are problems with persistent-net + local syspath= devs= problem=false + for syspath in /sys/class/net/*_rename*; do + if [ -d "${syspath}" ]; then + devs="${devs} ${syspath##*/}" + problem=true + fi + done + + ${problem} || return 0 + + eerror "UDEV: Your system has a problem assigning persistent names" + eerror "to these network interfaces: ${devs}" + + einfo "Checking persistent-net rules:" + # the sed-expression lists all duplicate lines + # from the input, like "uniq -d" does, but uniq + # is installed into /usr/bin and not available at boot. + dups=$( + RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules' + . /lib64/udev/rule_generator.functions + find_all_rules 'NAME=' '.*' | \ + tr ' ' '\n' | \ + sort | \ + sed '$!N; s/^\(.*\)\n\1$/\1/; t; D' + ) + if [ -n "${dups}" ]; then + ewarn "The rules create multiple entries assigning these names:" + eindent + ewarn "${dups}" + eoutdent + else + ewarn "Found no duplicate names in persistent-net rules," + ewarn "there must be some other problem!" + fi + return 1 +} + +check_udev_works() +{ + # should exist on every system, else udev failed + if [ ! -e /dev/zero ]; then + eerror "Assuming udev failed somewhere, as /dev/zero does not exist." + return 1 + fi + return 0 +} + +start() +{ + # do not run this on old baselayout where udev-addon gets loaded + if [ ! -f /etc/init.d/sysfs ]; then + eerror "The $SVCNAME init-script is written for baselayout-2!" + eerror "Please do not use it with baselayout-1!". + return 1 + fi + + check_openrc_net + _start + + display_hotplugged_services + + return 0 +} + +_start() +{ + if [ ! -e /etc/runlevels/${RC_DEFAULTLEVEL:-default}/udev-postmount ]; then + ewarn "You should add udev-postmount service to your default runlevel." + fi + + root_link + rules_disable_switch 75-persistent-net-generator.rules "${persistent_net_disable:-no}" + rules_disable_switch 75-cd-aliases-generator.rules ${persistent_cd_disable:-no} + + disable_hotplug_agent + start_udevd || cleanup + start_udevmonitor + populate_dev || cleanup + + check_persistent_net + + check_udev_works || cleanup + stop_udevmonitor + + return 0 +} + +stop() { + ebegin "Stopping udevd" + start-stop-daemon --stop --exec /sbin/udevd + eend $? +} + diff --git a/config-archive/etc/init.d/udev-mount b/config-archive/etc/init.d/udev-mount new file mode 100755 index 0000000..52cf26b --- /dev/null +++ b/config-archive/etc/init.d/udev-mount @@ -0,0 +1,107 @@ +#!/sbin/runscript +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Mount tmpfs on /dev" +[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev + +# get_KV and KV_to_int +. /lib64/udev/shell-compat-KV.sh + +# FIXME +# Instead of this script testing kernel version, udev itself should +# Maybe something like udevd --test || exit $? +check_kernel() +{ + if [ $(get_KV) -lt $(KV_to_int '2.6.25') ]; then + eerror "Your kernel is too old to work with this version of udev." + eerror "Current udev only supports Linux kernel 2.6.25 and newer." + return 1 + fi + + yesno "${unreliable_kernel_warning:-yes}" || return 0 + + if [ $(get_KV) -lt $(KV_to_int '2.6.27') ]; then + ewarn "You need at least Linux kernel 2.6.27 for reliable operation of udev." + fi + return 0 +} + + +mount_dev_directory() +{ + if mountinfo -q /dev; then + einfo "/dev is already mounted" + return 0 + fi + + # No options are processed here as they should all be in /etc/fstab + ebegin "Mounting /dev" + if ! fstabinfo --mount /dev; then + # we mount devtmpfs if supported + local fs=tmpfs + grep -qs devtmpfs /proc/filesystems && fs=devtmpfs + + # Some devices require exec, Bug #92921 + mount -n -t "$fs" -o "exec,nosuid,mode=0755,size=10M" udev /dev + fi + eend $? +} + +seed_dev() +{ + # Seed /dev with some things that we know we need + + # creating /dev/console, /dev/tty and /dev/tty1 to be able to write + # to $CONSOLE with/without bootsplash before udevd creates it + [ -c /dev/console ] || mknod -m 600 /dev/console c 5 1 + [ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1 + [ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0 + + # udevd will dup its stdin/stdout/stderr to /dev/null + # and we do not want a file which gets buffered in ram + [ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 + ${HAVE_SELINUX} && restorecon /dev/null + + # so udev can add its start-message to dmesg + [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11 + + # Create problematic directories + mkdir -p /dev/pts /dev/shm + ${HAVE_SELINUX} && restorecon -R /dev >/dev/null + return 0 +} + + +start() +{ + # do not run this on too old baselayout - udev-addon is already loaded! + if [ ! -f /etc/init.d/sysfs ]; then + eerror "The $SVCNAME init-script is written for baselayout-2!" + eerror "Please do not use it with baselayout-1!". + return 1 + fi + + _start +} + +_start() +{ + check_kernel || return 1 + mount_dev_directory || return 1 + + # Selinux lovin; /selinux should be mounted by selinux-patched init + if [ -x /sbin/restorecon -a -c /selinux/null ]; then + HAVE_SELINUX=true + restorecon /dev > /selinux/null + else + HAVE_SELINUX=false + fi + + # make sure it exists + mkdir -p /dev/.udev /dev/.udev/rules.d + + seed_dev + + return 0 +} diff --git a/init.d/._cfg0000_udev-mount b/config-archive/etc/init.d/udev-mount.dist similarity index 100% rename from init.d/._cfg0000_udev-mount rename to config-archive/etc/init.d/udev-mount.dist diff --git a/config-archive/etc/init.d/udev-postmount b/config-archive/etc/init.d/udev-postmount new file mode 100755 index 0000000..12a30f6 --- /dev/null +++ b/config-archive/etc/init.d/udev-postmount @@ -0,0 +1,53 @@ +#!/sbin/runscript +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/164/udev-postmount.initd,v 1.1 2010/10/30 13:53:54 zzam Exp $ + +depend() { + need localmount + after dbus # for trigger failed +} + +dir_writeable() +{ + touch "$1"/.test.$$ 2>/dev/null && rm "$1"/.test.$$ +} + +# store persistent-rules that got created while booting +# when / was still read-only +store_persistent_rules() { + # only continue if rules-directory is writable + dir_writeable /etc/udev/rules.d || return 0 + + local file dest + for file in /dev/.udev/tmp-rules--*; do + dest=${file##*tmp-rules--} + [ "$dest" = '*' ] && break + type=${dest##70-persistent-} + type=${type%%.rules} + ebegin "Saving udev persistent ${type} rules to /etc/udev/rules.d" + cat "$file" >> /etc/udev/rules.d/"$dest" && rm -f "$file" + eend $? "Failed moving persistent rules!" + done +} + + +start() { + # check if this system uses udev + [ -d /dev/.udev/ ] || return 0 + + einfo "Doing udev cleanups" + + # Run the events that failed at first udev trigger + udevadm trigger --type=failed -v + + # store persistent-rules that got created while booting + # when / was still read-only + store_persistent_rules +} + +stop() { + : +} + +# vim:ts=4 diff --git a/init.d/._cfg0000_udev-postmount b/config-archive/etc/init.d/udev-postmount.dist similarity index 100% rename from init.d/._cfg0000_udev-postmount rename to config-archive/etc/init.d/udev-postmount.dist diff --git a/init.d/._cfg0000_udev b/config-archive/etc/init.d/udev.dist similarity index 100% rename from init.d/._cfg0000_udev rename to config-archive/etc/init.d/udev.dist diff --git a/config-archive/etc/init.d/urandom b/config-archive/etc/init.d/urandom new file mode 100755 index 0000000..99e1127 --- /dev/null +++ b/config-archive/etc/init.d/urandom @@ -0,0 +1,45 @@ +#!/sbin/runscript +# Copyright (c) 2007-2009 Roy Marples +# Released under the 2-clause BSD license. + +: ${urandom_seed:=${URANDOM_SEED:-/var/run/random-seed}} +description="Initializes the random number generator." + +depend() +{ + need localmount + keyword -jail -openvz -prefix +} + +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/init.d/._cfg0000_urandom b/config-archive/etc/init.d/urandom.dist similarity index 100% rename from init.d/._cfg0000_urandom rename to config-archive/etc/init.d/urandom.dist diff --git a/config-archive/etc/lvm/lvm.conf b/config-archive/etc/lvm/lvm.conf new file mode 100644 index 0000000..567144b --- /dev/null +++ b/config-archive/etc/lvm/lvm.conf @@ -0,0 +1,525 @@ +# This is an example configuration file for the LVM2 system. +# It contains the default settings that would be used if there was no +# /etc/lvm/lvm.conf file. +# +# Refer to 'man lvm.conf' for further information including the file layout. +# +# To put this file in a different directory and override /etc/lvm set +# the environment variable LVM_SYSTEM_DIR before running the tools. + + +# This section allows you to configure which block devices should +# be used by the LVM system. +devices { + + # Where do you want your volume groups to appear ? + dir = "/dev" + + # An array of directories that contain the device nodes you wish + # to use with LVM2. + scan = [ "/dev" ] + + # If several entries in the scanned directories correspond to the + # same block device and the tools need to display a name for device, + # all the pathnames are matched against each item in the following + # list of regular expressions in turn and the first match is used. + preferred_names = [ ] + + # Try to avoid using undescriptive /dev/dm-N names, if present. + # preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ] + + # A filter that tells LVM2 to only use a restricted set of devices. + # The filter consists of an array of regular expressions. These + # expressions can be delimited by a character of your choice, and + # prefixed with either an 'a' (for accept) or 'r' (for reject). + # The first expression found to match a device name determines if + # the device will be accepted or rejected (ignored). Devices that + # don't match any patterns are accepted. + + # Be careful if there there are symbolic links or multiple filesystem + # entries for the same device as each name is checked separately against + # the list of patterns. The effect is that if any name matches any 'a' + # pattern, the device is accepted; otherwise if any name matches any 'r' + # pattern it is rejected; otherwise it is accepted. + + # Don't have more than one filter line active at once: only one gets used. + + # Run vgscan after you change this parameter to ensure that + # the cache file gets regenerated (see below). + # If it doesn't do what you expect, check the output of 'vgscan -vvvv'. + + + # By default we accept every block device: + # Gentoo: we exclude /dev/nbd by default, because it makes a lot of kernel + # noise when you probed while not available. + filter = [ "r|/dev/nbd.*|", "a/.*/" ] + + # Exclude the cdrom drive + # filter = [ "r|/dev/cdrom|" ] + + # When testing I like to work with just loopback devices: + # filter = [ "a/loop/", "r/.*/" ] + + # Or maybe all loops and ide drives except hdc: + # filter =[ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ] + + # Use anchors if you want to be really specific + # filter = [ "a|^/dev/hda8$|", "r/.*/" ] + + # The results of the filtering are cached on disk to avoid + # rescanning dud devices (which can take a very long time). + # By default this cache is stored in the /etc/lvm/cache directory + # in a file called '.cache'. + # It is safe to delete the contents: the tools regenerate it. + # (The old setting 'cache' is still respected if neither of + # these new ones is present.) + cache_dir = "/etc/lvm/cache" + cache_file_prefix = "" + + # You can turn off writing this cache file by setting this to 0. + write_cache_state = 1 + + # Advanced settings. + + # List of pairs of additional acceptable block device types found + # in /proc/devices with maximum (non-zero) number of partitions. + # types = [ "fd", 16 ] + + # If sysfs is mounted (2.6 kernels) restrict device scanning to + # the block devices it believes are valid. + # 1 enables; 0 disables. + sysfs_scan = 1 + + # By default, LVM2 will ignore devices used as components of + # software RAID (md) devices by looking for md superblocks. + # 1 enables; 0 disables. + md_component_detection = 1 + + # By default, if a PV is placed directly upon an md device, LVM2 + # will align its data blocks with the md device's stripe-width. + # 1 enables; 0 disables. + md_chunk_alignment = 1 + + # By default, the start of a PV's data area will be a multiple of + # the 'minimum_io_size' or 'optimal_io_size' exposed in sysfs. + # - minimum_io_size - the smallest request the device can perform + # w/o incurring a read-modify-write penalty (e.g. MD's chunk size) + # - optimal_io_size - the device's preferred unit of receiving I/O + # (e.g. MD's stripe width) + # minimum_io_size is used if optimal_io_size is undefined (0). + # If md_chunk_alignment is enabled, that detects the optimal_io_size. + # This setting takes precedence over md_chunk_alignment. + # 1 enables; 0 disables. + data_alignment_detection = 1 + + # Alignment (in KB) of start of data area when creating a new PV. + # If a PV is placed directly upon an md device and md_chunk_alignment or + # data_alignment_detection is enabled this parameter is ignored. + # Set to 0 for the default alignment of 1MB or page size, if larger. + data_alignment = 0 + + # By default, the start of the PV's aligned data area will be shifted by + # the 'alignment_offset' exposed in sysfs. This offset is often 0 but + # may be non-zero; e.g.: certain 4KB sector drives that compensate for + # windows partitioning will have an alignment_offset of 3584 bytes + # (sector 7 is the lowest aligned logical block, the 4KB sectors start + # at LBA -1, and consequently sector 63 is aligned on a 4KB boundary). + # 1 enables; 0 disables. + data_alignment_offset_detection = 1 + + # If, while scanning the system for PVs, LVM2 encounters a device-mapper + # device that has its I/O suspended, it waits for it to become accessible. + # Set this to 1 to skip such devices. This should only be needed + # in recovery situations. + ignore_suspended_devices = 0 + + # Allow use of pvcreate --uuid without requiring --restorefile. + require_restorefile_with_uuid = 1 +} + +# This section that allows you to configure the nature of the +# information that LVM2 reports. +log { + + # Controls the messages sent to stdout or stderr. + # There are three levels of verbosity, 3 being the most verbose. + verbose = 0 + + # Should we send log messages through syslog? + # 1 is yes; 0 is no. + syslog = 1 + + # Should we log error and debug messages to a file? + # By default there is no log file. + #file = "/var/log/lvm2.log" + + # Should we overwrite the log file each time the program is run? + # By default we append. + overwrite = 0 + + # What level of log messages should we send to the log file and/or syslog? + # There are 6 syslog-like log levels currently in use - 2 to 7 inclusive. + # 7 is the most verbose (LOG_DEBUG). + level = 0 + + # Format of output messages + # Whether or not (1 or 0) to indent messages according to their severity + indent = 1 + + # Whether or not (1 or 0) to display the command name on each line output + command_names = 0 + + # A prefix to use before the message text (but after the command name, + # if selected). Default is two spaces, so you can see/grep the severity + # of each message. + prefix = " " + + # To make the messages look similar to the original LVM tools use: + # indent = 0 + # command_names = 1 + # prefix = " -- " + + # Set this if you want log messages during activation. + # Don't use this in low memory situations (can deadlock). + # activation = 0 +} + +# Configuration of metadata backups and archiving. In LVM2 when we +# talk about a 'backup' we mean making a copy of the metadata for the +# *current* system. The 'archive' contains old metadata configurations. +# Backups are stored in a human readeable text format. +backup { + + # Should we maintain a backup of the current metadata configuration ? + # Use 1 for Yes; 0 for No. + # Think very hard before turning this off! + backup = 1 + + # Where shall we keep it ? + # Remember to back up this directory regularly! + backup_dir = "/etc/lvm/backup" + + # Should we maintain an archive of old metadata configurations. + # Use 1 for Yes; 0 for No. + # On by default. Think very hard before turning this off. + archive = 1 + + # Where should archived files go ? + # Remember to back up this directory regularly! + archive_dir = "/etc/lvm/archive" + + # What is the minimum number of archive files you wish to keep ? + retain_min = 10 + + # What is the minimum time you wish to keep an archive file for ? + retain_days = 30 +} + +# Settings for the running LVM2 in shell (readline) mode. +shell { + + # Number of lines of history to store in ~/.lvm_history + history_size = 100 +} + + +# Miscellaneous global LVM2 settings +global { + + # The file creation mask for any files and directories created. + # Interpreted as octal if the first digit is zero. + umask = 077 + + # Allow other users to read the files + #umask = 022 + + # Enabling test mode means that no changes to the on disk metadata + # will be made. Equivalent to having the -t option on every + # command. Defaults to off. + test = 0 + + # Default value for --units argument + units = "h" + + # Since version 2.02.54, the tools distinguish between powers of + # 1024 bytes (e.g. KiB, MiB, GiB) and powers of 1000 bytes (e.g. + # KB, MB, GB). + # If you have scripts that depend on the old behaviour, set this to 0 + # temporarily until you update them. + si_unit_consistency = 1 + + # Whether or not to communicate with the kernel device-mapper. + # Set to 0 if you want to use the tools to manipulate LVM metadata + # without activating any logical volumes. + # If the device-mapper kernel driver is not present in your kernel + # setting this to 0 should suppress the error messages. + activation = 1 + + # If we can't communicate with device-mapper, should we try running + # the LVM1 tools? + # This option only applies to 2.4 kernels and is provided to help you + # switch between device-mapper kernels and LVM1 kernels. + # The LVM1 tools need to be installed with .lvm1 suffices + # e.g. vgscan.lvm1 and they will stop working after you start using + # the new lvm2 on-disk metadata format. + # The default value is set when the tools are built. + # fallback_to_lvm1 = 0 + # Gentoo: the LVM tools are a seperate package. + fallback_to_lvm1 = 0 + + # The default metadata format that commands should use - "lvm1" or "lvm2". + # The command line override is -M1 or -M2. + # Defaults to "lvm2". + # format = "lvm2" + + # Location of proc filesystem + proc = "/proc" + + # Type of locking to use. Defaults to local file-based locking (1). + # Turn locking off by setting to 0 (dangerous: risks metadata corruption + # if LVM2 commands get run concurrently). + # Type 2 uses the external shared library locking_library. + # Type 3 uses built-in clustered locking. + # Type 4 uses read-only locking which forbids any operations that might + # change metadata. + locking_type = 1 + + # Set to 0 to fail when a lock request cannot be satisfied immediately. + wait_for_locks = 1 + + # If using external locking (type 2) and initialisation fails, + # with this set to 1 an attempt will be made to use the built-in + # clustered locking. + # If you are using a customised locking_library you should set this to 0. + fallback_to_clustered_locking = 1 + + # If an attempt to initialise type 2 or type 3 locking failed, perhaps + # because cluster components such as clvmd are not running, with this set + # to 1 an attempt will be made to use local file-based locking (type 1). + # If this succeeds, only commands against local volume groups will proceed. + # Volume Groups marked as clustered will be ignored. + fallback_to_local_locking = 1 + + # Local non-LV directory that holds file-based locks while commands are + # in progress. A directory like /tmp that may get wiped on reboot is OK. + locking_dir = "/var/lock/lvm" + + # Whenever there are competing read-only and read-write access requests for + # a volume group's metadata, instead of always granting the read-only + # requests immediately, delay them to allow the read-write requests to be + # serviced. Without this setting, write access may be stalled by a high + # volume of read-only requests. + # NB. This option only affects locking_type = 1 viz. local file-based + # locking. + prioritise_write_locks = 1 + + # Other entries can go here to allow you to load shared libraries + # e.g. if support for LVM1 metadata was compiled as a shared library use + # format_libraries = "liblvm2format1.so" + # Full pathnames can be given. + + # Search this directory first for shared libraries. + # library_dir = "/lib" + + # The external locking library to load if locking_type is set to 2. + # locking_library = "liblvm2clusterlock.so" + + # Treat any internal errors as fatal errors, aborting the process that + # encountered the internal error. Please only enable for debugging. + abort_on_internal_errors = 0 +} + +activation { + # Set to 0 to disable udev synchronisation (if compiled into the binaries). + # Processes will not wait for notification from udev. + # They will continue irrespective of any possible udev processing + # in the background. You should only use this if udev is not running + # or has rules that ignore the devices LVM2 creates. + # The command line argument --nodevsync takes precedence over this setting. + # If set to 1 when udev is not running, and there are LVM2 processes + # waiting for udev, run 'dmsetup udevcomplete_all' manually to wake them up. + udev_sync = 1 + + # Set to 0 to disable the udev rules installed by LVM2 (if built with + # --enable-udev_rules). LVM2 will then manage the /dev nodes and symlinks + # for active logical volumes directly itself. + # N.B. Manual intervention may be required if this setting is changed + # while any logical volumes are active. + udev_rules = 1 + + # How to fill in missing stripes if activating an incomplete volume. + # Using "error" will make inaccessible parts of the device return + # I/O errors on access. You can instead use a device path, in which + # case, that device will be used to in place of missing stripes. + # But note that using anything other than "error" with mirrored + # or snapshotted volumes is likely to result in data corruption. + missing_stripe_filler = "error" + + # How much stack (in KB) to reserve for use while devices suspended + reserved_stack = 256 + + # How much memory (in KB) to reserve for use while devices suspended + reserved_memory = 8192 + + # Nice value used while devices suspended + process_priority = -18 + + # If volume_list is defined, each LV is only activated if there is a + # match against the list. + # "vgname" and "vgname/lvname" are matched exactly. + # "@tag" matches any tag set in the LV or VG. + # "@*" matches if any tag defined on the host is also set in the LV or VG + # + # volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ] + + # Size (in KB) of each copy operation when mirroring + mirror_region_size = 512 + + # Setting to use when there is no readahead value stored in the metadata. + # + # "none" - Disable readahead. + # "auto" - Use default value chosen by kernel. + readahead = "auto" + + # 'mirror_image_fault_policy' and 'mirror_log_fault_policy' define + # how a device failure affecting a mirror is handled. + # A mirror is composed of mirror images (copies) and a log. + # A disk log ensures that a mirror does not need to be re-synced + # (all copies made the same) every time a machine reboots or crashes. + # + # In the event of a failure, the specified policy will be used to determine + # what happens. This applies to automatic repairs (when the mirror is being + # monitored by dmeventd) and to manual lvconvert --repair when + # --use-policies is given. + # + # "remove" - Simply remove the faulty device and run without it. If + # the log device fails, the mirror would convert to using + # an in-memory log. This means the mirror will not + # remember its sync status across crashes/reboots and + # the entire mirror will be re-synced. If a + # mirror image fails, the mirror will convert to a + # non-mirrored device if there is only one remaining good + # copy. + # + # "allocate" - Remove the faulty device and try to allocate space on + # a new device to be a replacement for the failed device. + # Using this policy for the log is fast and maintains the + # ability to remember sync state through crashes/reboots. + # Using this policy for a mirror device is slow, as it + # requires the mirror to resynchronize the devices, but it + # will preserve the mirror characteristic of the device. + # This policy acts like "remove" if no suitable device and + # space can be allocated for the replacement. + # + # "allocate_anywhere" - Not yet implemented. Useful to place the log device + # temporarily on same physical volume as one of the mirror + # images. This policy is not recommended for mirror devices + # since it would break the redundant nature of the mirror. This + # policy acts like "remove" if no suitable device and space can + # be allocated for the replacement. + + mirror_log_fault_policy = "allocate" + mirror_image_fault_policy = "remove" + + # While activating devices, I/O to devices being (re)configured is + # suspended, and as a precaution against deadlocks, LVM2 needs to pin + # any memory it is using so it is not paged out. Groups of pages that + # are known not to be accessed during activation need not be pinned + # into memory. Each string listed in this setting is compared against + # each line in /proc/self/maps, and the pages corresponding to any + # lines that match are not pinned. On some systems locale-archive was + # found to make up over 80% of the memory used by the process. + # mlock_filter = [ "locale/locale-archive", "gconv/gconv-modules.cache" ] + + # Set to 1 to revert to the default behaviour prior to version 2.02.62 + # which used mlockall() to pin the whole process's memory while activating + # devices. + use_mlockall = 0 + + # Monitoring is enabled by default when activating logical volumes. + # Set to 0 to disable monitoring or use the --ignoremonitoring option. + monitoring = 1 + + # When pvmove or lvconvert must wait for the kernel to finish + # synchronising or merging data, they check and report progress + # at intervals of this number of seconds. The default is 15 seconds. + # If this is set to 0 and there is only one thing to wait for, there + # are no progress reports, but the process is awoken immediately the + # operation is complete. + polling_interval = 15 +} + + +#################### +# Advanced section # +#################### + +# Metadata settings +# +metadata { + # Default number of copies of metadata to hold on each PV. 0, 1 or 2. + # You might want to override it from the command line with 0 + # when running pvcreate on new PVs which are to be added to large VGs. + # Gentoo: enable for data safety, but PV resize is then disabled. + #pvmetadatacopies = 2 + + # Default number of copies of metadata to maintain for each VG. + # If set to a non-zero value, LVM automatically chooses which of + # the available metadata areas to use to achieve the requested + # number of copies of the VG metadata. If you set a value larger + # than the the total number of metadata areas available then + # metadata is stored in them all. + # The default value of 0 ("unmanaged") disables this automatic + # management and allows you to control which metadata areas + # are used at the individual PV level using 'pvchange + # --metadataignore y/n'. + + # vgmetadatacopies = 0 + + # Approximate default size of on-disk metadata areas in sectors. + # You should increase this if you have large volume groups or + # you want to retain a large on-disk history of your metadata changes. + + # pvmetadatasize = 255 + + # List of directories holding live copies of text format metadata. + # These directories must not be on logical volumes! + # It's possible to use LVM2 with a couple of directories here, + # preferably on different (non-LV) filesystems, and with no other + # on-disk metadata (pvmetadatacopies = 0). Or this can be in + # addition to on-disk metadata areas. + # The feature was originally added to simplify testing and is not + # supported under low memory situations - the machine could lock up. + # + # Never edit any files in these directories by hand unless you + # you are absolutely sure you know what you are doing! Use + # the supplied toolset to make changes (e.g. vgcfgrestore). + + # dirs = [ "/etc/lvm/metadata", "/mnt/disk2/lvm/metadata2" ] +} + +# Event daemon +# +dmeventd { + # mirror_library is the library used when monitoring a mirror device. + # + # "libdevmapper-event-lvm2mirror.so" attempts to recover from + # failures. It removes failed devices from a volume group and + # reconfigures a mirror as necessary. If no mirror library is + # provided, mirrors are not monitored through dmeventd. + + mirror_library = "libdevmapper-event-lvm2mirror.so" + + # snapshot_library is the library used when monitoring a snapshot device. + # + # "libdevmapper-event-lvm2snapshot.so" monitors the filling of + # snapshots and emits a warning through syslog when the use of + # the snapshot exceeds 80%. The warning is repeated when 85%, 90% and + # 95% of the snapshot is filled. + + snapshot_library = "libdevmapper-event-lvm2snapshot.so" + + # Full path of the dmeventd binary. + # + # executable = "/sbin/dmeventd" +} diff --git a/lvm/._cfg0000_lvm.conf b/config-archive/etc/lvm/lvm.conf.dist similarity index 100% rename from lvm/._cfg0000_lvm.conf rename to config-archive/etc/lvm/lvm.conf.dist diff --git a/config-archive/etc/pam.d/system-login b/config-archive/etc/pam.d/system-login new file mode 100644 index 0000000..a20e8f9 --- /dev/null +++ b/config-archive/etc/pam.d/system-login @@ -0,0 +1,19 @@ +auth required pam_tally2.so onerr=succeed +auth required pam_shells.so +auth required pam_nologin.so +auth include system-auth + +account required pam_access.so +account required pam_nologin.so +account include system-auth +account required pam_tally2.so onerr=succeed + +password include system-auth + +session optional pam_loginuid.so +session required pam_env.so +session optional pam_lastlog.so +session include system-auth +session optional pam_motd.so motd=/etc/motd +session optional pam_mail.so + diff --git a/pam.d/._cfg0000_system-login b/config-archive/etc/pam.d/system-login.dist similarity index 100% rename from pam.d/._cfg0000_system-login rename to config-archive/etc/pam.d/system-login.dist diff --git a/config-archive/etc/rc.conf b/config-archive/etc/rc.conf new file mode 100644 index 0000000..9d8afee --- /dev/null +++ b/config-archive/etc/rc.conf @@ -0,0 +1,148 @@ +# 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" +rc_parallel="YES" + +# 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" +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=/sbin/sulogin + +# 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 is a list of services that we allow to be hotplugged. +# By default we do not allow hotplugging. +# A hotplugged service is one started by a dynamic dev manager when a matching +# hardware device is found. +# This service is intrinsically included in the boot runlevel. +# To disable services, prefix with a ! +# Example - rc_hotplug="net.wlan !net.*" +# This allows net.wlan and any service not matching net.* to be plugged. +# Example - rc_hotplug="*" +# This allows all services to be hotplugged +#rc_hotplug="*" + +# 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="YES" + +# 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" + +# 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 + +############################################################################## +# 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="YES" + +# Below is the default list of network fstypes. +# +# afs 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. + +# Some daemons are started and stopped via start-stop-daemon. +# We can set some things on a per service basis, like the nicelevel. +#export SSD_NICELEVEL="-19" + +# Pass ulimit parameters +#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" + +# You can also remove dependencies. +# This is mainly used for saying which servies do NOT provide net. +#rc_net_tap0_provide="!net" + +############################################################################## +# LINUX SPECIFIC OPTIONS + +# This is the subsystem type. Valid options on Linux: +# "" - nothing special +# "lxc" - Linux Containers +# "openvz" - Linux OpenVZ +# "prefix" - Prefix +# "uml" - Usermode Linux +# "vserver" - Linux vserver +# "xen0" - Xen0 Domain +# "xenU" - XenU Domain +# If this is commented out, automatic detection will be attempted. +# Note that autodetection will not work in a prefix environment or in a +# linux container. +# +# This should be set to the value representing the environment this file is +# PRESENTLY in, not the virtualization the environment is capable of. +rc_sys="" + +# This is the number of tty's used in most of the rc-scripts (like +# consolefont, numlock, etc ...) +rc_tty_number=12 + diff --git a/._cfg0000_rc.conf b/config-archive/etc/rc.conf.dist.new similarity index 100% rename from ._cfg0000_rc.conf rename to config-archive/etc/rc.conf.dist.new diff --git a/dispatch-conf.conf b/dispatch-conf.conf index 7eea44c..302ef08 100644 --- a/dispatch-conf.conf +++ b/dispatch-conf.conf @@ -22,7 +22,8 @@ use-rcs=no # %s new file # If using colordiff instead of diff, the less -R option may be required # for correct display. -diff="diff -Nu '%s' '%s'" +#diff="diff -Nu '%s' '%s'" +diff="diff -Nu '%s' '%s' | colordiff" # Set the pager for use with diff commands (this will # cause the PAGER environment variable to be ignored). @@ -44,11 +45,11 @@ replace-cvs=yes # Automerge files comprising only whitespace and/or comments # (yes or no) -replace-wscomments=no +replace-wscomments=yes # Automerge files that the user hasn't modified # (yes or no) -replace-unmodified=no +replace-unmodified=yes # Ignore a version that is identical to the previously merged version, # even though it is different from the current user modified version @@ -58,7 +59,7 @@ replace-unmodified=no ignore-previously-merged=no # Per-session log file of changes made to configuration files -#log-file=/var/log/dispatch-conf.log +log-file=/var/log/dispatch-conf.log # List of frozen files for which dispatch-conf will automatically zap updates #frozen-files="" diff --git a/init.d/bootmisc b/init.d/bootmisc index 35af097..0e03938 100755 --- a/init.d/bootmisc +++ b/init.d/bootmisc @@ -10,7 +10,7 @@ depend() keyword -prefix -timeout } -dir_writeable() +dir_writable() { mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$ } @@ -25,7 +25,7 @@ cleanup_tmp_dir() if ! [ -d "$dir" ]; then mkdir -p "$dir" || return $? fi - dir_writeable "$dir" || return 1 + dir_writable "$dir" || return 1 chmod a+rwt "$dir" 2> /dev/null cd "$dir" || return 1 if yesno $wipe_tmp; then @@ -72,6 +72,26 @@ mkutmp() 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 +} + start() { # Remove any added console dirs @@ -79,8 +99,16 @@ start() local logw=false runw=false extra= # Ensure that our basic dirs exist - [ "$RC_UNAME" = Linux ] && extra=/var/lib/misc # Satisfy Linux FHS - for x in /var/log /var/run /tmp $extra; do + 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" @@ -89,7 +117,12 @@ start() fi done - if dir_writeable /var/run; then + if [ "$RC_UNAME" = Linux -a -d /run ] && false; then + migrate_to_run /var/lock /run/lock + migrate_to_run /var/run /run + fi + + if dir_writable /var/run; then ebegin "Creating user login records" local xtra= [ "$RC_UNAME" = NetBSD ] && xtra=x @@ -131,7 +164,7 @@ start() cleanup_tmp_dir "$tmp" done - if dir_writeable /tmp; then + if dir_writable /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 @@ -144,7 +177,7 @@ start() fi if yesno $log_dmesg; then - if $logw || dir_writeable /var/log; then + if $logw || dir_writable /var/log; then # Create an 'after-boot' dmesg log if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ ]; then dmesg > /var/log/dmesg diff --git a/init.d/consolefont b/init.d/consolefont index ca9ee31..f989d2d 100755 --- a/init.d/consolefont +++ b/init.d/consolefont @@ -49,7 +49,7 @@ start() retval=1 break fi - x=$(($x + 1)) + : $(( x += 1 )) done eend $retval diff --git a/init.d/fsck b/init.d/fsck index 3960553..9cf35b8 100755 --- a/init.d/fsck +++ b/init.d/fsck @@ -48,8 +48,13 @@ start() if [ -n "$fsck_passno" ]; then check_extra="[passno $fsck_passno] $check_extra" + if [ -n "$fsck_mnt" ]; then + eerror "Only 1 of fsck_passno and fsck_mnt must be set!" + return 1 + fi fi ebegin "Checking local filesystems $check_extra" + # Append passno mounts for p in $fsck_passno; do local IFS="$_IFS" case "$p" in @@ -58,10 +63,16 @@ start() set -- "$@" $(fstabinfo --passno "$p") unset IFS done + # Append custom mounts + for m in $fsck_mnt ; do + local IFS="$_IFS" + set -- "$@" "$m" + unset IFS + done if [ "$RC_UNAME" = Linux ]; then fsck_opts="$fsck_opts -C0 -T" - if [ -z "$fsck_passno" ]; then + if [ -z "$fsck_passno" -a -z "$fsck_mnt" ]; then fsck_args=${fsck_args--A -p} if echo 2>/dev/null >/.test.$$; then rm -f /.test.$$ @@ -91,7 +102,7 @@ start() _reboot fi;; 8) ewend 1 "Operational error"; return 0;; - 12) ewend 1 "fsck interupted";; + 12) ewend 1 "fsck interrupted";; *) eend 2 "Filesystems couldn't be fixed";; esac _abort || return 1 diff --git a/init.d/hwclock b/init.d/hwclock index 20a9859..28d675a 100755 --- a/init.d/hwclock +++ b/init.d/hwclock @@ -85,7 +85,7 @@ start() if [ -e /etc/adjtime ] && yesno $clock_adjfile; then _hwclock --adjust $utc_cmd - retval=$(($retval + $?)) + : $(( retval += $? )) fi # If setting UTC, don't bother to run hwclock when first booting @@ -99,7 +99,7 @@ start() else _hwclock --systz $utc_cmd $clock_args fi - retval=$(($retval + $?)) + : $(( retval += $? )) fi eend $retval "Failed to set the system clock" diff --git a/init.d/keymaps b/init.d/keymaps index 8ab72fd..211fdd3 100755 --- a/init.d/keymaps +++ b/init.d/keymaps @@ -47,7 +47,7 @@ start() n=1 while [ $n -le $ttyn ]; do kbd_mode $kmode -C $ttydev$n - n=$(($n + 1)) + : $(( n += 1 )) done eend 0 diff --git a/init.d/modules b/init.d/modules index 3fa5867..17f60ce 100755 --- a/init.d/modules +++ b/init.d/modules @@ -57,7 +57,7 @@ start() [ -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=$(($cnt + 1)) + eend $? "Failed to load $x" && : $(( cnt += 1 )) done einfo "Autoloaded $cnt module(s)" } diff --git a/init.d/net.lo b/init.d/net.lo index 6f8b5b1..2314363 100755 --- a/init.d/net.lo +++ b/init.d/net.lo @@ -21,11 +21,11 @@ depend() need localmount after bootmisc provide net - keyword -jail -prefix -vserver + keyword -shutdown -jail -prefix -vserver case "${IFACE}" in lo|lo0);; - *) after net.lo net.lo0;; + *) after net.lo net.lo0 dbus;; esac if [ "$(command -v "depend_${IFVAR}")" = "depend_${IFVAR}" ]; then @@ -115,7 +115,7 @@ _wait_for_carrier() eend 0 return 0 fi - timeout=$((${timeout} - 1)) + : $(( timeout -= 1 )) [ "${efunc}" = "einfon" ] && printf "." done @@ -144,9 +144,9 @@ _netmask2cidr() local i= len= local IFS=. for i in $1; do - while [ ${i} != "0" ]; do - len=$((${len} + ${i} % 2)) - i=$((${i} >> 1)) + while [ ${i} -ne 0 ]; do + : $(( len += i % 2 )) + : $(( i >>= 1 )) done done @@ -169,6 +169,36 @@ _configure_variables() done } +_which() +{ + local i OIFS + # Empty + [ -z "$1" ] && return + # check paths + OIFS="$IFS" + IFS=: + for i in $PATH ; do + [ -x $i/$1 ] && echo $i/$1 && break + done + IFS=$OIFS +} + +# Like _which, but also consider shell builtins, and multiple alternatives +_program_available() +{ + [ -z "$1" ] && return 0 + local x= + for x; do + case "${x}" in + /*) [ -x "${x}" ] && break;; + *) type "${x}" >/dev/null 2>&1 && break;; + esac + unset x + done + [ -n "${x}" ] && echo $x && return 0 + return 1 +} + _show_address() { einfo "received address $(_get_inet_address "${IFACE}")" @@ -277,7 +307,7 @@ _gen_module_list() echo "module_${i}_program_start='${PROGRAM_START}'" >> "${MODULESLIST}" echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> "${MODULESLIST}" echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}" - i=$((${i} + 1)) + : $(( i += 1 )) done echo "module_${i}=" >> "${MODULESLIST}" ) @@ -304,18 +334,17 @@ _load_modules() local i=-1 x= mod= f= provides= while true; do - i=$((${i} + 1)) + : $(( i += 1 )) eval mod=\$module_${i} [ -z "${mod}" ] && break [ -e "${MODULESDIR}/${mod}.sh" ] || continue eval set -- \$module_${i}_program if [ -n "$1" ]; then - x= - for x; do - [ -x "${x}" ] && break - done - [ -x "${x}" ] || continue + if ! _program_available "$@" >/dev/null; then + vewarn "Skipping module $mod due to missing program: $@" + continue + fi fi if ${starting}; then eval set -- \$module_${i}_program_start @@ -323,15 +352,10 @@ _load_modules() eval set -- \$module_${i}_program_stop fi if [ -n "$1" ]; then - x= - for x; do - case "${x}" in - /*) [ -x "${x}" ] && break;; - *) type "${x}" >/dev/null 2>&1 && break;; - esac - unset x - done - [ -n "${x}" ] || continue + if ! _program_available "$@" >/dev/null; then + vewarn "Skipping module $mod due to missing program: $@" + continue + fi fi eval provides=\$module_${i}_provide @@ -407,16 +431,18 @@ _load_config() set -- ${config} # We should support a space separated array for cidr configs + # But only as long as they do not contain other parameters for the address if [ $# = 1 ]; then unset IFS set -- ${config} # Of course, we may have a single address added old style. - case "$2" in - netmask|broadcast|brd|brd+|peer|pointopoint) - local IFS="$__IFS" - set -- ${config} - ;; - esac + # If the NEXT argument is a v4 or v6 address, it's the next config. + # Otherwise, it's arguments to the first config... + if [ "${2#*.*}" = "${2}" -a "${2#*:*}" = "${2}" ]; then + # Not an IPv4/IPv6 + local IFS="$__IFS" + set -- ${config} + fi fi # Ensure that loopback has the correct address @@ -438,7 +464,7 @@ _load_config() # so modules can influence it for cmd; do eval config_${config_index}="'${cmd}'" - config_index=$((${config_index} + 1)) + : $(( config_index += 1 )) done # Terminate the list eval config_${config_index}= @@ -446,7 +472,7 @@ _load_config() config_index=0 for cmd in ${fallback}; do eval fallback_${config_index}="'${cmd}'" - config_index=$((${config_index} + 1)) + : $(( config_index += 1 )) done # Terminate the list eval fallback_${config_index}= @@ -488,7 +514,9 @@ start() { local IFACE=${RC_SVCNAME#*.} oneworked=false fallback=false module= local IFVAR=$(shell_var "${IFACE}") cmd= our_metric= - local metric=0 + local metric=0 _up_before_preup + eval _up_before_preup="\$up_before_preup_${IFVAR}" + [ -z "${_up_before_preup}" ] && _up_before_preup=$up_before_preup einfo "Bringing up interface ${IFACE}" eindent @@ -502,7 +530,7 @@ start() # available in preup and afterwards incase the user inadvertently # brings it down if [ "$(command -v preup)" = "preup" ]; then - _up 2>/dev/null + yesno "${_up_before_preup:-yes}" && _up 2>/dev/null ebegin "Running preup" eindent preup || return 1 @@ -541,7 +569,7 @@ start() if [ -n "${our_metric}" ]; then metric=${our_metric} elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then - metric=$((${metric} + $(_ifindex))) + : $(( metric += $(_ifindex) )) fi while true; do @@ -581,11 +609,11 @@ start() eindent eval config_${config_index}=\$config unset fallback_${config_index} - config_index=$((${config_index} - 1)) + : $(( config_index -= 1 )) fi fi eoutdent - config_index=$((${config_index} + 1)) + : $(( config_index += 1 )) done if ! ${oneworked}; then diff --git a/init.d/network b/init.d/network index 9f8ac71..7ba4f48 100755 --- a/init.d/network +++ b/init.d/network @@ -219,6 +219,12 @@ start() eend $? fi + ewarn + ewarn "The $RC_SVCNAME script is deprecated and will be" + ewarn "removed in the future." + ewarn "Please use the net.* scripts to manage your network interfaces." + ewarn + einfo "Starting network" routeflush if [ "$RC_UNAME" = "Linux" ]; then @@ -281,7 +287,7 @@ start() tentative || break [ $r = 5 ] && vebegin "Waiting for tentative addresses" sleep 1 - r=$(($r - 1)) + : $(( r -= 1 )) done if [ $r != 5 ]; then [ $r != 0 ] diff --git a/init.d/numlock b/init.d/numlock index bfa6add..e354dfd 100755 --- a/init.d/numlock +++ b/init.d/numlock @@ -21,7 +21,7 @@ _setleds() while [ $i -le $ttyn ]; do setleds -D "$1"num < $dev$i || retval=1 - i=$(($i + 1)) + : $(( i += 1 )) done return $retval diff --git a/init.d/staticroute b/init.d/staticroute index 558d57e..3a5d326 100755 --- a/init.d/staticroute +++ b/init.d/staticroute @@ -93,6 +93,11 @@ do_routes() start() { + ewarn + ewarn "The $RC_SVCNAME script is deprecated and will be" + ewarn "removed in the future." + ewarn "Please use the net.* scripts to manage your network interfaces." + ewarn do_routes "Adding" "add" } diff --git a/init.d/sysfs b/init.d/sysfs index 2433d84..dd3fc0e 100755 --- a/init.d/sysfs +++ b/init.d/sysfs @@ -50,6 +50,43 @@ mount_misc() 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 nodev,noexec,nosuid \ + 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="nodev,noexec,nosuid,mode=755,size=${rc_cgroupsize:-10m}" + mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup + eend $? + fi + fi +} + +mount_cgroups() +{ + yesno ${rc_cgroups:-YES} || return 0 + if [ ! -e /proc/cgroups ]; then + return 0 + fi + + while read name hier groups enabled rest; do + case "${enabled}" in + 1) mkdir /sys/fs/cgroup/${name} + mount -t cgroup -o nodev,noexec,nosuid,${name} \ + ${name} /sys/fs/cgroup/${name} + ;; + esac + done < /proc/cgroups } start() @@ -59,6 +96,11 @@ start() retval=$? if [ $retval -eq 0 ]; then mount_misc + retval=$? + fi + if [ $retval -eq 0 ]; then + mount_cgroups + retval=$? fi return $retval } diff --git a/init.d/termencoding b/init.d/termencoding index 2c2e6b0..d7951d1 100755 --- a/init.d/termencoding +++ b/init.d/termencoding @@ -31,7 +31,7 @@ start() n=1 while [ ${n} -le "$ttyn" ]; do printf "\033%s" "$termencoding" >$ttydev$n - n=$(($n + 1)) + : $(( n += 1 )) done # Save the encoding for use immediately at boot diff --git a/init.d/udev b/init.d/udev index 833cca0..1912c8b 100755 --- a/init.d/udev +++ b/init.d/udev @@ -2,48 +2,83 @@ # Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +command=/sbin/udevd +command_args="--daemon ${udev_opts}" description="Run udevd and create the device-nodes" -[ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf - +persistent_cd_disable="${persistent_cd_disable:-no}" +persistent_net_disable="${persistent_net_disable:-no}" rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}} +udev_debug="${udev_debug:-no}" +udev_monitor="${udev_monitor:-no}" +udev_monitor_keep_running="${udev_monitor_keep_running:-no}" +udev_settle_timeout="${udev_settle_timeout:-60}" +kv_min="${kb_min:-2.6.32}" depend() { - if [ -f /etc/init.d/sysfs ]; then - # require new enough openrc with sysinit being extra runlevel - # on linux we just check if sysfs init-script exists - # this is to silence out ugly warnings about not-existing sysfs script - provide dev - if yesno "${rc_device_tarball:-no}"; then - need sysfs udev-mount udev-dev-tarball - else - need sysfs udev-mount - fi - before checkfs fsck + provide dev + need sysfs udev-mount + before checkfs fsck - # udev does not work inside vservers - keyword novserver nolxc - fi + # udev does not work inside vservers + keyword -vserver -lxc } -cleanup() +KV_to_int() { - # fail more gracely and not leave udevd running - start-stop-daemon --stop --exec /sbin/udevd - exit 1 + [ -z $1 ] && return 1 + + local x=${1%%[!0-9.]*} y= z= + local KV_MAJOR=${x%%.*} + y=${x#*.} + [ "$x" = "$y" ] && y=0.0 + local KV_MINOR=${y%%.*} + z=${y#*.} + [ "$y" = "$z" ] && z=0 + local KV_MICRO=${z%%.*} + local KV_int=$((${KV_MAJOR} * 65536 + ${KV_MINOR} * 256 + ${KV_MICRO} )) + + # We make version 2.2.0 the minimum version we will handle as + # a sanity check ... if its less, we fail ... + [ "${KV_int}" -lt 131584 ] && return 1 + + echo "${KV_int}" } -disable_hotplug_agent() +_RC_GET_KV_CACHE="" +get_KV() { - if [ -e /proc/sys/kernel/hotplug ]; then - echo "" >/proc/sys/kernel/hotplug + if [ -z "${_RC_GET_KV_CACHE}" ] ; then + _RC_GET_KV_CACHE="$(uname -r)" fi + echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" + return $? } -root_link() +# FIXME +# Instead of this script testing kernel version, udev itself should +# Maybe something like udevd --test || exit $? +check_kernel() { - /lib64/udev/write_root_link_rule + if [ $(get_KV) -lt $(KV_to_int ${kv_min}) ]; then + eerror "Your kernel is too old to work with this version of udev." + eerror "Current udev only supports Linux kernel ${kv_min} and newer." + return 1 + fi + return 0 +} + +get_rundir() +{ + echo $(udevadm info --run) +} + +cleanup() +{ + # fail more gracely and not leave udevd running + start-stop-daemon --stop --exec /sbin/udevd + exit 1 } rules_disable_switch() @@ -51,7 +86,7 @@ rules_disable_switch() # this function disables rules files # by creating new files with the same name # in a temp rules directory with higher priority - local f=/dev/.udev/rules.d/"$1" bname="$1" onoff="$2" + local f=$(get_rundir)/rules.d/"$1" bname="$1" onoff="$2" if yesno "${onoff}"; then echo "# This file disables ${bname} due to /etc/conf.d/udev" \ @@ -61,8 +96,8 @@ rules_disable_switch() fi } -# only called on openrc -is_service_enabled() { +is_service_enabled() +{ local svc="$1" [ ! -e "/etc/init.d/${svc}" ] && return 1 @@ -72,35 +107,59 @@ is_service_enabled() { return 1 } -check_openrc_net() +start_pre() { - local f=/dev/.udev/rules.d/90-network.rules - is_service_enabled network || return 0 + if [ -d /run ]; then + checkpath -d -m 0755 -o root:root -q /run/udev + fi - # disable network hotplugging - echo "# This file disables network hotplug events calling old-style openrc net scripts" >> "${f}" - echo "# as we use new-style network init script /etc/init.d/network" >> "${f}" -} + if is_service_enabled network; then + # disable network hotplugging + local f="$(get_rundir)/rules.d/90-network.rules" + echo "# This file disables network hotplug events calling" >> "${f}" + echo "# old-style openrc net scripts" >> "${f}" + echo "# as we use /etc/init.d/network to set up our network" >> "${f}" + fi + + if [ ! -e /etc/runlevels/${RC_DEFAULTLEVEL:-default}/udev-postmount ]; then + ewarn "You should add udev-postmount service to your default runlevel." + fi + + /lib/udev/write_root_link_rule + + rules_disable_switch 75-persistent-net-generator.rules "${persistent_net_disable}" + rules_disable_switch 75-cd-aliases-generator.rules ${persistent_cd_disable} + + if [ -e /proc/sys/kernel/hotplug ]; then + echo "" >/proc/sys/kernel/hotplug + fi -start_udevd() -{ # load unix domain sockets if built as module, Bug #221253 - if [ -e /proc/modules ] ; then - modprobe -q unix 2>/dev/null + # and not yet loaded, Bug #363549 + if [ ! -e /proc/net/unix ]; then + if ! modprobe unix; then + eerror "Cannot load the unix domain socket module" + fi fi - local opts="${udev_opts}" - ebegin "Starting udevd" - if yesno "${udev_debug:-no}"; then - /sbin/udevd --daemon ${opts} --debug 2>/dev/.udev/udev.log - else - start-stop-daemon --start --exec /sbin/udevd -- --daemon ${opts} + if yesno "${udev_debug}"; then + command_args="${command_args} --debug 2> $(get_rundir)/udev.log" fi +} - eend $? +start_udevmonitor() +{ + yesno "${udev_monitor}" || return 0 + + udevmonitor_log="$(get_rundir)/udevmonitor.log" + udevmonitor_pid="$(get_rundir)/udevmonitor.pid" + + einfo "udev: Running udevadm monitor ${udev_monitor_opts} to log all events" + start-stop-daemon --start --stdout "${udevmonitor_log}" \ + --make-pidfile --pidfile "${udevmonitor_pid}" \ + --background --exec /sbin/udevadm -- monitor ${udev_monitor_opts} } -# populate /dev with devices already found by the kernel populate_dev() { if get_bootparam "nocoldplug" ; then @@ -109,71 +168,27 @@ populate_dev() fi ebegin "Populating /dev with existing devices through uevents" - udevadm control --property=STARTUP=1 - if yesno "${rc_coldplug}"; then - udevadm trigger --action="add" - else + if ! yesno "${rc_coldplug}"; then # Do not run any init-scripts, Bug #206518 udevadm control --property=do_not_run_plug_service=1 - - # only create device nodes - udevadm trigger --action="add" --attr-match=dev - - # run persistent-net stuff, bug 191466 - udevadm trigger --action="add" --subsystem-match=net fi + udevadm trigger --type=subsystems --action=add + udevadm trigger --type=devices --action=add eend $? # we can speed up booting under these conditions: # * using devtmpfs so kernel creates device nodes for us - # * only using kernel created device nodes at boot (in /etc/fstab and elsewhere) + # * only using kernel created device nodes at boot + # (in /etc/fstab and elsewhere) # ebegin "Waiting for uevents to be processed" - udevadm settle --timeout=${udev_settle_timeout:-60} + udevadm settle --timeout=${udev_settle_timeout} eend $? udevadm control --property=do_not_run_plug_service= - udevadm control --property=STARTUP= return 0 } -# for debugging -start_udevmonitor() -{ - yesno "${udev_monitor:-no}" || return 0 - - udevmonitor_log=/dev/.udev/udevmonitor.log - udevmonitor_pid=/dev/.udev/udevmonitor.pid - - einfo "udev: Running udevadm monitor ${udev_monitor_opts} to get a log of all events" - start-stop-daemon --start --stdout "${udevmonitor_log}" \ - --make-pidfile --pidfile "${udevmonitor_pid}" \ - --background --exec /sbin/udevadm -- monitor ${udev_monitor_opts} -} - -stop_udevmonitor() -{ - yesno "${udev_monitor:-no}" || return 0 - - if yesno "${udev_monitor_keep_running:-no}"; then - ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}" - else - einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}" - start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /sbin/udevadm - fi -} - -display_hotplugged_services() { - local svcfile= svc= services= - for svcfile in "${RC_SVCDIR}"/hotplugged/*; do - svc="${svcfile##*/}" - [ -x "${svcfile}" ] || continue - - services="${services} ${svc}" - done - [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" -} - check_persistent_net() { # check if there are problems with persistent-net @@ -196,7 +211,7 @@ check_persistent_net() # is installed into /usr/bin and not available at boot. dups=$( RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules' - . /lib64/udev/rule_generator.functions + . /lib/udev/rule_generator.functions find_all_rules 'NAME=' '.*' | \ tr ' ' '\n' | \ sort | \ @@ -224,49 +239,37 @@ check_udev_works() return 0 } -start() +stop_udevmonitor() { - # do not run this on old baselayout where udev-addon gets loaded - if [ ! -f /etc/init.d/sysfs ]; then - eerror "The $SVCNAME init-script is written for baselayout-2!" - eerror "Please do not use it with baselayout-1!". - return 1 + yesno "${udev_monitor}" || return 0 + + if yesno "${udev_monitor_keep_running}"; then + ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}" + else + einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}" + start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /sbin/udevadm fi +} - check_openrc_net - _start - - display_hotplugged_services +display_hotplugged_services() +{ + local svcfile= svc= services= + for svcfile in "${RC_SVCDIR}"/hotplugged/*; do + svc="${svcfile##*/}" + [ -x "${svcfile}" ] || continue - return 0 + services="${services} ${svc}" + done + [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" } -_start() +start_post() { - if [ ! -e /etc/runlevels/${RC_DEFAULTLEVEL:-default}/udev-postmount ]; then - ewarn "You should add udev-postmount service to your default runlevel." - fi - - root_link - rules_disable_switch 75-persistent-net-generator.rules "${persistent_net_disable:-no}" - rules_disable_switch 75-cd-aliases-generator.rules ${persistent_cd_disable:-no} - - disable_hotplug_agent - start_udevd || cleanup start_udevmonitor - populate_dev || cleanup - + populate_dev check_persistent_net - check_udev_works || cleanup stop_udevmonitor - + display_hotplugged_services return 0 } - -stop() { - ebegin "Stopping udevd" - start-stop-daemon --stop --exec /sbin/udevd - eend $? -} - diff --git a/init.d/udev-mount b/init.d/udev-mount index 52cf26b..62742bd 100755 --- a/init.d/udev-mount +++ b/init.d/udev-mount @@ -2,32 +2,13 @@ # Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -description="Mount tmpfs on /dev" -[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev +description="mount devtmpfs or tmpfs on /dev" -# get_KV and KV_to_int -. /lib64/udev/shell-compat-KV.sh - -# FIXME -# Instead of this script testing kernel version, udev itself should -# Maybe something like udevd --test || exit $? -check_kernel() +depend() { - if [ $(get_KV) -lt $(KV_to_int '2.6.25') ]; then - eerror "Your kernel is too old to work with this version of udev." - eerror "Current udev only supports Linux kernel 2.6.25 and newer." - return 1 - fi - - yesno "${unreliable_kernel_warning:-yes}" || return 0 - - if [ $(get_KV) -lt $(KV_to_int '2.6.27') ]; then - ewarn "You need at least Linux kernel 2.6.27 for reliable operation of udev." - fi - return 0 + keyword -vserver -lxc } - mount_dev_directory() { if mountinfo -q /dev; then @@ -72,22 +53,8 @@ seed_dev() return 0 } - start() { - # do not run this on too old baselayout - udev-addon is already loaded! - if [ ! -f /etc/init.d/sysfs ]; then - eerror "The $SVCNAME init-script is written for baselayout-2!" - eerror "Please do not use it with baselayout-1!". - return 1 - fi - - _start -} - -_start() -{ - check_kernel || return 1 mount_dev_directory || return 1 # Selinux lovin; /selinux should be mounted by selinux-patched init @@ -98,10 +65,6 @@ _start() HAVE_SELINUX=false fi - # make sure it exists - mkdir -p /dev/.udev /dev/.udev/rules.d - seed_dev - return 0 } diff --git a/init.d/udev-postmount b/init.d/udev-postmount index 12a30f6..d689681 100755 --- a/init.d/udev-postmount +++ b/init.d/udev-postmount @@ -1,11 +1,19 @@ #!/sbin/runscript # Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/164/udev-postmount.initd,v 1.1 2010/10/30 13:53:54 zzam Exp $ -depend() { +udev_version() +{ + echo $(udevadm --version) +} + +depend() +{ need localmount - after dbus # for trigger failed + if [ $(udev_version) -lt 175 ]; then + after dbus # for trigger failed + fi + keyword -vserver -lxc } dir_writeable() @@ -15,12 +23,13 @@ dir_writeable() # store persistent-rules that got created while booting # when / was still read-only -store_persistent_rules() { +store_persistent_rules() +{ # only continue if rules-directory is writable dir_writeable /etc/udev/rules.d || return 0 local file dest - for file in /dev/.udev/tmp-rules--*; do + for file in "${RUNDIR}"/tmp-rules--*; do dest=${file##*tmp-rules--} [ "$dest" = '*' ] && break type=${dest##70-persistent-} @@ -31,23 +40,27 @@ store_persistent_rules() { done } - -start() { +start() +{ + RUNDIR=$(udevadm info --run) # check if this system uses udev - [ -d /dev/.udev/ ] || return 0 + [ -d "${RUNDIR}" ] || return 0 einfo "Doing udev cleanups" - # Run the events that failed at first udev trigger - udevadm trigger --type=failed -v + if [ $(udev_version) -lt 175 ]; then + # Run the events that failed at first udev trigger + udevadm trigger --type=failed -v + fi # store persistent-rules that got created while booting # when / was still read-only store_persistent_rules } -stop() { - : +stop() +{ + return 0 } # vim:ts=4 diff --git a/init.d/urandom b/init.d/urandom index 99e1127..20e4325 100755 --- a/init.d/urandom +++ b/init.d/urandom @@ -2,7 +2,7 @@ # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. -: ${urandom_seed:=${URANDOM_SEED:-/var/run/random-seed}} +: ${urandom_seed:=${URANDOM_SEED:-/var/lib/misc/random-seed}} description="Initializes the random number generator." depend() @@ -16,7 +16,7 @@ save_seed() local psz=1 if [ -e /proc/sys/kernel/random/poolsize ]; then - psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096)) + : $(( psz = $(cat /proc/sys/kernel/random/poolsize) / 4096 )) fi ( # sub shell to prevent umask pollution diff --git a/lvm/lvm.conf b/lvm/lvm.conf index 567144b..cec2578 100644 --- a/lvm/lvm.conf +++ b/lvm/lvm.conf @@ -6,6 +6,9 @@ # # To put this file in a different directory and override /etc/lvm set # the environment variable LVM_SYSTEM_DIR before running the tools. +# +# N.B. Take care that each setting only appears once if uncommenting +# example settings in this file. # This section allows you to configure which block devices should @@ -19,6 +22,16 @@ devices { # to use with LVM2. scan = [ "/dev" ] + # If set, the cache of block device nodes with all associated symlinks + # will be constructed out of the existing udev database content. + # This avoids using and opening any inapplicable non-block devices or + # subdirectories found in the device directory. This setting is applied + # to udev-managed device directory only, other directories will be scanned + # fully. LVM2 needs to be compiled with udev support for this setting to + # take effect. N.B. Any device node or symlink not managed by udev in + # udev directory will be ignored with this setting on. + obtain_device_list_from_udev = 1 + # If several entries in the scanned directories correspond to the # same block device and the tools need to display a name for device, # all the pathnames are matched against each item in the following @@ -100,6 +113,10 @@ devices { # 1 enables; 0 disables. md_chunk_alignment = 1 + # Default alignment of the start of a data area in MB. If set to 0, + # a value of 64KB will be used. Set to 1 for 1MiB, 2 for 2MiB, etc. + # default_data_alignment = 1 + # By default, the start of a PV's data area will be a multiple of # the 'minimum_io_size' or 'optimal_io_size' exposed in sysfs. # - minimum_io_size - the smallest request the device can perform @@ -113,9 +130,9 @@ devices { data_alignment_detection = 1 # Alignment (in KB) of start of data area when creating a new PV. - # If a PV is placed directly upon an md device and md_chunk_alignment or - # data_alignment_detection is enabled this parameter is ignored. - # Set to 0 for the default alignment of 1MB or page size, if larger. + # md_chunk_alignment and data_alignment_detection are disabled if set. + # Set to 0 for the default alignment (see: data_alignment_default) + # or page size, if larger. data_alignment = 0 # By default, the start of the PV's aligned data area will be shifted by @@ -124,6 +141,7 @@ devices { # windows partitioning will have an alignment_offset of 3584 bytes # (sector 7 is the lowest aligned logical block, the 4KB sectors start # at LBA -1, and consequently sector 63 is aligned on a 4KB boundary). + # But note that pvcreate --dataalignmentoffset will skip this detection. # 1 enables; 0 disables. data_alignment_offset_detection = 1 @@ -133,10 +151,70 @@ devices { # in recovery situations. ignore_suspended_devices = 0 + # During each LVM operation errors received from each device are counted. + # If the counter of a particular device exceeds the limit set here, no + # further I/O is sent to that device for the remainder of the respective + # operation. Setting the parameter to 0 disables the counters altogether. + disable_after_error_count = 0 + # Allow use of pvcreate --uuid without requiring --restorefile. require_restorefile_with_uuid = 1 + + # Minimum size (in KB) of block devices which can be used as PVs. + # In a clustered environment all nodes must use the same value. + # Any value smaller than 512KB is ignored. + + # Ignore devices smaller than 2MB such as floppy drives. + pv_min_size = 2048 + + # The original built-in setting was 512 up to and including version 2.02.84. + # pv_min_size = 512 + + # Issue discards to a logical volumes's underlying physical volume(s) when + # the logical volume is no longer using the physical volumes' space (e.g. + # lvremove, lvreduce, etc). Discards inform the storage that a region is + # no longer in use. Storage that supports discards advertise the protocol + # specific way discards should be issued by the kernel (TRIM, UNMAP, or + # WRITE SAME with UNMAP bit set). Not all storage will support or benefit + # from discards but SSDs and thinly provisioned LUNs generally do. If set + # to 1, discards will only be issued if both the storage and kernel provide + # support. + # 1 enables; 0 disables. + issue_discards = 0 } +# This section allows you to configure the way in which LVM selects +# free space for its Logical Volumes. +#allocation { +# When searching for free space to extend an LV, the "cling" +# allocation policy will choose space on the same PVs as the last +# segment of the existing LV. If there is insufficient space and a +# list of tags is defined here, it will check whether any of them are +# attached to the PVs concerned and then seek to match those PV tags +# between existing extents and new extents. +# Use the special tag "@*" as a wildcard to match any PV tag. +# +# Example: LVs are mirrored between two sites within a single VG. +# PVs are tagged with either @site1 or @site2 to indicate where +# they are situated. +# +# cling_tag_list = [ "@site1", "@site2" ] +# cling_tag_list = [ "@*" ] +# +# Changes made in version 2.02.85 extended the reach of the 'cling' +# policies to detect more situations where data can be grouped +# onto the same disks. Set this to 0 to revert to the previous +# algorithm. +# +# maximise_cling = 1 +# +# Set to 1 to guarantee that mirror logs will always be placed on +# different PVs from the mirror images. This was the default +# until version 2.02.85. +# +# mirror_logs_require_separate_pvs = 0 +#} + # This section that allows you to configure the nature of the # information that LVM2 reports. log { @@ -327,9 +405,47 @@ global { # Treat any internal errors as fatal errors, aborting the process that # encountered the internal error. Please only enable for debugging. abort_on_internal_errors = 0 + + # Check whether CRC is matching when parsed VG is used multiple times. + # This is useful to catch unexpected internal cached volume group + # structure modification. Please only enable for debugging. + detect_internal_vg_cache_corruption = 0 + + # If set to 1, no operations that change on-disk metadata will be permitted. + # Additionally, read-only commands that encounter metadata in need of repair + # will still be allowed to proceed exactly as if the repair had been + # performed (except for the unchanged vg_seqno). + # Inappropriate use could mess up your system, so seek advice first! + metadata_read_only = 0 + + # 'mirror_segtype_default' defines which segtype will be used when the + # shorthand '-m' option is used for mirroring. The possible options are: + # + # "mirror" - The original RAID1 implementation provided by LVM2/DM. It is + # characterized by a flexible log solution (core, disk, mirrored) + # and by the necessity to block I/O while reconfiguring in the + # event of a failure. Snapshots of this type of RAID1 can be + # problematic. + # + # "raid1" - This implementation leverages MD's RAID1 personality through + # device-mapper. It is characterized by a lack of log options. + # (A log is always allocated for every device and they are placed + # on the same device as the image - no separate devices are + # required.) This mirror implementation does not require I/O + # to be blocked in the kernel in the event of a failure. + # + # Specify the '--type ' option to override this default + # setting. + mirror_segtype_default = "mirror" } activation { + # Set to 1 to perform internal checks on the operations issued to + # libdevmapper. Useful for debugging problems with activation. + # Some of the checks may be expensive, so it's best to use this + # only when there seems to be a problem. + checks = 0 + # Set to 0 to disable udev synchronisation (if compiled into the binaries). # Processes will not wait for notification from udev. # They will continue irrespective of any possible udev processing @@ -347,6 +463,12 @@ activation { # while any logical volumes are active. udev_rules = 1 + # Set to 1 for LVM2 to verify operations performed by udev. This turns on + # additional checks (and if necessary, repairs) on entries in the device + # directory after udev has completed processing its events. + # Useful for diagnosing problems with LVM2/udev interactions. + verify_udev_operations = 0 + # How to fill in missing stripes if activating an incomplete volume. # Using "error" will make inaccessible parts of the device return # I/O errors on access. You can instead use a device path, in which @@ -421,6 +543,25 @@ activation { mirror_log_fault_policy = "allocate" mirror_image_fault_policy = "remove" + # 'snapshot_autoextend_threshold' and 'snapshot_autoextend_percent' define + # how to handle automatic snapshot extension. The former defines when the + # snapshot should be extended: when its space usage exceeds this many + # percent. The latter defines how much extra space should be allocated for + # the snapshot, in percent of its current size. + # + # For example, if you set snapshot_autoextend_threshold to 70 and + # snapshot_autoextend_percent to 20, whenever a snapshot exceeds 70% usage, + # it will be extended by another 20%. For a 1G snapshot, using up 700M will + # trigger a resize to 1.2G. When the usage exceeds 840M, the snapshot will + # be extended to 1.44G, and so on. + # + # Setting snapshot_autoextend_threshold to 100 disables automatic + # extensions. The minimum value is 50 (A setting below 50 will be treated + # as 50). + + snapshot_autoextend_threshold = 100 + snapshot_autoextend_percent = 20 + # While activating devices, I/O to devices being (re)configured is # suspended, and as a precaution against deadlocks, LVM2 needs to pin # any memory it is using so it is not paged out. Groups of pages that diff --git a/motd b/motd index f571f14..c116e60 100644 --- a/motd +++ b/motd @@ -7,9 +7,9 @@ Gentoo Base System release 2.0.3 \___/|_| |_|\__,_| |_| -Es kann der Frömmste nicht in Frieden leben, wenn es dem bösen -Nachbarn nicht gefällt. - -- Friedrich Johann Christoph Schiller (Wilhelm Tell) +Liebe ist die Anziehungskraft des Geistes, wie die Schwerkraft die +Anziehungskraft der Körper ist. + -- Valerie Marie Breton Today is Pungenday, the 28th day of Chaos in the YOLD 3178 diff --git a/pam.d/system-login b/pam.d/system-login index a20e8f9..27fa05a 100644 --- a/pam.d/system-login +++ b/pam.d/system-login @@ -2,6 +2,7 @@ auth required pam_tally2.so onerr=succeed auth required pam_shells.so auth required pam_nologin.so auth include system-auth +auth optional pam_gnome_keyring.so account required pam_access.so account required pam_nologin.so @@ -9,11 +10,13 @@ account include system-auth account required pam_tally2.so onerr=succeed password include system-auth +password optional pam_gnome_keyring.so session optional pam_loginuid.so session required pam_env.so session optional pam_lastlog.so session include system-auth +session optional pam_gnome_keyring.so auto_start session optional pam_motd.so motd=/etc/motd session optional pam_mail.so -- 2.39.5