Package: vserver-debiantools Version: 0.3.6.2 Severity: wishlist File: /usr/sbin/newvserver Tags: patch
Hi, if you are creating many VServers using the newvserver script, it is a bit cumbersome to always give the correct combination of --hostname and --ip. An alternative strategy would be to set up a name server which knows about the IP<->hostname assignments and to derive either the hostname or the IP address by querying the name server. This is implemented by the appended patch. Using the patch you can just use newvserver --ip 1.2.3.4/24 and the script looks up hostname and domain (if not given) using the name server. Alternatively you can use newvserver --hostname x --domain y.z and the script looks up the IP address using the name server. In this case the prefix length (/24 in the above example) is taken from the netmask of the given network interface. I hope this helps, Jochen -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.22-2-vserver-amd64 (SMP w/1 CPU core) Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Shell: /bin/sh linked to /bin/bash Versions of packages vserver-debiantools depends on: ii binutils 2.18-1 The GNU assembler, linker and bina ii debootstrap 1.0.3 Bootstrap a basic Debian system ii dnsutils 1:9.4.1-P1-1 Clients provided with BIND ii iproute 20070313-1 Professional tools to control the ii rsync 2.6.9-5 fast remote file copy program (lik ii util-vserver 0.30.214-3 user-space tools for Linux-VServer vserver-debiantools recommends no packages. -- no debconf information -- http://seehuhn.de/
diff -ur vserver-debiantools-0.3.6.1/debian/control vserver-debiantools-0.3.6.2/debian/control --- vserver-debiantools-0.3.6.1/debian/control 2007-08-20 07:37:48.000000000 +0100 +++ vserver-debiantools-0.3.6.2/debian/control 2007-10-01 16:17:00.000000000 +0100 @@ -8,7 +8,7 @@ Package: vserver-debiantools Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, util-vserver (>= 0.30.204-5sarge2), debootstrap (>= 0.3.3), binutils, rsync, iproute +Depends: ${shlibs:Depends}, ${misc:Depends}, util-vserver (>= 0.30.204-5sarge2), debootstrap (>= 0.3.3), binutils, rsync, iproute, dnsutils Conflicts: vserver Description: Tools to manage debian virtual servers This package contain tools to manage debian based virtual servers. diff -ur vserver-debiantools-0.3.6.1/newvserver.sh vserver-debiantools-0.3.6.2/newvserver.sh --- vserver-debiantools-0.3.6.1/newvserver.sh 2007-10-01 14:22:34.000000000 +0100 +++ vserver-debiantools-0.3.6.2/newvserver.sh 2007-10-01 17:06:22.000000000 +0100 @@ -122,12 +122,17 @@ --pkgcache Package caching. -v, --verbose show extra output during setup --vsroot location of "/vserver/" directory + Required: --hostname hostname for new vserver (eg. "alpha") --domain dns domain for new vserver (eg. "example.com") --ip IPv4 address for new vserver (syntax: --ip <ip>[/<netmask|prefixlength>]) + Either --ip or --domain/--hostname may be omitted if the + corresponding information is can be found by a name server + query. + You can also set variables in /etc/vservers/newvserver-vars. EOF @@ -348,6 +353,24 @@ parse_args $@ +if [ -n "$IP" -a \( -z "$VHOST" -o -z "$VDOMAIN" \) ]; then + tmp=$(dig +short -x $(echo $IP | sed 's;/[0-9]*$;;')) + if [ -n "$tmp" ]; then + if [ -z "$VHOST" ]; then + VHOST=$(echo $tmp | sed 's/\..*//') + fi + if [ -z "$VDOMAIN" ]; then + VDOMAIN=$(echo $tmp | sed 's/[^.]*\.//') + fi + fi +fi + +if [ -n "$VHOST" -a -n "$VDOMAIN" -a -n "$INTERFACE" -a -z "$IP" ]; then + prefix=$(ip -o addr show dev "$INTERFACE" primary scope global | \ + sed -n 's;.*inet [0-9.]*/\([0-9]*\).*;\1;p') + IP="$(dig +short "$VHOST.$VDOMAIN")/$prefix" +fi + if ! [ -n "$VHOST" -a -n "$VDOMAIN" -a -n "$IP" ]; then echo "${0##*/} error: --hostname, --domain and --ip are required" 1>&2 usage
signature.asc
Description: Digital signature