]> Frank Brehm's Git Trees - config/bruni/etc.git/commitdiff
saving uncommitted changes in /etc prior to emerge run
authorFrank Brehm <frank@brehm-online.com>
Mon, 18 Jan 2016 11:24:51 +0000 (12:24 +0100)
committerFrank Brehm <frank@brehm-online.com>
Mon, 18 Jan 2016 11:24:51 +0000 (12:24 +0100)
conf.d/bootmisc
conf.d/net-online [new file with mode: 0644]
conf.d/netmount
init.d/bootmisc
init.d/net-online [new file with mode: 0755]
init.d/sysfs

index d79706cc7729ee28b3a20d1971aed75d8ffe61aa..5371209767b737eda1402fd710dbe4dd7a8a098e 100644 (file)
@@ -8,3 +8,8 @@ wipe_tmp="YES"
 # Write the initial dmesg log into /var/log/dmesg after boot
 # This may be useful if you need the kernel boot log afterwards
 log_dmesg="YES"
+
+# Save the previous dmesg log to dmesc.old
+# This may be useful if you need to compare the current boot to the
+# previous one.
+#previous_dmesg=no
diff --git a/conf.d/net-online b/conf.d/net-online
new file mode 100644 (file)
index 0000000..bf0b09a
--- /dev/null
@@ -0,0 +1,15 @@
+# The interfaces setting controls which interfaces the net-online
+# service considers in deciding whether the network is active. By
+# default, it is all ethernet or wireless LAN interfaces.
+#interfaces=""
+
+# This setting controls whether a ping to the default gateway is
+# included in the test for network connectivity after all interfaces
+# are active.
+#ping_default_gateway=no
+
+# The timeout setting controls how long the net-online service waits
+# for the network to be configured.
+# The default is 120 seconds.
+# if this is set to 0, the wait is infinite.
+#timeout=120
index fc19fd489b14d6100ce5a5bc0a8f01d47d7da939..53717fcd822e9b0d08aa146fa078aae5c265bbcf 100644 (file)
 #rc_need="net.eth1 net.eth2"
 #
 # If you are using a dynamic network management tool like
-# networkmanager, dhcpcd in standalone mode, wicd, badvpn-ncd, etc, to
+# NetworkManager, dhcpcd in standalone mode, wicd, badvpn-ncd, etc, to
 # manage the network interfaces with the routes to your netmounts, you
 # should list that tool.
 #
-#rc_need="networkmanager"
+#rc_need="NetworkManager"
 #rc_need="dhcpcd"
 #rc_need="wicd"
 #
index c8c0cf5464bde10fa85a84215438c0515ee8603c..03f8924381115a62b70ba0da890206d49b67764e 100755 (executable)
@@ -216,6 +216,9 @@ start()
                        case "$RC_SYS" in
                                VSERVER|OPENVZ|LXC|SYSTEMD-NSPAWN) ;;
                                *)
+                                       if yesno ${previous_dmesg:-no}; then
+                                               mv /var/log/dmesg /var/log/dmesg.old
+                                       fi
                                        dmesg > /var/log/dmesg
                                        chmod 640 /var/log/dmesg
                                        ;;
diff --git a/init.d/net-online b/init.d/net-online
new file mode 100755 (executable)
index 0000000..3ef1481
--- /dev/null
@@ -0,0 +1,69 @@
+#!/sbin/openrc-run
+# Copyright (C) 2015 William Hubbs <w.d.hubbs@gmail.com>
+# Released under the 2-clause BSD license.
+
+description="Delays until the network is online or a specific timeout"
+
+depend()
+{
+       after modules
+       need sysfs
+       keyword -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
+}
+
+get_interfaces()
+{
+       local ifname iftype
+       for ifname in /sys/class/net/*; do
+               read iftype < ${ifname}/type
+               [ "$iftype" = "1" ] && printf "%s " ${ifname##*/}
+       done
+}
+
+get_default_gateway()
+{
+       local cmd gateway
+       if command -v ip > /dev/null 2>&1; then
+               cmd="ip route show"
+       else
+               cmd=route
+       fi
+       set -- $($cmd | grep default)
+       [ "$2" != via ] && gateway="$2" || gateway="$3"
+       printf "%s" $gateway
+}
+
+start ()
+{
+       local carriers configured dev gateway ifcount infinite interfaces
+       local rc state timeout x
+
+       ebegin "Checking to see if the network is online"
+       rc=0
+       interfaces=${interfaces:-$(get_interfaces)}
+       timeout=${timeout:-120}
+ [ $timeout -eq 0 ] && infinite=true || infinite=false
+ while $infinite || [ $timeout -gt 0 ]; do
+       carriers=0
+       configured=0
+       ifcount=0
+       for dev in ${interfaces}; do
+               : $((ifcount += 1))
+               read x < /sys/class/net/$dev/carrier
+               [ $x -eq 1 ] && : $((carriers += 1))
+               read x < /sys/class/net/$dev/operstate
+               [ "$x" = up ] && : $((configured += 1))
+       done
+       [ $configured -eq $ifcount ] && [ $carriers -ge 1 ] && break
+       sleep 1
+       : $((timeout -= 1))
+ done
+ ! $infinite && [ $timeout -eq 0 ] && rc=1
+ if [ $rc -eq 0 ] && yesno ${ping_default_gateway:-no}; then
+       gateway="$(get_default_gateway)"
+       if [ -n "$gateway" ] && ! ping -c 1 $gateway > /dev/null 2>&1; then
+               rc=1
+       fi
+ fi
+ eend $rc "The network is offline"
+}
index 70eaaa9e4efe21045b8d15b46c54d67632a0b74b..24b781e0a131be495616d6783b54fda0d64ba1aa 100755 (executable)
@@ -61,16 +61,6 @@ mount_misc()
                fi
        fi
 
-       # set up kernel support for cgroups
-       if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
-               if grep -qs cgroup /proc/filesystems; then
-                       ebegin "Mounting cgroup filesystem"
-                       local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}"
-                       mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
-                       eend $?
-               fi
-       fi
-
        # set up kernel support for fusectl
        if [ -d /sys/fs/fuse/connections ] \
                && ! mountinfo -q /sys/fs/fuse/connections; then
@@ -108,6 +98,16 @@ mount_misc()
 
 mount_cgroups()
 {
+       # set up kernel support for cgroups
+       if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
+               if grep -qs cgroup /proc/filesystems; then
+                       ebegin "Mounting cgroup filesystem"
+                       local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}"
+                       mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
+                       eend $?
+               fi
+       fi
+
        mountinfo -q /sys/fs/cgroup || return 0
 
        if ! mountinfo -q /sys/fs/cgroup/openrc; then