Hi, the attached patch to the new newvserver script allows a prefix or netmask to be added to the "--ip" argument in the form of <ip>[/<mask|prefixlen>]. The prefix or netmask are not used but stored in variables anyway.
regards Daniel -- ----------------------------------------------------------------- Daniel Hermann, Institut fuer Theorie der Kondensierten Materie Universitaet Karlsruhe Tel: ++49 (0)721 608-3588 Postfach 6980 Fax: ++49 (0)721 608-7779 76128 Karlsruhe, Germany email: [EMAIL PROTECTED] -----------------------------------------------------------------
--- newvserver.20050418 2005-04-19 16:47:51.000000000 +0200 +++ newvserver 2005-04-19 16:59:20.000000000 +0200 @@ -92,7 +92,7 @@ full_usage () { cat << EOF -Usage: ${0##*/} [OPTIONS] --hostname x --domain y.z --ip 1.2.3.4 +Usage: ${0##*/} [OPTIONS] --hostname x --domain y.z --ip 1.2.3.4/24 Creates a new Debian vserver by calling "vserver ... build" Options: @@ -112,6 +112,7 @@ --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>]) You can also set variables in /etc/vservers/newvserver-vars. @@ -244,6 +245,18 @@ case "$2" in [0-9]*.[0-9]*.[0-9]*.[0-9]*) IP="$2" + # get netmask + IP_NETMASK=${IP##*/} + test "$IP_NETMASK" != "$1" || IP_NETMASK= + IP_ADDR=${IP%%/${IP_NETMASK}} + # if IP_NETMASK contains no ".", it is + # interpreted as IP_PREFIX + IP_PREFIX= + test "${IP_NETMASK%%.*}" != "${IP_NETMASK}" \ + || { + IP_PREFIX=$IP_NETMASK + IP_NETMASK= + } ;; *) echo "${0##*/} error: $1 requires a single IPv4 e.g. \"192.168.100.1\"" 1>&2 @@ -385,7 +398,7 @@ # /etc/hosts 127.0.0.1 localhost -$IP $VHOST.$VDOMAIN $VHOST +$IP_ADDR $VHOST.$VDOMAIN $VHOST # The following lines are desirable for IPv6 capable hosts # (added automatically by netbase upgrade)