/usr/lib/util-vserver/vserver-setup.functions is in util-vserver 0.30.216-pre3120-1.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | # $Id$ --*- sh -*--
# Copyright (C) 2003,2004,2005,2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
SETUP_HOSTNAME=
SETUP_NETDEV=
SETUP_NETMASK=
SETUP_NETPREFIX=
SETUP_NETBCAST=
SETUP_LOCKFILE=
SETUP_CONFDIR=
SETUP_CONTEXT=
SETUP_INITSTYLE=
SETUP_CPUSET=
SETUP_CPUSETCPUS=
SETUP_CPUSETMEMS=
SETUP_CPUSETVIRT=
declare -a SETUP_INTERFACES=()
declare -a SETUP_FLAGS=()
declare -r SETUP_OPTIONS="confdir:,lockfile:,hostname:,netdev:,netmask:,netprefix:,netbcast:,interface:,flags:,context:,initstyle:,cpuset:,cpusetcpus:,cpusetmems:,cpusetvirt"
declare -r SETUP_HELPMSG=$"
--context ... the static context of the vserver [default: none; one will
be generated for you]
--confdir ... [default: $__CONFDIR/<name>]
--lockfile <filename>
... [default: $__RUNDIR/<name>]
--hostname <hostname>
--netdev <device>
--netbcast <broadcast>
--netmask <netmask>|--netprefix <prefixlen>
... sets the default netmask (a.b.c.d quadruple) or prefixlen
(length of the interface)
--interface [<name-suffix>=][<device>:]<ip>[/<mask|prefixlen>]
... declares an network-interface; this option can be specified
multiple times
--flags <flags>+
... sets comma-separated list of flags; possible flags are
lock: Prevent the vserver from setting new security context
sched: Merge scheduler priority of all processes in the
vserver so that it acts a like a single
one (kernel 2.4 only).
nproc: Limit the number of processes in the vserver
according to ulimit (instead of a per user limit,
this becomes a per vserver limit)
private: No other process can join this security context.
Even root
--cpuset <name>
... declares the CPUSET this vserver will run in [default: none]
--cpusetcpus <number[-number][:<exclusive>]>
... sets which cpus belong to the CPUSET,
exclusive is a flag (0|1) prohibiting any other cpuset from
using those cpus
--cpusetmems <number[-number][:<exclusive>]>
... sets which memory pools belong to the CPUSET,
exclusive is a flag (0|1) prohibiting any other cpuset from
using those memory pools
--cpusetvirt
... virtualize cpuset (guest will see only CPUs defined in cpuset)
Requires kernel patch from http://www.bullopensource.org/cpuset/
--initstyle <style>
... configures the initstyle (e.g. minit,sysv,plain)
"
function setup_setOption2
{
case "$1" in
(--context) SETUP_CONTEXT=$2;;
(--confdir) SETUP_CONFDIR=$2;;
(--lockfile) SETUP_LOCKFILE=$2;;
(--hostname) SETUP_HOSTNAME=$2;;
(--netdev) SETUP_NETDEV=$2;;
(--netmask) SETUP_NETMASK=$2;;
(--netprefix) SETUP_NETPREFIX=$2;;
(--netbcast) SETUP_NETBCAST=$2;;
(--interface) SETUP_INTERFACES=( "${SETUP_INTERFACES[@]}" "$2" );;
(--initstyle) SETUP_INITSTYLE=$2;;
(--cpuset) SETUP_CPUSET=$2;;
(--cpusetcpus) old_IFS=$IFS
IFS=:
set -- $2
SETUP_CPUSETCPUS=$1
SETUP_CPUSETCPUSEXCL=$2
IFS=$old_IFS
;;
(--cpusetmems) old_IFS=$IFS
IFS=:
set -- $2
SETUP_CPUSETMEMS=$1
SETUP_CPUSETMEMSEXCL=$2
IFS=$old_IFS
;;
(--cpusetvirt) SETUP_CPUSETVIRT=1;;
(--flags) old_IFS=$IFS
IFS=,
set -- $2
SETUP_FLAGS=( "${SETUP_FLAGS[@]}" "$@" )
IFS=$old_IFS
;;
(*) return 1;;
esac
return 0
}
function _setup_writeSingleOption
{
test -z "$1" || echo "$1" >"$2"
}
function _setup_writeInterface
{
local vdir=$1
local idx=$2
local tmp=$3
local name=${tmp%%=*}
test "$name" != "$tmp" || name=
tmp=${tmp##${name}=}
local dev=${tmp%%:*}
local nodev=
test "$dev" != "$tmp" || dev=
tmp=${tmp##${dev}:}
test "$dev" != "nodev" || {
dev=
nodev=1
}
local mask=${tmp##*/}
test "$mask" != "$tmp" || mask=
local ip=${tmp%%/${mask}}
local prefix=
test "${mask%%.*}" != "$mask" || {
prefix=$mask
mask=
}
d=$vdir/interfaces/$idx
mkdir "$d"
_setup_writeSingleOption "$name" $d/name
_setup_writeSingleOption "$dev" $d/dev
_setup_writeSingleOption "$ip" $d/ip
_setup_writeSingleOption "$mask" $d/mask
_setup_writeSingleOption "$prefix" $d/prefix
test -n "$dev" -o -n "$SETUP_NETDEV" || {
test -n "$nodev" || \
echo $"No device specified for interface '$idx'; setting 'nodev'" >&2
$_TOUCH $d/nodev
}
}
function setup_setDefaults
{
: ${SETUP_CONFDIR:=$__CONFDIR/$1}
: ${SETUP_LOCKFILE:=$__RUNDIR/$1}
findFile SETUP_FSTAB "$__CONFDIR"/.defaults/fstab "$__PKGLIBDEFAULTDIR"/fstab
}
function _setup_generateContext
{
if test -z "$SETUP_CONTEXT" && test ! -e "$__CONFDIR/.defaults/context.dynamic"; then
if test -e "$__CONFDIR/.defaults/context.next"; then
SETUP_CONTEXT=`$_CAT "$__CONFDIR/.defaults/context.next"`
else
SETUP_CONTEXT=`$_CAT "$__PKGLIBDEFAULTDIR/context.start"`
fi
expr "$SETUP_CONTEXT" + 1 > "$__CONFDIR/.defaults/context.next"
fi
}
function setup_writeOption
{
local name=$1
local cfgdir=${SETUP_CONFDIR:?}
local i
mkdir -p "$cfgdir"/interfaces "$cfgdir"/apps/init "$cfgdir"/uts "$cfgdir"/cpuset
_setup_generateContext
_setup_writeSingleOption "$name" "$cfgdir"/name
_setup_writeSingleOption "$SETUP_CONTEXT" "$cfgdir"/context
_setup_writeSingleOption "$SETUP_HOSTNAME" "$cfgdir"/uts/nodename
_setup_writeSingleOption "$SETUP_NETDEV" "$cfgdir"/interfaces/dev
_setup_writeSingleOption "$SETUP_NETMASK" "$cfgdir"/interfaces/mask
_setup_writeSingleOption "$SETUP_NETPREFIX" "$cfgdir"/interfaces/prefix
_setup_writeSingleOption "$SETUP_NETBCAST" "$cfgdir"/interfaces/bcast
_setup_writeSingleOption "$SETUP_INITSTYLE" "$cfgdir"/apps/init/style
_setup_writeSingleOption "$SETUP_CPUSET" "$cfgdir"/cpuset/name
_setup_writeSingleOption "$SETUP_CPUSETCPUS" "$cfgdir"/cpuset/cpus
_setup_writeSingleOption "$SETUP_CPUSETCPUSEXCL" "$cfgdir"/cpuset/cpus_exclusive
_setup_writeSingleOption "$SETUP_CPUSETMEMS" "$cfgdir"/cpuset/mems
_setup_writeSingleOption "$SETUP_CPUSETMEMSEXCL" "$cfgdir"/cpuset/mem_exclusive
_setup_writeSingleOption "$SETUP_CPUSETVIRT" "$cfgdir"/cpuset/virtualized
local idx=0
for i in "${SETUP_INTERFACES[@]}"; do
_setup_writeInterface "$cfgdir" $idx "$i"
let ++idx
done
test -z "$SETUP_FLAGS" || for i in "${SETUP_FLAGS[@]}"; do
echo "$i"
done >"$cfgdir"/cflags
ln -s "$SETUP_LOCKFILE" "$cfgdir"/run
}
function setup_writeInitialFstab
{
cat "${SETUP_FSTAB:?}" >"${SETUP_CONFDIR:?}"/fstab
}
function setup_test
{
SETUP_INTERFACES=()
setup_setOption2 --interface foo0=eth0:1.2.3.4/1
setup_setOption2 --interface foo1=eth0:1.2.3.4/255.255.248.0
setup_setOption2 --interface foo2=eth0:1.2.3.4
setup_setOption2 --interface foo3=1.2.3.4
setup_setOption2 --interface foo4=1.2.3.4/1
setup_setOption2 --interface eth0:1.2.3.4
setup_setOption2 --interface eth0:1.2.3.4/1
setup_setOption2 --interface 1.2.3.4
setup_setOption2 --interface 1.2.3.4/1
setup_writeOption xx
}
|