summaryrefslogtreecommitdiffstats
path: root/source/ap/lxc
diff options
context:
space:
mode:
Diffstat (limited to 'source/ap/lxc')
-rw-r--r--source/ap/lxc/lxc-slackware.in13
-rwxr-xr-xsource/ap/lxc/lxc.SlackBuild24
-rw-r--r--source/ap/lxc/rc.lxc6
-rw-r--r--source/ap/lxc/scripts/rc.6.lxc22
-rw-r--r--source/ap/lxc/scripts/rc.6.orig22
-rw-r--r--source/ap/lxc/scripts/rc.M.lxc80
-rw-r--r--source/ap/lxc/scripts/rc.M.orig78
-rw-r--r--source/ap/lxc/scripts/rc.S.lxc24
-rw-r--r--source/ap/lxc/scripts/rc.S.orig20
-rw-r--r--source/ap/lxc/scripts/rc.inet1.lxc242
-rw-r--r--source/ap/lxc/scripts/rc.inet1.orig242
-rw-r--r--source/ap/lxc/slack-desc12
12 files changed, 444 insertions, 341 deletions
diff --git a/source/ap/lxc/lxc-slackware.in b/source/ap/lxc/lxc-slackware.in
index 6049d2a5f..53e5e2b11 100644
--- a/source/ap/lxc/lxc-slackware.in
+++ b/source/ap/lxc/lxc-slackware.in
@@ -228,11 +228,14 @@ bash
bin
bzip2
coreutils
+cyrus-sasl
+db48
dcron
dhcpcd
dialog
diffutils
e2fsprogs
+elfutils
elvis
etc
eudev
@@ -240,16 +243,26 @@ findutils
gawk
glibc-solibs
gnupg
+gnutls
grep
gzip
+iproute2
iputils
+kmod
+libcap-ng
+libffi
+libmnl
+libtasn1
+libunistring
logrotate
mpfr
net-tools
+nettle
network-scripts
ncurses
openssh
openssl-solibs
+p11-kit
pkgtools
procps-ng
sed
diff --git a/source/ap/lxc/lxc.SlackBuild b/source/ap/lxc/lxc.SlackBuild
index 3383ee352..9829e3acd 100755
--- a/source/ap/lxc/lxc.SlackBuild
+++ b/source/ap/lxc/lxc.SlackBuild
@@ -1,6 +1,6 @@
-#!/bin/sh
+#!/bin/bash
-# Copyright 2011, 2012, 2013, 2014, 2015, 2016 Patrick J. Volkerding, Sebeka, Minnesota, USA
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -22,9 +22,11 @@
# Modified by Matteo Bernardini <ponce@slackbuilds.org> (2014)
+cd $(dirname $0) ; CWD=$(pwd)
+
PKGNAM=lxc
VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | rev | cut -f 2- -d -)}
-BUILD=${BUILD:-4}
+BUILD=${BUILD:-2}
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
@@ -36,6 +38,14 @@ if [ -z "$ARCH" ]; then
esac
fi
+# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
+# the name of the created package would be, and then exit. This information
+# could be useful to other scripts.
+if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
+ echo "$PKGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD.txz"
+ exit 0
+fi
+
NUMJOBS=${NUMJOBS:-" -j7 "}
if [ "$ARCH" = "i586" ]; then
@@ -52,7 +62,6 @@ else
LIBDIRSUFFIX=""
fi
-CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-$PKGNAM
@@ -96,13 +105,18 @@ CFLAGS="$SLKCFLAGS" \
--infodir=/usr/info \
--with-global-conf=/etc/lxc/lxc.conf \
--with-rootfs-path=/var/lib/rootfs-lxc \
+ --enable-cgmanager=no \
+ --disable-werror \
$python \
- --build=$ARCH-slackware-linux
+ --build=$ARCH-slackware-linux || exit 1
# Build and install:
make $NUMJOBS || make || exit 1
make install DESTDIR=$PKG || exit 1
+# Don't ship .la files:
+rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la
+
# Add the modified Slackware startup scripts:
mkdir -p $PKG/usr/share/lxc/scripts/slackware
cp -a $CWD/scripts/*.lxc $PKG/usr/share/lxc/scripts/slackware
diff --git a/source/ap/lxc/rc.lxc b/source/ap/lxc/rc.lxc
index f97a1b1d5..0690d70bd 100644
--- a/source/ap/lxc/rc.lxc
+++ b/source/ap/lxc/rc.lxc
@@ -17,11 +17,7 @@ start_lxc() {
if [ "$(lxc-info -n $CONTAIN -c lxc.start.auto)" = "lxc.start.auto = 1" ]; then
if [ "$(/usr/bin/lxc-info -s -n $CONTAIN | grep STOPPED$)" ]; then
echo "Starting LXC container ${CONTAIN}."
- if [ -x /usr/bin/screen ]; then
- /usr/bin/screen -dmS init-${CONTAIN} /usr/bin/lxc-start -n $CONTAIN
- else
- /usr/bin/lxc-start -n $CONTAIN -d
- fi
+ /usr/bin/lxc-start -n $CONTAIN
/usr/bin/lxc-wait -n $CONTAIN -s RUNNING
if [ $? -gt 0 ]; then
return 2
diff --git a/source/ap/lxc/scripts/rc.6.lxc b/source/ap/lxc/scripts/rc.6.lxc
index 5dde949a8..7fd57ef26 100644
--- a/source/ap/lxc/scripts/rc.6.lxc
+++ b/source/ap/lxc/scripts/rc.6.lxc
@@ -11,7 +11,7 @@
#
# Set the path.
-PATH=/sbin:/etc:/bin:/usr/bin
+PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
# Set $container variable since this is a modified version of rc.6 with
# changes for running in an lxc container. A check to see if this variable
@@ -22,7 +22,7 @@ container="lxc"
# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
- . /etc/rc.d/rc.sysvinit
+ /etc/rc.d/rc.sysvinit
fi
# Set linefeed mode to avoid staircase effect.
@@ -85,13 +85,13 @@ if [ -x /etc/rc.d/rc.httpd ]; then
fi
# Stop the MySQL database:
-if [ -r /var/run/mysql/mysql.pid ]; then
- . /etc/rc.d/rc.mysqld stop
+if [ -x /etc/rc.d/rc.mysqld -a -r /var/run/mysql/mysql.pid ]; then
+ /etc/rc.d/rc.mysqld stop
fi
# Stop the Samba server:
if [ -x /etc/rc.d/rc.samba ]; then
- . /etc/rc.d/rc.samba stop
+ /etc/rc.d/rc.samba stop
fi
# Shut down the NFS server:
@@ -116,7 +116,7 @@ fi
# Stop D-Bus:
if [ -x /etc/rc.d/rc.messagebus ]; then
- sh /etc/rc.d/rc.messagebus stop
+ /etc/rc.d/rc.messagebus stop
fi
# Kill any processes (typically gam) that would otherwise prevent
@@ -156,7 +156,7 @@ fi
# isn't a diskless client with the / partition mounted via NFS:
if ! /bin/mount | /bin/grep -q 'on / type nfs' ; then
if [ -x /etc/rc.d/rc.inet1 ]; then
- . /etc/rc.d/rc.inet1 stop
+ /etc/rc.d/rc.inet1 stop
fi
fi
@@ -171,7 +171,7 @@ fi
# Shut down PCMCIA devices:
if [ -x /etc/rc.d/rc.pcmcia -a -z "$container" ]; then
- . /etc/rc.d/rc.pcmcia stop
+ /etc/rc.d/rc.pcmcia stop
# The cards might need a little extra time here to deactivate:
/bin/sleep 5
fi
@@ -183,12 +183,12 @@ fi
# Terminate acpid before syslog:
if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid -a -z "$container" ]; then # quit
- . /etc/rc.d/rc.acpid stop
+ /etc/rc.d/rc.acpid stop
fi
# Stop udev:
if [ -x /etc/rc.d/rc.udev -a -z "$container" ]; then
- sh /etc/rc.d/rc.udev force-stop
+ /etc/rc.d/rc.udev force-stop
fi
# Kill all remaining processes.
@@ -231,7 +231,7 @@ fi
# Stop cgmanager and cgproxy:
if [ -x /etc/rc.d/rc.cgmanager -a -z "$container" ]; then
- sh /etc/rc.d/rc.cgmanager stop
+ /etc/rc.d/rc.cgmanager stop
fi
if [ -z "$container" ]; then
diff --git a/source/ap/lxc/scripts/rc.6.orig b/source/ap/lxc/scripts/rc.6.orig
index 76895aca8..23c280d91 100644
--- a/source/ap/lxc/scripts/rc.6.orig
+++ b/source/ap/lxc/scripts/rc.6.orig
@@ -11,11 +11,11 @@
#
# Set the path.
-PATH=/sbin:/etc:/bin:/usr/bin
+PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
- . /etc/rc.d/rc.sysvinit
+ /etc/rc.d/rc.sysvinit
fi
# Set linefeed mode to avoid staircase effect.
@@ -78,13 +78,13 @@ if [ -x /etc/rc.d/rc.httpd ]; then
fi
# Stop the MySQL database:
-if [ -r /var/run/mysql/mysql.pid ]; then
- . /etc/rc.d/rc.mysqld stop
+if [ -x /etc/rc.d/rc.mysqld -a -r /var/run/mysql/mysql.pid ]; then
+ /etc/rc.d/rc.mysqld stop
fi
# Stop the Samba server:
if [ -x /etc/rc.d/rc.samba ]; then
- . /etc/rc.d/rc.samba stop
+ /etc/rc.d/rc.samba stop
fi
# Shut down the NFS server:
@@ -109,7 +109,7 @@ fi
# Stop D-Bus:
if [ -x /etc/rc.d/rc.messagebus ]; then
- sh /etc/rc.d/rc.messagebus stop
+ /etc/rc.d/rc.messagebus stop
fi
# Kill any processes (typically gam) that would otherwise prevent
@@ -149,7 +149,7 @@ fi
# isn't a diskless client with the / partition mounted via NFS:
if ! /bin/mount | /bin/grep -q 'on / type nfs' ; then
if [ -x /etc/rc.d/rc.inet1 ]; then
- . /etc/rc.d/rc.inet1 stop
+ /etc/rc.d/rc.inet1 stop
fi
fi
@@ -164,7 +164,7 @@ fi
# Shut down PCMCIA devices:
if [ -x /etc/rc.d/rc.pcmcia ]; then
- . /etc/rc.d/rc.pcmcia stop
+ /etc/rc.d/rc.pcmcia stop
# The cards might need a little extra time here to deactivate:
/bin/sleep 5
fi
@@ -176,12 +176,12 @@ fi
# Terminate acpid before syslog:
if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
- . /etc/rc.d/rc.acpid stop
+ /etc/rc.d/rc.acpid stop
fi
# Stop udev:
if [ -x /etc/rc.d/rc.udev ]; then
- sh /etc/rc.d/rc.udev force-stop
+ /etc/rc.d/rc.udev force-stop
fi
# Kill all remaining processes.
@@ -222,7 +222,7 @@ echo "Turning off swap."
# Stop cgmanager and cgproxy:
if [ -x /etc/rc.d/rc.cgmanager ]; then
- sh /etc/rc.d/rc.cgmanager stop
+ /etc/rc.d/rc.cgmanager stop
fi
echo "Unmounting local file systems:"
diff --git a/source/ap/lxc/scripts/rc.M.lxc b/source/ap/lxc/scripts/rc.M.lxc
index a86eb62dd..2b16190eb 100644
--- a/source/ap/lxc/scripts/rc.M.lxc
+++ b/source/ap/lxc/scripts/rc.M.lxc
@@ -36,11 +36,11 @@ fi
# Set the hostname.
if [ -z "$container" ]; then
if [ -r /etc/HOSTNAME ]; then
- /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
+ /bin/hostname $(cat /etc/HOSTNAME)
else
# fall back on this old default:
echo "darkstar.example.net" > /etc/HOSTNAME
- /bin/hostname darkstar
+ /bin/hostname $(cat /etc/HOSTNAME)
fi
fi
@@ -78,14 +78,14 @@ fi
# that's how it is...
#
if [ -x /etc/rc.d/rc.pcmcia -a -z "$container" ]; then
- . /etc/rc.d/rc.pcmcia start
+ /etc/rc.d/rc.pcmcia start
# The cards might need a little extra time here to initialize.
sleep 5
fi
# Start the system logger.
if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
- . /etc/rc.d/rc.syslog start
+ /etc/rc.d/rc.syslog start
fi
# Update the X font indexes:
@@ -100,41 +100,36 @@ fi
if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then
if ! grep -wq nohotplug /proc/cmdline ; then
if [ -x /etc/rc.d/rc.udev -a -z "$container" ]; then
- /bin/sh /etc/rc.d/rc.udev start
+ /etc/rc.d/rc.udev start
fi
fi
fi
# Initialize the networking hardware.
if [ -x /etc/rc.d/rc.inet1 ]; then
- . /etc/rc.d/rc.inet1
+ /etc/rc.d/rc.inet1
fi
# Start D-Bus:
if [ -x /etc/rc.d/rc.messagebus ]; then
- sh /etc/rc.d/rc.messagebus start
+ /etc/rc.d/rc.messagebus start
fi
# Start Bluetooth:
if [ -x /etc/rc.d/rc.bluetooth ]; then
- sh /etc/rc.d/rc.bluetooth start
+ /etc/rc.d/rc.bluetooth start
fi
# Start wicd or networkmanager:
if [ -x /etc/rc.d/rc.wicd -a -x /usr/sbin/wicd ]; then
- sh /etc/rc.d/rc.wicd start
+ /etc/rc.d/rc.wicd start
elif [ -x /etc/rc.d/rc.networkmanager ]; then
- sh /etc/rc.d/rc.networkmanager start
+ /etc/rc.d/rc.networkmanager start
fi
# Start networking daemons:
if [ -x /etc/rc.d/rc.inet2 ]; then
- . /etc/rc.d/rc.inet2
-fi
-
-# Look for additional USB/SCSI/IEEE1394/etc devices on multiple LUNs:
-if [ -x /etc/rc.d/rc.scanluns ]; then
- . /etc/rc.d/rc.scanluns
+ /etc/rc.d/rc.inet2
fi
# Mount any additional filesystem types that haven't already been mounted:
@@ -142,12 +137,12 @@ mount -a -v 2> /dev/null | grep -v -e "already mounted" -e "ignored" | cut -f 1
# Start the Control Script for automounter:
if [ -x /etc/rc.d/rc.autofs ]; then
- sh /etc/rc.d/rc.autofs start
+ /etc/rc.d/rc.autofs start
fi
# Start the Network Time Protocol daemon:
if [ -x /etc/rc.d/rc.ntpd ]; then
- sh /etc/rc.d/rc.ntpd start
+ /etc/rc.d/rc.ntpd start
fi
# Remove stale locks and junk files (must be done after mount -a!)
@@ -166,12 +161,12 @@ chmod 1777 /tmp /var/tmp
# Start ACPI daemon.
if [ -x /etc/rc.d/rc.acpid -a -z "$container" ]; then
- . /etc/rc.d/rc.acpid start
+ /etc/rc.d/rc.acpid start
fi
# Enable CPU frequency scaling:
if [ -x /etc/rc.d/rc.cpufreq -a -z "$container" ]; then
- . /etc/rc.d/rc.cpufreq start
+ /etc/rc.d/rc.cpufreq start
fi
# Update any existing icon cache files:
@@ -198,18 +193,18 @@ fi
# Start console-kit-daemon:
if [ -x /etc/rc.d/rc.consolekit ]; then
- sh /etc/rc.d/rc.consolekit start
+ /etc/rc.d/rc.consolekit start
fi
# Start HAL:
if [ -x /etc/rc.d/rc.hald ]; then
- sh /etc/rc.d/rc.hald start
+ /etc/rc.d/rc.hald start
fi
# Start system-wide PulseAudio daemon (not recommended, nor required in
# order to use PulseAudio -- see the script for details):
if [ -x /etc/rc.d/rc.pulseaudio ]; then
- . /etc/rc.d/rc.pulseaudio start
+ /etc/rc.d/rc.pulseaudio start
fi
# These GTK+/pango files need to be kept up to date for
@@ -251,7 +246,7 @@ if [ -x /etc/rc.d/rc.cups ]; then
/etc/rc.d/rc.cups start
elif [ -x /etc/rc.d/rc.lprng ]; then
# Start LPRng (lpd):
- . /etc/rc.d/rc.lprng start
+ /etc/rc.d/rc.lprng start
fi
# Start netatalk. (a file/print server for Macs using Appletalk)
@@ -333,65 +328,72 @@ if grep -q quota /etc/fstab ; then
fi
# Start the SASL authentication server. This provides SASL
-# authentication services for sendmail:
+# authentication services for sendmail/postfix:
if [ -x /etc/rc.d/rc.saslauthd ]; then
- . /etc/rc.d/rc.saslauthd start
+ /etc/rc.d/rc.saslauthd start
fi
-# Start the sendmail daemon:
-if [ -x /etc/rc.d/rc.sendmail ]; then
- . /etc/rc.d/rc.sendmail start
+# Start the mail server. Try the rc.sendmail script first, then try rc.postfix.
+if [ -x /etc/rc.d/rc.sendmail -a -x usr/sbin/makemap ]; then
+ /etc/rc.d/rc.sendmail start
+elif [ -x /etc/rc.d/rc.postfix -a -x usr/sbin/postdrop ]; then
+ /etc/rc.d/rc.postfix start
fi
# Load ALSA (sound) defaults:
if [ -x /etc/rc.d/rc.alsa -a -z "$container" ]; then
- . /etc/rc.d/rc.alsa
+ /etc/rc.d/rc.alsa
fi
# Load a custom screen font if the user has an rc.font script.
if [ -x /etc/rc.d/rc.font ]; then
- . /etc/rc.d/rc.font
+ /etc/rc.d/rc.font
fi
# Load a custom keymap if the user has an rc.keymap script.
if [ -x /etc/rc.d/rc.keymap ]; then
- . /etc/rc.d/rc.keymap
+ /etc/rc.d/rc.keymap
fi
# Start the MySQL database:
if [ -x /etc/rc.d/rc.mysqld ]; then
- . /etc/rc.d/rc.mysqld start
+ /etc/rc.d/rc.mysqld start
fi
# Start Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
- . /etc/rc.d/rc.httpd start
+ /etc/rc.d/rc.httpd start
fi
# Start OpenLDAP:
if [ -x /etc/rc.d/rc.openldap ]; then
- . /etc/rc.d/rc.openldap start
+ /etc/rc.d/rc.openldap start
+fi
+
+# Start Dovecot:
+if [ -x /etc/rc.d/rc.dovecot ]; then
+ /etc/rc.d/rc.dovecot start
fi
# Start Samba (a file/print server for Win95/NT machines).
# Samba can be started in /etc/inetd.conf instead.
if [ -x /etc/rc.d/rc.samba ]; then
- . /etc/rc.d/rc.samba start
+ /etc/rc.d/rc.samba start
fi
# Start the GPM mouse server:
if [ -x /etc/rc.d/rc.gpm ]; then
- . /etc/rc.d/rc.gpm start
+ /etc/rc.d/rc.gpm start
fi
# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
- . /etc/rc.d/rc.sysvinit
+ /etc/rc.d/rc.sysvinit
fi
# Start the local setup procedure.
if [ -x /etc/rc.d/rc.local ]; then
- . /etc/rc.d/rc.local
+ /etc/rc.d/rc.local
fi
# All done.
diff --git a/source/ap/lxc/scripts/rc.M.orig b/source/ap/lxc/scripts/rc.M.orig
index 1d480cac9..0cd9f0b52 100644
--- a/source/ap/lxc/scripts/rc.M.orig
+++ b/source/ap/lxc/scripts/rc.M.orig
@@ -26,7 +26,7 @@ fi
# Set the hostname.
if [ -r /etc/HOSTNAME ]; then
- /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
+ /bin/hostname $(cat /etc/HOSTNAME)
else
# fall back on this old default:
echo "darkstar.example.net" > /etc/HOSTNAME
@@ -67,14 +67,14 @@ fi
# that's how it is...
#
if [ -x /etc/rc.d/rc.pcmcia ]; then
- . /etc/rc.d/rc.pcmcia start
+ /etc/rc.d/rc.pcmcia start
# The cards might need a little extra time here to initialize.
sleep 5
fi
# Start the system logger.
if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
- . /etc/rc.d/rc.syslog start
+ /etc/rc.d/rc.syslog start
fi
# Update the X font indexes:
@@ -89,41 +89,36 @@ fi
if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then
if ! grep -wq nohotplug /proc/cmdline ; then
if [ -x /etc/rc.d/rc.udev ]; then
- /bin/sh /etc/rc.d/rc.udev start
+ /etc/rc.d/rc.udev start
fi
fi
fi
# Initialize the networking hardware.
if [ -x /etc/rc.d/rc.inet1 ]; then
- . /etc/rc.d/rc.inet1
+ /etc/rc.d/rc.inet1
fi
# Start D-Bus:
if [ -x /etc/rc.d/rc.messagebus ]; then
- sh /etc/rc.d/rc.messagebus start
+ /etc/rc.d/rc.messagebus start
fi
# Start Bluetooth:
if [ -x /etc/rc.d/rc.bluetooth ]; then
- sh /etc/rc.d/rc.bluetooth start
+ /etc/rc.d/rc.bluetooth start
fi
# Start wicd or networkmanager:
if [ -x /etc/rc.d/rc.wicd -a -x /usr/sbin/wicd ]; then
- sh /etc/rc.d/rc.wicd start
+ /etc/rc.d/rc.wicd start
elif [ -x /etc/rc.d/rc.networkmanager ]; then
- sh /etc/rc.d/rc.networkmanager start
+ /etc/rc.d/rc.networkmanager start
fi
# Start networking daemons:
if [ -x /etc/rc.d/rc.inet2 ]; then
- . /etc/rc.d/rc.inet2
-fi
-
-# Look for additional USB/SCSI/IEEE1394/etc devices on multiple LUNs:
-if [ -x /etc/rc.d/rc.scanluns ]; then
- . /etc/rc.d/rc.scanluns
+ /etc/rc.d/rc.inet2
fi
# Mount any additional filesystem types that haven't already been mounted:
@@ -131,12 +126,12 @@ mount -a -v 2> /dev/null | grep -v -e "already mounted" -e "ignored" | cut -f 1
# Start the Control Script for automounter:
if [ -x /etc/rc.d/rc.autofs ]; then
- sh /etc/rc.d/rc.autofs start
+ /etc/rc.d/rc.autofs start
fi
# Start the Network Time Protocol daemon:
if [ -x /etc/rc.d/rc.ntpd ]; then
- sh /etc/rc.d/rc.ntpd start
+ /etc/rc.d/rc.ntpd start
fi
# Remove stale locks and junk files (must be done after mount -a!)
@@ -155,12 +150,12 @@ chmod 1777 /tmp /var/tmp
# Start ACPI daemon.
if [ -x /etc/rc.d/rc.acpid ]; then
- . /etc/rc.d/rc.acpid start
+ /etc/rc.d/rc.acpid start
fi
# Enable CPU frequency scaling:
if [ -x /etc/rc.d/rc.cpufreq ]; then
- . /etc/rc.d/rc.cpufreq start
+ /etc/rc.d/rc.cpufreq start
fi
# Update any existing icon cache files:
@@ -187,18 +182,18 @@ fi
# Start console-kit-daemon:
if [ -x /etc/rc.d/rc.consolekit ]; then
- sh /etc/rc.d/rc.consolekit start
+ /etc/rc.d/rc.consolekit start
fi
# Start HAL:
if [ -x /etc/rc.d/rc.hald ]; then
- sh /etc/rc.d/rc.hald start
+ /etc/rc.d/rc.hald start
fi
# Start system-wide PulseAudio daemon (not recommended, nor required in
# order to use PulseAudio -- see the script for details):
if [ -x /etc/rc.d/rc.pulseaudio ]; then
- . /etc/rc.d/rc.pulseaudio start
+ /etc/rc.d/rc.pulseaudio start
fi
# These GTK+/pango files need to be kept up to date for
@@ -240,7 +235,7 @@ if [ -x /etc/rc.d/rc.cups ]; then
/etc/rc.d/rc.cups start
elif [ -x /etc/rc.d/rc.lprng ]; then
# Start LPRng (lpd):
- . /etc/rc.d/rc.lprng start
+ /etc/rc.d/rc.lprng start
fi
# Start netatalk. (a file/print server for Macs using Appletalk)
@@ -322,65 +317,72 @@ if grep -q quota /etc/fstab ; then
fi
# Start the SASL authentication server. This provides SASL
-# authentication services for sendmail:
+# authentication services for sendmail/postfix:
if [ -x /etc/rc.d/rc.saslauthd ]; then
- . /etc/rc.d/rc.saslauthd start
+ /etc/rc.d/rc.saslauthd start
fi
-# Start the sendmail daemon:
-if [ -x /etc/rc.d/rc.sendmail ]; then
- . /etc/rc.d/rc.sendmail start
+# Start the mail server. Try the rc.sendmail script first, then try rc.postfix.
+if [ -x /etc/rc.d/rc.sendmail -a -x usr/sbin/makemap ]; then
+ /etc/rc.d/rc.sendmail start
+elif [ -x /etc/rc.d/rc.postfix -a -x usr/sbin/postdrop ]; then
+ /etc/rc.d/rc.postfix start
fi
# Load ALSA (sound) defaults:
if [ -x /etc/rc.d/rc.alsa ]; then
- . /etc/rc.d/rc.alsa
+ /etc/rc.d/rc.alsa
fi
# Load a custom screen font if the user has an rc.font script.
if [ -x /etc/rc.d/rc.font ]; then
- . /etc/rc.d/rc.font
+ /etc/rc.d/rc.font
fi
# Load a custom keymap if the user has an rc.keymap script.
if [ -x /etc/rc.d/rc.keymap ]; then
- . /etc/rc.d/rc.keymap
+ /etc/rc.d/rc.keymap
fi
# Start the MySQL database:
if [ -x /etc/rc.d/rc.mysqld ]; then
- . /etc/rc.d/rc.mysqld start
+ /etc/rc.d/rc.mysqld start
fi
# Start Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
- . /etc/rc.d/rc.httpd start
+ /etc/rc.d/rc.httpd start
fi
# Start OpenLDAP:
if [ -x /etc/rc.d/rc.openldap ]; then
- . /etc/rc.d/rc.openldap start
+ /etc/rc.d/rc.openldap start
+fi
+
+# Start Dovecot:
+if [ -x /etc/rc.d/rc.dovecot ]; then
+ /etc/rc.d/rc.dovecot start
fi
# Start Samba (a file/print server for Win95/NT machines).
# Samba can be started in /etc/inetd.conf instead.
if [ -x /etc/rc.d/rc.samba ]; then
- . /etc/rc.d/rc.samba start
+ /etc/rc.d/rc.samba start
fi
# Start the GPM mouse server:
if [ -x /etc/rc.d/rc.gpm ]; then
- . /etc/rc.d/rc.gpm start
+ /etc/rc.d/rc.gpm start
fi
# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
- . /etc/rc.d/rc.sysvinit
+ /etc/rc.d/rc.sysvinit
fi
# Start the local setup procedure.
if [ -x /etc/rc.d/rc.local ]; then
- . /etc/rc.d/rc.local
+ /etc/rc.d/rc.local
fi
# All done.
diff --git a/source/ap/lxc/scripts/rc.S.lxc b/source/ap/lxc/scripts/rc.S.lxc
index eb804e878..d6bc21f0a 100644
--- a/source/ap/lxc/scripts/rc.S.lxc
+++ b/source/ap/lxc/scripts/rc.S.lxc
@@ -12,11 +12,11 @@
# Chris Willing for the initial work making this script lxc compatible.
container="lxc"
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
+PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
# Try to mount /proc:
if [ -z "$container" ]; then
-/sbin/mount -v proc /proc -n -t proc 2> /dev/null
+ /sbin/mount -v proc /proc -n -t proc 2> /dev/null
fi
# Mount sysfs next, if the kernel supports it:
@@ -32,13 +32,13 @@ fi
# initrd has already done so):
if [ -d /run -a -z "$container" ]; then
if ! grep -wq "tmpfs /run tmpfs" /proc/mounts ; then
- /sbin/mount -v -n -t tmpfs tmpfs /run -o mode=0755
+ /sbin/mount -v -n -t tmpfs tmpfs /run -o mode=0755,size=32M,nodev,nosuid,noexec
fi
fi
# Load the loop device kernel module:
if [ -x /etc/rc.d/rc.loop -a -z "$container" ]; then
- . /etc/rc.d/rc.loop start
+ /etc/rc.d/rc.loop start
fi
# Initialize udev to manage /dev entries and hotplugging.
@@ -52,7 +52,7 @@ fi
if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then
if ! grep -wq nohotplug /proc/cmdline ; then
if [ -x /etc/rc.d/rc.udev -a -z "$container" ]; then
- /bin/sh /etc/rc.d/rc.udev start
+ /etc/rc.d/rc.udev start
fi
fi
fi
@@ -193,7 +193,7 @@ fi
# Start FUSE, if requested:
if [ -x /etc/rc.d/rc.fuse -a -z "$container" ]; then
- sh /etc/rc.d/rc.fuse start
+ /etc/rc.d/rc.fuse start
fi
# Set the tick and frequency for the system clock.
@@ -315,8 +315,8 @@ if [ -z "$container" ]; then
echo " read-only"
echo
echo "to the Linux section in your /etc/lilo.conf and type 'lilo' to reinstall it."
- fi
-fi # Done checking root filesystem
+ fi # Done checking root filesystem
+fi
# Any /etc/mtab that exists here is old, so we start with a new one:
/bin/rm -f /etc/mtab{,~,.tmp} && /bin/touch /etc/mtab
@@ -349,7 +349,7 @@ fi
# Run the kernel module script. This updates the module dependencies and
# also supports manually loading kernel modules through rc.modules.local.
if [ -x /etc/rc.d/rc.modules -a -z "$container" ]; then
- . /etc/rc.d/rc.modules
+ /etc/rc.d/rc.modules
fi
# Configure kernel parameters:
@@ -408,7 +408,7 @@ fi
# Start cgmanager (or cgproxy in a container):
if [ -x /etc/rc.d/rc.cgmanager -a -d /sys/fs/cgroup ]; then
- sh /etc/rc.d/rc.cgmanager start
+ /etc/rc.d/rc.cgmanager start
fi
# Clean up some temporary files:
@@ -448,7 +448,7 @@ fi
# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
- . /etc/rc.d/rc.sysvinit
+ /etc/rc.d/rc.sysvinit
fi
# Run serial port setup script:
@@ -456,7 +456,7 @@ fi
# set up correctly. If this happens, you may have to edit the file from a
# boot disk, and/or set it as non-executable:
if [ -x /etc/rc.d/rc.serial -a -z "$container" ]; then
- sh /etc/rc.d/rc.serial start
+ /etc/rc.d/rc.serial start
fi
# Carry an entropy pool between reboots to improve randomness.
diff --git a/source/ap/lxc/scripts/rc.S.orig b/source/ap/lxc/scripts/rc.S.orig
index 20064e558..78e68e40a 100644
--- a/source/ap/lxc/scripts/rc.S.orig
+++ b/source/ap/lxc/scripts/rc.S.orig
@@ -5,7 +5,7 @@
# Mostly written by: Patrick J. Volkerding, <volkerdi@slackware.com>
#
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
+PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
# Try to mount /proc:
/sbin/mount -v proc /proc -n -t proc 2> /dev/null
@@ -23,13 +23,13 @@ fi
# initrd has already done so):
if [ -d /run ]; then
if ! grep -wq "tmpfs /run tmpfs" /proc/mounts ; then
- /sbin/mount -v -n -t tmpfs tmpfs /run -o mode=0755
+ /sbin/mount -v -n -t tmpfs tmpfs /run -o mode=0755,size=32M,nodev,nosuid,noexec
fi
fi
# Load the loop device kernel module:
if [ -x /etc/rc.d/rc.loop ]; then
- . /etc/rc.d/rc.loop start
+ /etc/rc.d/rc.loop start
fi
# Initialize udev to manage /dev entries and hotplugging.
@@ -43,7 +43,7 @@ fi
if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then
if ! grep -wq nohotplug /proc/cmdline ; then
if [ -x /etc/rc.d/rc.udev ]; then
- /bin/sh /etc/rc.d/rc.udev start
+ /etc/rc.d/rc.udev start
fi
fi
fi
@@ -55,7 +55,7 @@ if grep -wq cgroup /proc/filesystems ; then
# Check if we have some tools to autodetect the available cgroup controllers
if [ -x /bin/cut -a -x /bin/tail ]; then
# Mount a tmpfs as the cgroup filesystem root
- mount -t tmpfs -o mode=0755 cgroup_root /sys/fs/cgroup
+ mount -t tmpfs -o mode=0755,size=8M cgroup_root /sys/fs/cgroup
# Autodetect available controllers and mount them in subfolders
controllers="$(/bin/cut -f 1 /proc/cgroups | /bin/tail -n +2)"
for i in $controllers; do
@@ -179,7 +179,7 @@ fi
# Start FUSE, if requested:
if [ -x /etc/rc.d/rc.fuse ]; then
- sh /etc/rc.d/rc.fuse start
+ /etc/rc.d/rc.fuse start
fi
# Set the tick and frequency for the system clock.
@@ -326,7 +326,7 @@ fi
# Run the kernel module script. This updates the module dependencies and
# also supports manually loading kernel modules through rc.modules.local.
if [ -x /etc/rc.d/rc.modules ]; then
- . /etc/rc.d/rc.modules
+ /etc/rc.d/rc.modules
fi
# Configure kernel parameters:
@@ -379,7 +379,7 @@ fi
# Start cgmanager (or cgproxy in a container):
if [ -x /etc/rc.d/rc.cgmanager -a -d /sys/fs/cgroup ]; then
- sh /etc/rc.d/rc.cgmanager start
+ /etc/rc.d/rc.cgmanager start
fi
# Clean up some temporary files:
@@ -419,7 +419,7 @@ fi
# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
- . /etc/rc.d/rc.sysvinit
+ /etc/rc.d/rc.sysvinit
fi
# Run serial port setup script:
@@ -427,7 +427,7 @@ fi
# set up correctly. If this happens, you may have to edit the file from a
# boot disk, and/or set it as non-executable:
if [ -x /etc/rc.d/rc.serial ]; then
- sh /etc/rc.d/rc.serial start
+ /etc/rc.d/rc.serial start
fi
# Carry an entropy pool between reboots to improve randomness.
diff --git a/source/ap/lxc/scripts/rc.inet1.lxc b/source/ap/lxc/scripts/rc.inet1.lxc
index 2306a2fc9..58213a7c0 100644
--- a/source/ap/lxc/scripts/rc.inet1.lxc
+++ b/source/ap/lxc/scripts/rc.inet1.lxc
@@ -23,12 +23,19 @@ container="lxc"
###########
# If possible, log events in /var/log/messages:
-if [ -f /var/run/syslogd.pid -a -x /usr/bin/logger ]; then
+if [ -f /var/run/syslogd.pid ] && [ -x /usr/bin/logger ]; then
LOGGER=/usr/bin/logger
else # output to stdout/stderr:
LOGGER=/bin/cat
fi
+# Handy wrapper for verbose logging
+debug_log() {
+ if [ "$DEBUG_ETH_UP" = "yes" ]; then
+ echo "/etc/rc.d/rc.inet1: $*" | $LOGGER
+ fi
+}
+
############################
# DETERMINE INTERFACE LIST #
############################
@@ -46,9 +53,7 @@ do
IFNAME[$i]=${IFNAME[$i]:=eth${i}}
i=$(($i+1))
done
-if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: List of interfaces: '${IFNAME[@]}'" | $LOGGER
-fi
+debug_log "List of interfaces: '${IFNAME[*]}'"
######################
# LOOPBACK FUNCTIONS #
@@ -57,21 +62,22 @@ fi
# Function to bring up the loopback interface. If loopback is
# already up, do nothing.
lo_up() {
- if grep lo: /proc/net/dev 1> /dev/null ; then
- if ! /sbin/ifconfig | grep "^lo" 1> /dev/null ; then
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig lo 127.0.0.1" | $LOGGER
- /sbin/ifconfig lo 127.0.0.1
- echo "/etc/rc.d/rc.inet1: /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo" | $LOGGER
- /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
+ if [ -e /sys/class/net/lo ]; then
+ if ! /sbin/ip link show dev lo | grep -wq -e "state UP" -e "state UNKNOWN" ; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip address add 127.0.0.1/8 dev lo" | $LOGGER
+ /sbin/ip address add 127.0.0.1/8 dev lo
+ /sbin/ip link set dev lo up
+ echo "/etc/rc.d/rc.inet1: /sbin/ip route add 127.0.0.0/8 dev lo" | $LOGGER
+ /sbin/ip route add 127.0.0.0/8 dev lo
fi
fi
}
# Function to take down the loopback interface:
lo_down() {
- if grep lo: /proc/net/dev 1> /dev/null ; then
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig lo down" | $LOGGER
- /sbin/ifconfig lo down
+ if [ -e /sys/class/net/lo ]; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev lo down" | $LOGGER
+ /sbin/ip link set dev lo down
fi
}
@@ -79,27 +85,48 @@ lo_down() {
# INTERFACE FUNCTIONS #
#######################
+# Function to create virtual interfaces
+virtif_create() {
+ # argument is 'i' - the position of this interface in the VIRTIFNAME array.
+ # this loop goes from i=0 to i=number_of_configured_virtual_interfaces_minus_one
+ # which means it doesn't do anything if there are none.
+ for i in $(seq 0 $((${#VIRTIFNAME[@]} - 1))); do
+ /sbin/ip tuntap add dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]} user ${VIRTIFUSER[$i]} group ${VIRTIFGROUP[$i]}
+ done
+}
+
+# Function to destory virtual interfaces
+virtif_destroy() {
+ # argument is 'i' - the position of this interface in the VIRTIFNAME array.
+ for i in $(seq 0 $((${#VIRTIFNAME[@]} - 1))); do
+ /sbin/ip tuntap del dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]}
+ done
+}
+
# Function to assemble a bridge interface.
br_open() {
# argument is 'i' - the position of this interface in the IFNAME array.
- /sbin/brctl addbr ${IFNAME[$1]}
- for BRIF in $(echo ${BRNICS[$1]}); do
- /sbin/ifconfig $BRIF down
- /sbin/ifconfig $BRIF 0.0.0.0 promisc up
- /sbin/brctl addif ${IFNAME[$1]} $BRIF
+ /sbin/ip link add name ${IFNAME[$1]} type bridge
+ for BRIF in ${BRNICS[$1]}; do
+ /sbin/ip link set dev $BRIF down
+ /sbin/ip address add 0.0.0.0 dev $BRIF
+ /sbin/ip link set dev $BRIF master ${IFNAME[$1]}
+ /sbin/ip link set dev $BRIF up
done
+ /sbin/ip link set dev ${IFNAME[$1]} up
}
# Function to disassemble a bridge interface.
br_close() {
+ /sbin/ip link set dev ${IFNAME[$1]} down
# argument is 'i' - the position of this interface in the IFNAME array.
- #for BRIF in $(echo ${BRNICS[$1]}); do
+ #for BRIF in ${BRNICS[$1]}; do
for BRIF in $(ls --indicator-style=none /sys/class/net/${IFNAME[$1]}/brif/)
do
- /sbin/brctl delif ${IFNAME[$1]} $BRIF
+ /sbin/ip link set dev $BRIF nomaster
done
- /sbin/ifconfig ${IFNAME[$1]} down
- /sbin/brctl delbr ${IFNAME[$1]}
+ /sbin/ip link set dev ${IFNAME[$1]} down
+ /sbin/ip link del ${IFNAME[$1]}
}
# Function to bring up a network interface. If the interface is
@@ -112,13 +139,25 @@ if_up() {
[ "${IFNAME[$i]}" = "${1}" ] && break
i=$(($i+1))
done
+ # If "i" is greater or equal to "MAXNICS" at this point, it means we didn't
+ # find an entry in IFNAME array corresponding to "$1", which likely means
+ # there are more interfaces configured than MAXNICS. Let's err on the
+ # side of caution and do nothing instead of possibly doing the wrong thing.
+ if [ $i -ge $MAXNICS ]; then
+ echo "/etc/rc.d/rc.inet1: skipping ${1}, you might need to increase MAXNICS" | $LOGGER
+ return
+ fi
if [ -z "$container" ]; then
# If the interface is a bridge, then create it first:
[ -n "${BRNICS[$i]}" ] && br_open $i
# 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
+ if [ -z "${IPADDR[$i]}" ] && [ "${USE_DHCP[$i]}" != "yes" ]; then # skip unconfigured interfaces
+ debug_log "skipping ${1} early, interface is not configured in /etc/rc.d/rc.inet1.conf"
+ return 0
+ fi
+ if [ ! -e /sys/class/net/${1%%:*} ]; then # no interface yet
if /sbin/modprobe -c | grep -v "^#" | grep -w "alias ${1}" | grep -vw "alias ${1} off" > /dev/null ; then
echo "/etc/rc.d/rc.inet1: /sbin/modprobe ${1}" | $LOGGER
/sbin/modprobe ${1}
@@ -126,16 +165,19 @@ if_up() {
fi
fi # end check container
- 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 -w inet 1> /dev/null ; then # interface not up or not configured
- if [ ! "${HWADDR[$i]}" = "" ]; then # Set hardware address _before_ the interface goes up:
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} hw ether ${HWADDR[$i]}" | $LOGGER
- /sbin/ifconfig ${1} hw ether ${HWADDR[$i]}
+ if [ -e /sys/class/net/${1%%:*} ]; then # interface exists
+ if ! /sbin/ip address show dev ${1} 2>/dev/null | grep -wq inet || \
+ ! /sbin/ip link show dev ${1} | grep -wq "state UP" ; then # interface not up or not configured
+ if [ -n "${HWADDR[$i]}" ]; then # Set hardware address _before_ the interface goes up:
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} address ${HWADDR[$i]}" | $LOGGER
+ /sbin/ip link set dev ${1} address ${HWADDR[$i]}
+ fi
+ if [ -n "${MTU[$i]}" ]; then # Set MTU to something else than 1500
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} mtu ${MTU[$i]}" | $LOGGER
+ /sbin/ip link set dev ${1} mtu ${MTU[$i]}
fi
- if [ ! "${MTU[$i]}" = "" ]; then # Set MTU to something else than 1500
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} mtu ${MTU[$i]}" | $LOGGER
- /sbin/ifconfig ${1} mtu ${MTU[$i]}
+ if /sbin/ip link show dev ${1} | grep -wq "state DOWN" ; then
+ /sbin/ip link set dev ${1} up # Bring up interface
fi
if [ -x /etc/rc.d/rc.wireless ]; then
. /etc/rc.d/rc.wireless ${1} start # Initialize any wireless parameters
@@ -144,13 +186,13 @@ if_up() {
# Clear DHCP_OPTIONS before adding new options to it:
unset DHCP_OPTIONS
# Set DHCP_OPTIONS for this interface:
- [ ${DHCP_HOSTNAME[$i]} ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
+ [ -n "${DHCP_HOSTNAME[$i]}" ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
[ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C resolv.conf"
[ "${DHCP_KEEPNTP[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C ntp.conf"
[ "${DHCP_KEEPGW[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -G"
[ "${DHCP_DEBUG[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -d"
[ "${DHCP_NOIPV4LL[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -L"
- [ ${DHCP_IPADDR[$i]} ] && DHCP_OPTIONS="$DHCP_OPTIONS -r ${DHCP_IPADDR[$i]}"
+ [ -n "${DHCP_IPADDR[$i]}" ] && DHCP_OPTIONS="$DHCP_OPTIONS -r ${DHCP_IPADDR[$i]}"
echo "Polling for DHCP server on interface ${1}:"
# If you set a timeout, you get one, even if the kernel doesn't think that
# your device is connected, in case /sys isn't right (which it usually isn't
@@ -158,43 +200,54 @@ if_up() {
#### (start commented out)
# This is deactivated for now since the kernel has been returning incorrect
# results concerning whether the interface carrier is detected.
- #if [ "${DHCP_TIMEOUT[$i]}" = "" ]; then
- # ifconfig ${1} up && sleep 1
+ #if [ -z "${DHCP_TIMEOUT[$i]}" ]; then
+ # /sbin/ip link set dev ${1} up && sleep 1
# CONNSTATUS="$(cat /sys/class/net/${1}/carrier 2> /dev/null)"
- # ifconfig ${1} down
+ # /sbin/ip link set dev ${1} down
# if [ "$CONNSTATUS" = "0" ]; then
# # The kernel has just told us the cable isn't even plugged in, but we will
# # give any DHCP server a short chance to reply anyway:
- # echo "No carrier detected on ${1}. Reducing DHCP timeout to 10 seconds."
- # DHCP_TIMEOUT[$i]=10
+ # echo "No carrier detected on ${1}. Reducing DHCP timeout to 15 seconds."
+ # DHCP_TIMEOUT[$i]=15
# fi
#fi
#### (end commented out)
- # 10 seconds should be a reasonable default DHCP timeout. 30 was too much.
- echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS} ${1}" | $LOGGER
- /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS} ${1}
+ # 15 seconds should be a reasonable default DHCP timeout. 30 was too much.
+ echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -L -t ${DHCP_TIMEOUT[$i]:-15} ${DHCP_OPTIONS} ${1}" | $LOGGER
+ /sbin/dhcpcd -L -t ${DHCP_TIMEOUT[$i]:-15} ${DHCP_OPTIONS} ${1}
+ # If the dhcpcd call succeeds, add extra IP addresses, if defined, to interface
+ if [ "$?" == "0" ] && [ -n "${IPALIASES[$i]}" ]; then
+ num=0
+ for ipalias in ${IPALIASES[$i]}; do
+ /sbin/ip address add ${ipalias}/32 dev ${1} label ${1}:${num} ;
+ num=$(($num + 1))
+ done
+ fi
else # bring up interface using a static IP address
- if [ ! "${IPADDR[$i]}" = "" ]; then # skip unconfigured interfaces
- # Determine broadcast address from the IP address and netmask:
- BROADCAST[$i]=`/bin/ipmask ${NETMASK[$i]} ${IPADDR[$i]}|cut -f1 -d' '`
+ if [ -n "${IPADDR[$i]}" ]; then # skip unconfigured interfaces
# Set up the network card:
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} ${IPADDR[$i]} broadcast ${BROADCAST[$i]} netmask ${NETMASK[$i]}" | $LOGGER
- /sbin/ifconfig ${1} ${IPADDR[$i]} broadcast ${BROADCAST[$i]} netmask ${NETMASK[$i]}
- else
- if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: ${1} interface is not configured in /etc/rc.d/rc.inet1.conf" | $LOGGER
+ echo "/etc/rc.d/rc.inet1: /sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} dev ${1}" | $LOGGER
+ /sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} dev ${1}
+ if /sbin/ip link show dev ${1} | grep -wq "state DOWN" ; then
+ /sbin/ip link set dev ${1} up # Bring up interface
fi
+ # Add extra IP addresses, if defined, to interface
+ if [ -n "${IPALIASES[$i]}" ]; then
+ num=0
+ for ipalias in ${IPALIASES[$i]}; do
+ /sbin/ip address add ${ipalias}/32 dev ${1} label ${1}:${num} ;
+ num=$(($num + 1))
+ done
+ fi
+ else
+ debug_log "${1} interface is not configured in /etc/rc.d/rc.inet1.conf"
fi
fi
else
- if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: ${1} is already up, skipping" | $LOGGER
- fi
+ debug_log "${1} is already up, skipping"
fi
else
- if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: ${1} interface does not exist (yet)" | $LOGGER
- fi
+ debug_log "${1} interface does not exist (yet)"
fi
}
@@ -206,14 +259,18 @@ if_down() {
[ "${IFNAME[$i]}" = "${1}" ] && break
i=$(($i+1))
done
- if grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then
+ if [ $i -ge $MAXNICS ]; then
+ echo "/etc/rc.d/rc.inet1: skipping ${1}, you might need to increase MAXNICS" | $LOGGER
+ return
+ fi
+ if [ -e /sys/class/net/${1%%:*} ]; then
if [ "${USE_DHCP[$i]}" = "yes" ]; then
echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -k -d ${1}" | $LOGGER
- /sbin/dhcpcd -k -d ${1} 2> /dev/null || /sbin/ifconfig ${1} down
+ /sbin/dhcpcd -k -d ${1} 2> /dev/null || /sbin/ip link set dev ${1} down
sleep 1
else
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} down" | $LOGGER
- /sbin/ifconfig ${1} down
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} down" | $LOGGER
+ /sbin/ip link set dev ${1} down
fi
if [ -x /etc/rc.d/rc.wireless ]; then
. /etc/rc.d/rc.wireless ${1} stop # Kill wireless daemons if any.
@@ -231,26 +288,27 @@ if_down() {
# Function to bring up the gateway if there is not yet a default route:
gateway_up() {
- if ! /sbin/route -n | grep "^0.0.0.0" 1> /dev/null ; then
- if [ ! "$GATEWAY" = "" ]; then
- echo "/etc/rc.d/rc.inet1: /sbin/route add default gw ${GATEWAY} metric 1" | $LOGGER
- /sbin/route add default gw ${GATEWAY} metric 1 2>&1 | $LOGGER
+ if ! /sbin/ip route show | grep -wq default ; then
+ if [ -n "$GATEWAY" ]; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip route add default via ${GATEWAY}" | $LOGGER
+ /sbin/ip route add default via ${GATEWAY} | $LOGGER
fi
fi
}
# Function to take down an existing default gateway:
gateway_down() {
- if /sbin/route -n | grep "^0.0.0.0" 1> /dev/null ; then
- echo "/etc/rc.d/rc.inet1: /sbin/route del default" | $LOGGER
- /sbin/route del default
+ if /sbin/ip route show | grep -wq default ; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip route del default" | $LOGGER
+ /sbin/ip route del default
fi
}
# Function to start the network:
start() {
lo_up
- for i in ${IFNAME[@]} ; do
+ virtif_create
+ for i in "${IFNAME[@]}" ; do
if_up $i
done
gateway_up
@@ -259,9 +317,10 @@ start() {
# Function to stop the network:
stop() {
gateway_down
- for i in ${IFNAME[@]} ; do
+ for i in "${IFNAME[@]}" ; do
if_down $i
done
+ virtif_destroy
lo_down
}
@@ -271,59 +330,38 @@ stop() {
############
case "$1" in
-'start') # "start" brings up all configured interfaces:
+start|up) # "start" (or "up") brings up all configured interfaces:
start
;;
-'stop') # "stop" takes down all configured interfaces:
+stop|down) # "stop" (or "down") takes down all configured interfaces:
stop
;;
-'restart') # "restart" restarts the network:
+restart) # "restart" restarts the network:
stop
start
;;
-'lo_start') # Start the loopback interface:
+lo_start|lo_up) # Start the loopback interface:
lo_up
;;
-*_start) # Example: "eth1_start" will start the specified interface 'eth1'
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
+lo_stop|lo_down) # Stop the loopback interface:
+ lo_down
+ ;;
+*_start|*_up) # Example: "eth1_start" (or "eth1_up") will start the specified interface 'eth1'
+ INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1)
if_up $INTERFACE
gateway_up
;;
-'lo_stop') # Stop the loopback interface:
- lo_down
- ;;
-*_stop) # Example: "eth0_stop" will stop the specified interface 'eth0'
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
+*_stop|*_down) # Example: "eth0_stop" (or "eth0_down") will stop the specified interface 'eth0'
+ INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1)
if_down $INTERFACE
;;
*_restart) # Example: "wlan0_restart" will take 'wlan0' down and up again
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
+ INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1)
if_down $INTERFACE
sleep 1
if_up $INTERFACE
gateway_up
;;
-'up') # "up" does the same thing as "start"
- start
- ;;
-'down') # "down" does the same thing as "stop"
- stop
- ;;
-'lo_up') # Start the loopback interface:
- lo_up
- ;;
-*_up) # "*_up" does the same thing as "*_start"
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
- if_up $INTERFACE
- gateway_up
- ;;
-'lo_down') # Stop the loopback interface:
- lo_down
- ;;
-*_down) # "*_down" does the same thing as "*_stop"
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
- if_down $INTERFACE
- ;;
*) # The default is to bring up all configured interfaces:
start
esac
diff --git a/source/ap/lxc/scripts/rc.inet1.orig b/source/ap/lxc/scripts/rc.inet1.orig
index f2d85a6d0..2f566ef89 100644
--- a/source/ap/lxc/scripts/rc.inet1.orig
+++ b/source/ap/lxc/scripts/rc.inet1.orig
@@ -16,12 +16,19 @@
###########
# If possible, log events in /var/log/messages:
-if [ -f /var/run/syslogd.pid -a -x /usr/bin/logger ]; then
+if [ -f /var/run/syslogd.pid ] && [ -x /usr/bin/logger ]; then
LOGGER=/usr/bin/logger
else # output to stdout/stderr:
LOGGER=/bin/cat
fi
+# Handy wrapper for verbose logging
+debug_log() {
+ if [ "$DEBUG_ETH_UP" = "yes" ]; then
+ echo "/etc/rc.d/rc.inet1: $*" | $LOGGER
+ fi
+}
+
############################
# DETERMINE INTERFACE LIST #
############################
@@ -39,9 +46,7 @@ do
IFNAME[$i]=${IFNAME[$i]:=eth${i}}
i=$(($i+1))
done
-if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: List of interfaces: '${IFNAME[@]}'" | $LOGGER
-fi
+debug_log "List of interfaces: '${IFNAME[*]}'"
######################
# LOOPBACK FUNCTIONS #
@@ -50,21 +55,22 @@ fi
# Function to bring up the loopback interface. If loopback is
# already up, do nothing.
lo_up() {
- if grep lo: /proc/net/dev 1> /dev/null ; then
- if ! /sbin/ifconfig | grep "^lo" 1> /dev/null ; then
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig lo 127.0.0.1" | $LOGGER
- /sbin/ifconfig lo 127.0.0.1
- echo "/etc/rc.d/rc.inet1: /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo" | $LOGGER
- /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
+ if [ -e /sys/class/net/lo ]; then
+ if ! /sbin/ip link show dev lo | grep -wq -e "state UP" -e "state UNKNOWN" ; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip address add 127.0.0.1/8 dev lo" | $LOGGER
+ /sbin/ip address add 127.0.0.1/8 dev lo
+ /sbin/ip link set dev lo up
+ echo "/etc/rc.d/rc.inet1: /sbin/ip route add 127.0.0.0/8 dev lo" | $LOGGER
+ /sbin/ip route add 127.0.0.0/8 dev lo
fi
fi
}
# Function to take down the loopback interface:
lo_down() {
- if grep lo: /proc/net/dev 1> /dev/null ; then
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig lo down" | $LOGGER
- /sbin/ifconfig lo down
+ if [ -e /sys/class/net/lo ]; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev lo down" | $LOGGER
+ /sbin/ip link set dev lo down
fi
}
@@ -72,27 +78,48 @@ lo_down() {
# INTERFACE FUNCTIONS #
#######################
+# Function to create virtual interfaces
+virtif_create() {
+ # argument is 'i' - the position of this interface in the VIRTIFNAME array.
+ # this loop goes from i=0 to i=number_of_configured_virtual_interfaces_minus_one
+ # which means it doesn't do anything if there are none.
+ for i in $(seq 0 $((${#VIRTIFNAME[@]} - 1))); do
+ /sbin/ip tuntap add dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]} user ${VIRTIFUSER[$i]} group ${VIRTIFGROUP[$i]}
+ done
+}
+
+# Function to destory virtual interfaces
+virtif_destroy() {
+ # argument is 'i' - the position of this interface in the VIRTIFNAME array.
+ for i in $(seq 0 $((${#VIRTIFNAME[@]} - 1))); do
+ /sbin/ip tuntap del dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]}
+ done
+}
+
# Function to assemble a bridge interface.
br_open() {
# argument is 'i' - the position of this interface in the IFNAME array.
- /sbin/brctl addbr ${IFNAME[$1]}
- for BRIF in $(echo ${BRNICS[$1]}); do
- /sbin/ifconfig $BRIF down
- /sbin/ifconfig $BRIF 0.0.0.0 promisc up
- /sbin/brctl addif ${IFNAME[$1]} $BRIF
+ /sbin/ip link add name ${IFNAME[$1]} type bridge
+ for BRIF in ${BRNICS[$1]}; do
+ /sbin/ip link set dev $BRIF down
+ /sbin/ip address add 0.0.0.0 dev $BRIF
+ /sbin/ip link set dev $BRIF master ${IFNAME[$1]}
+ /sbin/ip link set dev $BRIF up
done
+ /sbin/ip link set dev ${IFNAME[$1]} up
}
# Function to disassemble a bridge interface.
br_close() {
+ /sbin/ip link set dev ${IFNAME[$1]} down
# argument is 'i' - the position of this interface in the IFNAME array.
- #for BRIF in $(echo ${BRNICS[$1]}); do
+ #for BRIF in ${BRNICS[$1]}; do
for BRIF in $(ls --indicator-style=none /sys/class/net/${IFNAME[$1]}/brif/)
do
- /sbin/brctl delif ${IFNAME[$1]} $BRIF
+ /sbin/ip link set dev $BRIF nomaster
done
- /sbin/ifconfig ${IFNAME[$1]} down
- /sbin/brctl delbr ${IFNAME[$1]}
+ /sbin/ip link set dev ${IFNAME[$1]} down
+ /sbin/ip link del ${IFNAME[$1]}
}
# Function to bring up a network interface. If the interface is
@@ -105,26 +132,41 @@ if_up() {
[ "${IFNAME[$i]}" = "${1}" ] && break
i=$(($i+1))
done
+ # If "i" is greater or equal to "MAXNICS" at this point, it means we didn't
+ # find an entry in IFNAME array corresponding to "$1", which likely means
+ # there are more interfaces configured than MAXNICS. Let's err on the
+ # side of caution and do nothing instead of possibly doing the wrong thing.
+ if [ $i -ge $MAXNICS ]; then
+ echo "/etc/rc.d/rc.inet1: skipping ${1}, you might need to increase MAXNICS" | $LOGGER
+ return
+ fi
# If the interface is a bridge, then create it first:
[ -n "${BRNICS[$i]}" ] && br_open $i
# 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
+ if [ -z "${IPADDR[$i]}" ] && [ "${USE_DHCP[$i]}" != "yes" ]; then # skip unconfigured interfaces
+ debug_log "skipping ${1} early, interface is not configured in /etc/rc.d/rc.inet1.conf"
+ return 0
+ fi
+ if [ ! -e /sys/class/net/${1%%:*} ]; then # no interface yet
if /sbin/modprobe -c | grep -v "^#" | grep -w "alias ${1}" | grep -vw "alias ${1} off" > /dev/null ; then
echo "/etc/rc.d/rc.inet1: /sbin/modprobe ${1}" | $LOGGER
/sbin/modprobe ${1}
fi
fi
- 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 -w inet 1> /dev/null ; then # interface not up or not configured
- if [ ! "${HWADDR[$i]}" = "" ]; then # Set hardware address _before_ the interface goes up:
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} hw ether ${HWADDR[$i]}" | $LOGGER
- /sbin/ifconfig ${1} hw ether ${HWADDR[$i]}
+ if [ -e /sys/class/net/${1%%:*} ]; then # interface exists
+ if ! /sbin/ip address show dev ${1} 2>/dev/null | grep -wq inet || \
+ ! /sbin/ip link show dev ${1} | grep -wq "state UP" ; then # interface not up or not configured
+ if [ -n "${HWADDR[$i]}" ]; then # Set hardware address _before_ the interface goes up:
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} address ${HWADDR[$i]}" | $LOGGER
+ /sbin/ip link set dev ${1} address ${HWADDR[$i]}
+ fi
+ if [ -n "${MTU[$i]}" ]; then # Set MTU to something else than 1500
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} mtu ${MTU[$i]}" | $LOGGER
+ /sbin/ip link set dev ${1} mtu ${MTU[$i]}
fi
- if [ ! "${MTU[$i]}" = "" ]; then # Set MTU to something else than 1500
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} mtu ${MTU[$i]}" | $LOGGER
- /sbin/ifconfig ${1} mtu ${MTU[$i]}
+ if /sbin/ip link show dev ${1} | grep -wq "state DOWN" ; then
+ /sbin/ip link set dev ${1} up # Bring up interface
fi
if [ -x /etc/rc.d/rc.wireless ]; then
. /etc/rc.d/rc.wireless ${1} start # Initialize any wireless parameters
@@ -133,13 +175,13 @@ if_up() {
# Clear DHCP_OPTIONS before adding new options to it:
unset DHCP_OPTIONS
# Set DHCP_OPTIONS for this interface:
- [ ${DHCP_HOSTNAME[$i]} ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
+ [ -n "${DHCP_HOSTNAME[$i]}" ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
[ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C resolv.conf"
[ "${DHCP_KEEPNTP[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C ntp.conf"
[ "${DHCP_KEEPGW[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -G"
[ "${DHCP_DEBUG[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -d"
[ "${DHCP_NOIPV4LL[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -L"
- [ ${DHCP_IPADDR[$i]} ] && DHCP_OPTIONS="$DHCP_OPTIONS -r ${DHCP_IPADDR[$i]}"
+ [ -n "${DHCP_IPADDR[$i]}" ] && DHCP_OPTIONS="$DHCP_OPTIONS -r ${DHCP_IPADDR[$i]}"
echo "Polling for DHCP server on interface ${1}:"
# If you set a timeout, you get one, even if the kernel doesn't think that
# your device is connected, in case /sys isn't right (which it usually isn't
@@ -147,43 +189,54 @@ if_up() {
#### (start commented out)
# This is deactivated for now since the kernel has been returning incorrect
# results concerning whether the interface carrier is detected.
- #if [ "${DHCP_TIMEOUT[$i]}" = "" ]; then
- # ifconfig ${1} up && sleep 1
+ #if [ -z "${DHCP_TIMEOUT[$i]}" ]; then
+ # /sbin/ip link set dev ${1} up && sleep 1
# CONNSTATUS="$(cat /sys/class/net/${1}/carrier 2> /dev/null)"
- # ifconfig ${1} down
+ # /sbin/ip link set dev ${1} down
# if [ "$CONNSTATUS" = "0" ]; then
# # The kernel has just told us the cable isn't even plugged in, but we will
# # give any DHCP server a short chance to reply anyway:
- # echo "No carrier detected on ${1}. Reducing DHCP timeout to 10 seconds."
- # DHCP_TIMEOUT[$i]=10
+ # echo "No carrier detected on ${1}. Reducing DHCP timeout to 15 seconds."
+ # DHCP_TIMEOUT[$i]=15
# fi
#fi
#### (end commented out)
- # 10 seconds should be a reasonable default DHCP timeout. 30 was too much.
- echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS} ${1}" | $LOGGER
- /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS} ${1}
+ # 15 seconds should be a reasonable default DHCP timeout. 30 was too much.
+ echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -L -t ${DHCP_TIMEOUT[$i]:-15} ${DHCP_OPTIONS} ${1}" | $LOGGER
+ /sbin/dhcpcd -L -t ${DHCP_TIMEOUT[$i]:-15} ${DHCP_OPTIONS} ${1}
+ # If the dhcpcd call succeeds, add extra IP addresses, if defined, to interface
+ if [ "$?" == "0" ] && [ -n "${IPALIASES[$i]}" ]; then
+ num=0
+ for ipalias in ${IPALIASES[$i]}; do
+ /sbin/ip address add ${ipalias}/32 dev ${1} label ${1}:${num} ;
+ num=$(($num + 1))
+ done
+ fi
else # bring up interface using a static IP address
- if [ ! "${IPADDR[$i]}" = "" ]; then # skip unconfigured interfaces
- # Determine broadcast address from the IP address and netmask:
- BROADCAST[$i]=`/bin/ipmask ${NETMASK[$i]} ${IPADDR[$i]}|cut -f1 -d' '`
+ if [ -n "${IPADDR[$i]}" ]; then # skip unconfigured interfaces
# Set up the network card:
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} ${IPADDR[$i]} broadcast ${BROADCAST[$i]} netmask ${NETMASK[$i]}" | $LOGGER
- /sbin/ifconfig ${1} ${IPADDR[$i]} broadcast ${BROADCAST[$i]} netmask ${NETMASK[$i]}
- else
- if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: ${1} interface is not configured in /etc/rc.d/rc.inet1.conf" | $LOGGER
+ echo "/etc/rc.d/rc.inet1: /sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} dev ${1}" | $LOGGER
+ /sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} dev ${1}
+ if /sbin/ip link show dev ${1} | grep -wq "state DOWN" ; then
+ /sbin/ip link set dev ${1} up # Bring up interface
fi
+ # Add extra IP addresses, if defined, to interface
+ if [ -n "${IPALIASES[$i]}" ]; then
+ num=0
+ for ipalias in ${IPALIASES[$i]}; do
+ /sbin/ip address add ${ipalias}/32 dev ${1} label ${1}:${num} ;
+ num=$(($num + 1))
+ done
+ fi
+ else
+ debug_log "${1} interface is not configured in /etc/rc.d/rc.inet1.conf"
fi
fi
else
- if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: ${1} is already up, skipping" | $LOGGER
- fi
+ debug_log "${1} is already up, skipping"
fi
else
- if [ "$DEBUG_ETH_UP" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: ${1} interface does not exist (yet)" | $LOGGER
- fi
+ debug_log "${1} interface does not exist (yet)"
fi
}
@@ -195,14 +248,18 @@ if_down() {
[ "${IFNAME[$i]}" = "${1}" ] && break
i=$(($i+1))
done
- if grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then
+ if [ $i -ge $MAXNICS ]; then
+ echo "/etc/rc.d/rc.inet1: skipping ${1}, you might need to increase MAXNICS" | $LOGGER
+ return
+ fi
+ if [ -e /sys/class/net/${1%%:*} ]; then
if [ "${USE_DHCP[$i]}" = "yes" ]; then
echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -k -d ${1}" | $LOGGER
- /sbin/dhcpcd -k -d ${1} 2> /dev/null || /sbin/ifconfig ${1} down
+ /sbin/dhcpcd -k -d ${1} 2> /dev/null || /sbin/ip link set dev ${1} down
sleep 1
else
- echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} down" | $LOGGER
- /sbin/ifconfig ${1} down
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} down" | $LOGGER
+ /sbin/ip link set dev ${1} down
fi
if [ -x /etc/rc.d/rc.wireless ]; then
. /etc/rc.d/rc.wireless ${1} stop # Kill wireless daemons if any.
@@ -220,26 +277,27 @@ if_down() {
# Function to bring up the gateway if there is not yet a default route:
gateway_up() {
- if ! /sbin/route -n | grep "^0.0.0.0" 1> /dev/null ; then
- if [ ! "$GATEWAY" = "" ]; then
- echo "/etc/rc.d/rc.inet1: /sbin/route add default gw ${GATEWAY} metric 1" | $LOGGER
- /sbin/route add default gw ${GATEWAY} metric 1 2>&1 | $LOGGER
+ if ! /sbin/ip route show | grep -wq default ; then
+ if [ -n "$GATEWAY" ]; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip route add default via ${GATEWAY}" | $LOGGER
+ /sbin/ip route add default via ${GATEWAY} | $LOGGER
fi
fi
}
# Function to take down an existing default gateway:
gateway_down() {
- if /sbin/route -n | grep "^0.0.0.0" 1> /dev/null ; then
- echo "/etc/rc.d/rc.inet1: /sbin/route del default" | $LOGGER
- /sbin/route del default
+ if /sbin/ip route show | grep -wq default ; then
+ echo "/etc/rc.d/rc.inet1: /sbin/ip route del default" | $LOGGER
+ /sbin/ip route del default
fi
}
# Function to start the network:
start() {
lo_up
- for i in ${IFNAME[@]} ; do
+ virtif_create
+ for i in "${IFNAME[@]}" ; do
if_up $i
done
gateway_up
@@ -248,9 +306,10 @@ start() {
# Function to stop the network:
stop() {
gateway_down
- for i in ${IFNAME[@]} ; do
+ for i in "${IFNAME[@]}" ; do
if_down $i
done
+ virtif_destroy
lo_down
}
@@ -260,59 +319,38 @@ stop() {
############
case "$1" in
-'start') # "start" brings up all configured interfaces:
+start|up) # "start" (or "up") brings up all configured interfaces:
start
;;
-'stop') # "stop" takes down all configured interfaces:
+stop|down) # "stop" (or "down") takes down all configured interfaces:
stop
;;
-'restart') # "restart" restarts the network:
+restart) # "restart" restarts the network:
stop
start
;;
-'lo_start') # Start the loopback interface:
+lo_start|lo_up) # Start the loopback interface:
lo_up
;;
-*_start) # Example: "eth1_start" will start the specified interface 'eth1'
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
+lo_stop|lo_down) # Stop the loopback interface:
+ lo_down
+ ;;
+*_start|*_up) # Example: "eth1_start" (or "eth1_up") will start the specified interface 'eth1'
+ INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1)
if_up $INTERFACE
gateway_up
;;
-'lo_stop') # Stop the loopback interface:
- lo_down
- ;;
-*_stop) # Example: "eth0_stop" will stop the specified interface 'eth0'
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
+*_stop|*_down) # Example: "eth0_stop" (or "eth0_down") will stop the specified interface 'eth0'
+ INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1)
if_down $INTERFACE
;;
*_restart) # Example: "wlan0_restart" will take 'wlan0' down and up again
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
+ INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1)
if_down $INTERFACE
sleep 1
if_up $INTERFACE
gateway_up
;;
-'up') # "up" does the same thing as "start"
- start
- ;;
-'down') # "down" does the same thing as "stop"
- stop
- ;;
-'lo_up') # Start the loopback interface:
- lo_up
- ;;
-*_up) # "*_up" does the same thing as "*_start"
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
- if_up $INTERFACE
- gateway_up
- ;;
-'lo_down') # Stop the loopback interface:
- lo_down
- ;;
-*_down) # "*_down" does the same thing as "*_stop"
- INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
- if_down $INTERFACE
- ;;
*) # The default is to bring up all configured interfaces:
start
esac
diff --git a/source/ap/lxc/slack-desc b/source/ap/lxc/slack-desc
index 1a000970e..d6660b335 100644
--- a/source/ap/lxc/slack-desc
+++ b/source/ap/lxc/slack-desc
@@ -1,8 +1,8 @@
# HOW TO EDIT THIS FILE:
-# The "handy ruler" below makes it easier to edit a package description. Line
+# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
-# on the right side marks the last column you can put a character in. You must
-# make exactly 11 lines for the formatting to be correct. It's also
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
@@ -10,10 +10,10 @@ lxc: lxc (Linux Containers)
lxc:
lxc: Linux Containers (LXC) are an operating system-level virtualization
lxc: method for running multiple isolated server installs (containers) on
-lxc: a single control host. LXC does not provide a virtual machine, but
+lxc: a single control host. LXC does not provide a virtual machine, but
lxc: rather provides a virtual environment that has its own process and
-lxc: network space. It is similar to a chroot, but offers more isolation.
+lxc: network space. It is similar to a chroot, but offers more isolation.
lxc:
lxc: Daniel Lezcano is the primary developer of lxc.
-lxc: Homepage: https://linuxcontainers.org
+lxc: Homepage: https://linuxcontainers.org
lxc: