diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2015-02-09 02:44:20 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-02-09 02:44:20 +0100 |
commit | 8c9b11aed2c2eb9ad3a77f821efeabb48f848e31 (patch) | |
tree | e6c423e4046cb76c6a61dbc157d313dd7c5822a6 | |
parent | 29fc7eb1549de7622dc1f9fbbfe647b55adace17 (diff) | |
parent | 40f8ecbf261c8b3319350e681a207ed4b42f424d (diff) | |
download | util-vserver-netns-8c9b11aed2c2eb9ad3a77f821efeabb48f848e31.tar.gz util-vserver-netns-8c9b11aed2c2eb9ad3a77f821efeabb48f848e31.tar.bz2 util-vserver-netns-8c9b11aed2c2eb9ad3a77f821efeabb48f848e31.zip |
Merge commit '2.3' into debian
* commit '2.3':
Add insserv config to define $util-vserver system facility.
Add util-vserver-netns initscript.
Use spline-netns folder, to not collidate with default netns handling.
Add vshelper with netns support.
Use nullglob for all globbings.
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | util-vserver | 1 | ||||
-rwxr-xr-x | util-vserver-netns | 65 | ||||
-rw-r--r-- | util-vserver-vars | 3 | ||||
-rwxr-xr-x | vnamespace.netns | 2 | ||||
-rw-r--r-- | vserver.functions | 3 | ||||
-rwxr-xr-x | vserver.netns | 8 | ||||
-rwxr-xr-x | vshelper.netns | 10 |
8 files changed, 99 insertions, 8 deletions
@@ -2,16 +2,25 @@ all: clean: -install: vserver.netns vnamespace.netns util-vserver-vars vserver.functions vserver-netns.sh vservers-default - install -d "$(DESTDIR)/usr/share/util-vserver/netns/" \ +install: vserver.netns vnamespace.netns vshelper.netns util-vserver-vars vserver.functions vserver-netns.sh vservers-default util-vserver-netns util-vserver + install -d "$(DESTDIR)/sbin/" \ + "$(DESTDIR)/usr/share/util-vserver/netns/" \ + "$(DESTDIR)/usr/lib/x86_64-linux-gnu/util-vserver/" \ "$(DESTDIR)/usr/sbin/" \ "$(DESTDIR)/etc/profile.d/" \ - "$(DESTDIR)/etc/default/" + "$(DESTDIR)/etc/default/" \ + "$(DESTDIR)/etc/init.d/" \ + "$(DESTDIR)/etc/insserv.conf.d/" install vserver.netns "$(DESTDIR)/usr/sbin/" install vnamespace.netns "$(DESTDIR)/usr/sbin/" + install vshelper.netns "$(DESTDIR)/usr/lib/x86_64-linux-gnu/util-vserver/" + install util-vserver-netns "$(DESTDIR)/etc/init.d/" install -m644 util-vserver-vars "$(DESTDIR)/usr/share/util-vserver/netns/" install -m644 vserver.functions "$(DESTDIR)/usr/share/util-vserver/netns/" install -m644 vserver-netns.sh "$(DESTDIR)/etc/profile.d/" install -m644 vservers-default "$(DESTDIR)/etc/default/" + install -m644 util-vserver "$(DESTDIR)/etc/insserv.conf.d/" + + ln -s /usr/lib/x86_64-linux-gnu/util-vserver/vshelper.netns "$(DESTDIR)/sbin/" .PHONY: install diff --git a/util-vserver b/util-vserver new file mode 100644 index 0000000..74c0635 --- /dev/null +++ b/util-vserver @@ -0,0 +1 @@ +$util-vserver +util-vserver +util-vserver-netns diff --git a/util-vserver-netns b/util-vserver-netns new file mode 100755 index 0000000..6e1a04a --- /dev/null +++ b/util-vserver-netns @@ -0,0 +1,65 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: util-vserver-netns +# Required-Start: $remote_fs $syslog $time util-vserver +# Required-Stop: $remote_fs $syslog $time util-vserver +# X-Start-Before: vservers-default +# X-Stop-After: vservers-default +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Sets the path to vshelper for netns handling +# Description: Sets the path to vshelper for netns handling +### END INIT INFO + +: ${UTIL_VSERVER_VARS:=/usr/share/util-vserver/netns/util-vserver-vars} +test -e "$UTIL_VSERVER_VARS" || { + echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 + exit 1 +} +. "$UTIL_VSERVER_VARS" + +LOCKFILE=util-vserver-netns +. "$_LIB_VSERVER_INIT_FUNCTIONS" +. "$_LIB_FUNCTIONS" +. "$_LIB_VSERVER_FUNCTIONS" + +function start() +{ + _beginResult $"Setting path to vshelper" + set_helper + local retval=$? + _endResult $retval + test "$retval" -ne 0 || touch "$lockfile" + return $retval +} + +function stop() +{ + $_RM -f "$lockfile" +} + +function restart() +{ + stop + start +} + +case "$1" in + start|stop|restart) $1;; + reload) ;; + condrestart) + test -f $lockfile && restart || : + ;; + status) + test -f $lockfile && { + echo $"Path to vshelper.netns has been set" + exit 0 + } + echo $"Path to vshelper.netns has not been set" + exit 1 + ;; + *) + echo "Usage: $0 {start|stop|reload|restart|condrestart|status}" + exit 2 + ;; +esac diff --git a/util-vserver-vars b/util-vserver-vars index 4d23588..167d975 100644 --- a/util-vserver-vars +++ b/util-vserver-vars @@ -8,6 +8,7 @@ test -e "$REAL_UTIL_VSERVER_VARS" || { # save defaults _REAL_LIB_VSERVER_FUNCTIONS="${_LIB_VSERVER_FUNCTIONS}" _REAL_VSERVER="${_VSERVER}" +_REAL_VSHELPER="${_VSHELPER}" case "$0" in /usr/sbin/vserver*) @@ -23,3 +24,5 @@ case "$0" in ;; esac +# overwrite _VSHELPER for init script +_VSHELPER="$__PKGLIBEXECDIR/vshelper.netns" diff --git a/vnamespace.netns b/vnamespace.netns index d2935f8..57e8881 100755 --- a/vnamespace.netns +++ b/vnamespace.netns @@ -35,7 +35,7 @@ do esac done -if [[ -n "$VSERVER_NAME" && -d "${VSERVER_DIR}/netns/" ]]; then +if [[ -n "$VSERVER_NAME" && -d "${VSERVER_DIR}/spline-netns/" ]]; then exec $_IP netns exec "$VSERVER_NAME" /usr/sbin/vnamespace "${ARGS[@]}" fi diff --git a/vserver.functions b/vserver.functions index 97e7b35..458d8fb 100644 --- a/vserver.functions +++ b/vserver.functions @@ -102,7 +102,8 @@ function _generateInterfaceOptions() { # add commands for default route local netns=0 - for net in "$VSERVER_DIR/netns/"*; do + shopt -s nullglob + for net in "$VSERVER_DIR/spline-netns/"*; do test -d "$net" || continue test ! -e "${net}/disabled" || continue diff --git a/vserver.netns b/vserver.netns index 6b7526a..ce7bb52 100755 --- a/vserver.netns +++ b/vserver.netns @@ -78,7 +78,7 @@ NETNS=() _setVserverDir "$VSERVER_NAME" -[ -d "${VSERVER_DIR}/netns/" ] && _USE_NETNS="1" +[ -d "${VSERVER_DIR}/spline-netns/" ] && _USE_NETNS="1" if [[ "$ACTION" == "start" && -n "${_USE_NETNS}" ]]; then pushd "$VSERVER_DIR" >/dev/null @@ -89,7 +89,8 @@ if [[ "$ACTION" == "start" && -n "${_USE_NETNS}" ]]; then $_IP netns list | grep -q "^${VSERVER_NAME}\$" || $_IP netns add "$VSERVER_NAME" $_IP netns exec "$VSERVER_NAME" $_IP link set dev lo up - for net in "$VSERVER_DIR/netns/"*; do + shopt -s nullglob + for net in "$VSERVER_DIR/spline-netns/"*; do test -d "$net" || continue test ! -e "${net}/disabled" || continue @@ -136,7 +137,8 @@ fi ret=$? if [ -n "${_USE_NETNS}" ]; then - for net in "${VSERVER_DIR}/netns/"*; do + shopt -s nullglob + for net in "${VSERVER_DIR}/spline-netns/"*; do test -d "$net" || continue test ! -e "${net}/disabled" || continue diff --git a/vshelper.netns b/vshelper.netns new file mode 100755 index 0000000..9e59636 --- /dev/null +++ b/vshelper.netns @@ -0,0 +1,10 @@ +#! /usr/lib/x86_64-linux-gnu/util-vserver/sigexec /bin/bash + +: ${UTIL_VSERVER_VARS:=/usr/share/util-vserver/netns/util-vserver-vars} +test -e "$UTIL_VSERVER_VARS" || { + echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 + exit 1 +} + +export UTIL_VSERVER_VARS +exec $_REAL_VSHELPER "$@" |