Skip to content

Commit

Permalink
rc.M,rc.inet1: added container einvironment checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ponce committed Jul 20, 2011
1 parent 09809f2 commit 63ac6f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rc.M
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
# Author: Fred N. van Kempen, <[email protected]>
# Heavily modified by Patrick Volkerding <[email protected]>
#
# tweaks for an lxc container by ponce <[email protected]>,
# a check for a CONTAINER variable is made to jump unneeded sections

CONTAINER=yes

# Tell the viewers what's going to happen.
echo "Going multiuser..."
Expand All @@ -20,10 +24,15 @@ if [ -x /sbin/ldconfig ]; then
/sbin/ldconfig &
fi

# container check
if [ ! $CONTAINER ]; then

# Screen blanks after 15 minutes idle time, and powers down in one hour
# if the kernel supports APM or ACPI power management:
/bin/setterm -blank 15 -powersave powerdown -powerdown 60

fi # end container check

# Set the hostname.
if [ -r /etc/HOSTNAME ]; then
/bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
Expand Down
12 changes: 12 additions & 0 deletions rc.inet1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# This script is used to bring up the various network interfaces.
#
# @(#)/etc/rc.d/rc.inet1 10.2 Sun Jul 24 12:45:56 PDT 2005 (pjv)
#
# tweaks for an lxc container by ponce <[email protected]>,
# a check for a CONTAINER variable is made to jump unneeded sections

CONTAINER=yes

############################
# READ NETWORK CONFIG FILE #
Expand Down Expand Up @@ -82,6 +87,10 @@ if_up() {
[ "${IFNAME[$i]}" = "${1}" ] && break
i=$(($i+1))
done

# container check
if [ ! $CONTAINER ]; then

# If the interface isn't in the kernel yet (but there's an alias for it in
# modules.conf), then it should be loaded first:
if ! grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then # no interface yet
Expand All @@ -90,6 +99,9 @@ if_up() {
/sbin/modprobe ${1}
fi
fi

fi # end container check

if grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then # interface exists
if ! /sbin/ifconfig | grep -w "${1}" 1>/dev/null || \
! /sbin/ifconfig ${1} | grep "inet addr" 1> /dev/null ; then # interface not up or not configured
Expand Down

0 comments on commit 63ac6f5

Please sign in to comment.