3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # $VSERVER_DIR ... path to vserver-cfg dir
20 # $VSERVER_NAME ... name of vserver
22 declare -a NICE_CMD=()
23 declare -a CHBIND_OPTS=()
24 declare -a CAP_OPTS=()
25 declare -a CHCONTEXT_INIT_OPTS=()
26 declare -a CHCONTEXT_FLAG_OPTS=()
27 declare -a CHCONTEXT_OPTS=()
28 declare -a CAPCHROOT_OPTS=()
29 declare -a INTERFACES=()
31 declare -a INITCMD_RESCUE=( /bin/sleep 900 )
32 declare -a INITCMD_START=()
33 declare -a INITCMD_START_SYNC=()
34 declare -a INITCMD_STOP=()
35 declare -a INITCMD_STOP_SYNC=()
36 declare -a INITCMD_PREPARE=()
37 declare -a INITKILL_SEQ=()
38 declare -a ENTER_SHELL=()
40 declare -a OPTS_VCONTEXT_CREATE=()
41 declare -a OPTS_VCONTEXT_MIGRATE=()
42 declare -a OPTS_VCONTEXT_ENTER=()
43 declare -a OPTS_VATTRIBUTE=( --flag fakeinit )
44 declare -a OPTS_VSCHED=()
46 declare -a STOPCMD_PREPARE=()
48 declare -a VSERVER_EXTRA_CMDS=()
51 VSHELPER_SYNC_TIMEOUT=30
56 _HAVE_INTERFACE_OPTIONS=
67 : ${VSERVER_NAME:=$(basename "$VSERVER_DIR")}
69 if test -e "$VSERVER_DIR"/noisy -o -n "$OPTION_VERBOSE"; then
75 function _generateChbindOptions
82 test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
84 local f=$vdir/interfaces/bcast
85 getFileValue bcast "$f"
87 getFileValue nid "$vdir/ncontext" "$vdir/context"
89 CHBIND_OPTS=( $SILENT_OPT ${nid:+--nid "$nid"} ${bcast:+--bcast "$bcast"} )
91 for i in "${INTERFACES[@]}"; do
92 CHBIND_OPTS=( "${CHBIND_OPTS[@]}" --ip "$i" )
95 _HAVE_CHBIND_OPTIONS=1
98 function _generateNiceCommand
103 test -r "$vdir/nice" || return 0;
104 read nice <"$vdir"/nice
106 NICE_CMD=( $_NICE -$nice )
110 function _generatePersonalityOptions
113 local f="$vdir"/personality
116 test -s "$f" || return 0
125 (*) flags=$flags$delim$tmp
132 OPTS_VCONTEXT_ENTER=( "${OPTS_VCONTEXT_ENTER[@]}"
133 --personality-type "$type"
134 ${flags:+--personality-flags "$flags"} )
137 function _generateCCapabilityOptions
141 local f="$vdir"/ccapabilities
143 test -e "$f" || return 0
147 (*) OPTS_VATTRIBUTE=( "${OPTS_VATTRIBUTE[@]}" --ccap "$cap" );;
152 function _generateBCapabilityOptions
156 local f="$vdir"/bcapabilities
158 test -e "$f" || return 0
162 (*) OPTS_VATTRIBUTE=( "${OPTS_VATTRIBUTE[@]}" --bcap "$cap" );;
167 function _generateCapabilityOptions
172 _generateBCapabilityOptions "$vdir"
173 _generateCCapabilityOptions "$vdir"
175 test -e "$vdir"/capabilities || return 0
184 CAP_OPTS=( "${CAP_OPTS[@]}" --cap "$cap" )
185 CAPCHROOT_OPTS=( "${CAPCHROOT_OPTS[@]}" --nochroot )
188 CAP_OPTS=( "${CAP_OPTS[@]}" --cap "$cap" )
191 done <"$vdir"/capabilities
194 function getEnterShell
201 getFileValue ENTER_SHELL "$vdir"/shell "$__CONFDIR"/.defaults/shell
203 test -n "$ENTER_SHELL" || {
205 for i in "/bin/bash -login" "/bin/sh -l" /bin/csh; do
207 test -x "$vdir/vdir/$1" || continue
214 ## Usage: sendKillSequence <ctx> <signal> [<wait> <signal>]*
215 function sendKillSequence
221 while isCtxRunning "$ctx"; do
222 test -z "$wait" || sleep "$wait"
224 killContext "$ctx" "$1"
225 test -n "$2" || break
231 function _generateInitOptions
234 local cfgdir=$vdir/apps/init
239 INITCMD_START_SYNC=()
244 INITKILL_SEQ=( 15 5 9 )
245 CHCONTEXT_INIT_OPTS=()
248 getFileValue INITSTYLE "$cfgdir"/style
249 getFileValue RUNLEVEL_START "$cfgdir"/runlevel
250 getFileValue RUNLEVEL_START "$cfgdir"/runlevel.start
251 getFileValue RUNLEVEL_STOP "$cfgdir"/runlevel.stop
252 getFileArray INITKILL_SEQ "$cfgdir"/killseq || :
254 case x"$INITSTYLE" in
256 INITCMD_START=( "${INITCMD_RESCUE[@]}" )
257 INITCMD_STOP=( /sbin/killall5 )
263 test -n "$RUNLEVEL_START" || RUNLEVEL_START=3
264 test -n "$RUNLEVEL_STOP" || RUNLEVEL_STOP=6
266 for i in /etc/init.d/rc /etc/rc.d/rc; do
267 test -x "$vdir/vdir/$i" || continue
268 INITCMD_START=( "$i" "$RUNLEVEL_START" )
269 INITCMD_STOP=( "$i" "$RUNLEVEL_STOP" )
271 INITCMD_PREPARE=( $_FAKE_RUNLEVEL "$RUNLEVEL_START" /var/run/utmp )
275 INITCMD_START=( /sbin/init )
276 INITCMD_STOP=( /sbin/init )
278 _NEED_VSHELPER_SYNC=1
279 test -z "$RUNLEVEL_START" || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
280 test -z "$RUNLEVEL_STOP" || INITCMD_STOP=( "${INITCMD_STOP[@]}" "$RUNLEVEL_STOP" )
284 INITCMD_START=( /sbin/minit-start )
285 INITCMD_STOP=( /sbin/minit-stop )
287 INITCMD_START_SYNC=( "$_INITSYNC_MINIT_START" "$vdir" )
288 _NEED_VSHELPER_SYNC=1
289 test -z "$RUNLEVEL_START" || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
290 test -z "$RUNLEVEL_STOP" || INITCMD_STOP=( "${INITCMD_STOP[@]}" "$RUNLEVEL_STOP" )
291 ! isNumber "${RUNLEVEL_START:-3}" || INITCMD_PREPARE=( $_FAKE_RUNLEVEL "${RUNLEVEL_START:-3}" /var/run/utmp )
295 INITCMD_START=( /sbin/rc default )
296 INITCMD_STOP=( /sbin/rc shutdown )
300 (*) panic "Unknown init-style '$INITSTYLE'; aborting";;
303 if test x"$INITSTYLE" != xrescue; then
304 getFileArray INITCMD_START "$cfgdir"/cmd.start || :
305 getFileArray INITCMD_STOP "$cfgdir"/cmd.stop || :
306 getFileArray INITCMD_START_SYNC "$cfgdir"/cmd.start-sync || :
307 getFileArray INITCMD_STOP_SYNC "$cfgdir"/cmd.stop-sync || :
308 getFileArray INITCMD_PREPARE "$cfgdir"/cmd.prepare || :
311 test -n "$OPTION_FORCE_SYNC" -o -e "$cfgdir"/sync || {
312 INITCMD_START_SYNC=()
317 if vshelper.isEnabled; then
318 vshelper.getSyncTimeout "$vdir" VSHELPER_SYNC_TIMEOUT || :
324 function _generateFlagOptions
328 CHCONTEXT_FLAG_OPTS=()
330 test ! -e "$vdir"/flags || \
339 OPTS_VATTRIBUTE=( "${OPTS_VATTRIBUTE[@]}" --flag "$flag" )
340 CHCONTEXT_FLAG_OPTS=( "${CHCONTEXT_FLAG_OPTS[@]}"
346 isAvoidNamespace "$vdir" || {
348 CHCONTEXT_FLAG_OPTS=( "${CHCONTEXT_FLAG_OPTS[@]}" --flag namespace )
352 function _generateChcontextOptions
355 local ctx hostname domainname
360 read ctx <"$vdir"/context || :
362 read hostname <"$vdir"/uts/nodename || read hostname <"$vdir"/hostname || :
363 read domainname <"$vdir"/uts/domainname || read domainname <"$vdir"/domainname || :
366 test -z "$S_CONTEXT" || ctx=$S_CONTEXT
368 _generateCapabilityOptions "$vdir"
369 _generateFlagOptions "$vdir"
371 CHCONTEXT_OPTS=( $SILENT_OPT \
372 "${CHCONTEXT_FLAG_OPTS[@]}" \
375 ${ctx:+--ctx "$ctx"} \
376 ${hostname:+--hostname "$hostname"} \
377 ${domainname:+--domainname "$domainname"} )
379 OPTS_VCONTEXT_CREATE=( $SILENT_OPT \
380 ${ctx:+--xid "$ctx"} )
381 ## put '--secure' at front so that it can be overridden
382 OPTS_VATTRIBUTE=( --secure --flag default "${OPTS_VATTRIBUTE[@]}" )
385 function _generateScheduleOptions
388 local f="$vdir"/schedule
389 test -e "$f" || return 0
391 local fill_rate interval tokens tokens_min tokens_max prio_bias
399 read prio_bias || prio_bias=
403 test -n "$prio_bias" || {
404 echo $"Bad content in '$f'; aborting..." >&2
408 OPTS_VSCHED=( --fill-rate "$fill_rate" --interval "$interval" \
409 --tokens "$tokens" --tokens_min "$tokens_min" \
410 --tokens_max "$tokens_max" --priority-bias "$prio_bias" )
413 function _getInterfaceValue
423 read _giv_tmp <"$_giv_i/$_giv_val" && break || :
426 : ${_giv_tmp:=$_giv_dflt}
427 eval $_giv_val=\$_giv_tmp
430 ## Usage: _transformMask2Prefix <result-varname> <prefix> <mask>
431 function _transformMask2Prefix
435 test -n "$_tm2p_tmp" || {
436 $_MASK2PREFIX "$3" || _tm2p_tmp=$?
443 function _addInterfaceCmd
445 eval INTERFACE_CMDS_${INTERFACE_CMDS_IDX}='( "$@" )'
446 let ++INTERFACE_CMDS_IDX
449 ## Usage: _generateMac <var> <iface> <ctx>
450 function _generateMac
453 echo $"Interface basename '$iface' must be either a number, or the mac must be configured explicitly" >&2
457 eval $1=$(printf "f0:ff:%02x:%02x:%02x:%02x" $[ (~($2>>8)) & 0xff ] $[ ($2 & 0xff) ] $[ ($3>>8) & 0xff ] $[ $3 & 0xff ])
460 function _getVLANInfo
465 creation of VLAN_PLUS_VID devices is not supported; please create them
466 before starting the vserver and use the 'nodev' flag then"
467 echo "$1 vlan ${1##vlan} VLAN_PLUS_VID"
471 creation of VLAN_PLUS_VID_NO_PAD devices is not supported; please
472 create them before starting the vserver and use the 'nodev' flag then"
473 echo "$1 vlan ${1##vlan} VLAN_PLUS_VID_N0_PAD"
475 (*.????) echo "$1 ${1%%.*} ${1##*.} DEV_PLUS_VID";;
476 (*.*) echo "$1 ${1%%.*} ${1##*.} DEV_PLUS_VID_NO_PAD";;
483 ## Usage: _processSingleInterface <interface-directory>
484 function _processSingleInterface
499 _getInterfaceValue ip '' "$iface"
500 _getInterfaceValue extip '' "$iface" "$iface/.."
501 _getInterfaceValue dev '' "$iface" "$iface/.."
502 _getInterfaceValue prefix '' "$iface" "$iface/.."
503 _getInterfaceValue mask '' "$iface" "$iface/.."
504 _getInterfaceValue bcast '' "$iface" "$iface/.."
505 _getInterfaceValue name '' "$iface"
506 _getInterfaceValue scope '' "$iface" "$iface/.."
507 _getInterfaceValue mac '' "$iface"
509 test -n "$ip" || { echo $"Can not read ip for '$iface'" >&2; return 1; }
510 test -n "$dev" -o -e "$iface"/nodev || {
511 echo $"No device specified for '$iface'" >&2
515 test ! -e "$iface"/down || up=
518 _transformMask2Prefix prefix "$prefix" "$mask"
519 INTERFACES=( "${INTERFACES[@]}" "$ip${prefix:+/$prefix}" )
521 test ! -e "$iface"/nodev || break
523 test ! -e "$iface"/only_ip || break
526 if vlan_info=$(_getVLANInfo "$dev"); then
527 test -d /proc/net/vlan || {
528 echo -e $"VLAN device-name used, but vlan subsystem not enabled.\nTry to execute 'modprobe 8021q' before starting the vservers" >&2
531 test -f /proc/net/vlan -o -e "$iface"/novlandev || {
532 _addInterfaceCmd VCONFIG $vlan_info
536 if ! test -e "$iface"/indirect; then
537 _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" broadcast ${bcast:-+} ${name:+label "$dev:$name"} dev "$dev"
538 #_addInterfaceCmd IP_ROUTE "$ip${prefix:+/$prefix}" dev "$dev"
539 _addInterfaceCmd IP_LINK "$dev" $up
540 elif ! test -n "$ctx"; then
541 echo $"Using 'dummy' (indirect) for interface '$dev' requires a fixed context number; dynamic ctx are not supported" >&2
544 test -z "$mac" || _generateMac mac "$(basename $iface)" "$ctx" || return 1
545 _addInterfaceCmd MODPROBE dummy "$dev"
546 _addInterfaceCmd IP_LINK dev dummy0 address "$mac"
547 _addInterfaceCmd NAMEIF "$dev" "$mac"
548 _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" dev "$dev"
549 test -z "$extip" || _addInterfaceCmd IPTABLES "$ip${prefix:+/$prefix}" ${name:+label "$dev:$name"} "$ctx" "$extip"
556 ## Usage: _generateInterfaceOptions <vserver-directory>
557 function _generateInterfaceOptions
562 test ! -e "$1"/context || read ctx <"$1"/context
564 for iface in "$1/interfaces/"*; do
565 test -d "$iface" || continue
566 test ! -e "$iface"/disabled || continue
568 _processSingleInterface "$iface"
570 _HAVE_INTERFACE_OPTIONS=1
573 function enableInterfaces
578 lock "$__LOCKDIR"/vserver.interfaces
580 while test $i -lt $INTERFACE_CMDS_IDX; do
581 eval var='( "${INTERFACE_CMDS_'$i'[@]}" )'
592 $_MODPROBE ${name:+-o "$name"} "$mod" "$@"
594 NAMEIF) $_NAMEIF "$@";;
595 VCONFIG) $_VCONFIG set_name_type "$4" >/dev/null
596 $_VCONFIG add "$2" "$3" >/dev/null;;
597 IP_ADDR) $_IP addr add "$@";;
598 IP_ADDR_FLUSH) $_IP addr flush "$@";;
599 IP_LINK) $_IP link set "$@";;
600 IP_ROUTE) $_IP route add "$@";;
601 *) echo "Unknown interface-command type '$type'" >&2; false;;
610 function disableInterfaces
612 test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$1"
614 local i=$INTERFACE_CMDS_IDX
617 lock "$__LOCKDIR"/vserver.interfaces
619 while test $i -gt 0; do
622 eval var='( "${INTERFACE_CMDS_'$i'[@]}" )'
629 MODPROBE) $_RMMOD "${2:-$1}";;
631 VCONFIG) $_VCONFIG rem "$2.$3" >/dev/null;;
632 IP_ADDR) $_IP addr del "$@";;
634 IP_LINK) ;; ## Ignore the link-down command for now
635 IP_ROUTE) $_IP route del "$@";;
636 *) echo "Unknown interface-command type '$type'" >&2; false;;
643 ## Usage: prepareInit <vserver-directory>
646 pushd "$1/vdir" >/dev/null
649 { find var/run ! -type d -print0; \
650 find var/lock ! -type d -print0; } | xargs -0r $_CHROOT_SH rm
653 $_CHROOT_SH rm .autofsck forcefsck 2>/dev/null || :
654 : | $_CHROOT_SH truncate fastboot 2>/dev/null || :
659 "${INITCMD_PREPARE[@]}"
663 ## Usage: prepareInit <vserver-directory>
666 pushd "$1/vdir" >/dev/null
669 export PREVLEVEL=$RUNLEVEL_START # required by Debian's initscripts
672 "${STOPCMD_PREPARE[@]}"
677 function generateOptions
679 _generateInterfaceOptions "$1"
680 test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
681 _generateNiceCommand "$1"
682 _generateInitOptions "$1"
683 _generateChcontextOptions "$1"
684 _generateScheduleOptions "$1"
685 _generatePersonalityOptions "$1"
687 if test -n "$_IS_FAKEINIT"; then
688 CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit )
689 OPTS_VCONTEXT_MIGRATE=( "${OPTS_VCONTEXT_MIGRATE[@]}" --initpid --disconnect )
693 function _mountVserverInternal
698 test -e "$fstab" || return 0
701 pushd "$vdir" >/dev/null
702 # check whether / is mounted readonly or whether there is special
703 # magic regarding the mtab file; when etc/mtab can not be touched,
704 # add the '-n' flag to mount
705 test -w etc -o -w etc/mtab || xflag=-n
706 "$@" $_SECURE_MOUNT -a $xflag --chroot --fstab "$fstab" --rootfs no
714 local fstab="$cfgdir"/fstab
717 test -e "$fstab" || return 0
718 pushd "$vdir" >/dev/null
719 # check whether / is mounted readonly or whether there is special
720 # magic regarding the mtab file; when etc/mtab can not be touched,
721 # add the '-n' flag to mount
722 test -w etc -o -w etc/mtab || xflag=-n
723 $_SECURE_MOUNT -a $xflag --chroot --fstab "$fstab" --rootfs only -n
727 function mountVserver
734 test -e "$cfgdir"/fstab -o \
735 -e "$cfgdir"/fstab.local -o \
736 -e "$cfgdir"/fstab.remote || return 0
738 findObject -r mtab_src "$cfgdir"/apps/init/mtab "$__CONFDIR"/.defaults/init/mtab "$__PKGLIBDEFAULTDIR"/mtab /dev/null
740 pushd "$vdir" >/dev/null
741 $_CHROOT_SH truncate /etc/mtab <"$mtab_src"
744 test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
746 test -z "$NAMESPACE_CLEANUP" || isAvoidNamespace "$cfgdir" || \
747 $_VNAMESPACE --cleanup
749 _mountVserverInternal "$cfgdir"/fstab
750 _mountVserverInternal "$cfgdir"/fstab.local
751 _mountVserverInternal "$cfgdir"/fstab.remote $_CHBIND "${CHBIND_OPTS[@]}"
753 isAvoidNamespace "$cfgdir" || \
754 $_SECURE_MOUNT --rbind -n "$vdir" "/"
757 function _umountVserverInternal
760 test -e "$fstab" || return 0
765 while read src dst tmp; do
766 test -n "$tmp" || continue
772 "$@" $_EXEC_CD "$dst" $_UMOUNT -lfn . || is_ok=
778 function umountVserver
784 isAvoidNamespace "$cfgdir" || return 0
785 test -e "$cfgdir"/fstab -o \
786 -e "$cfgdir"/fstab.local || return 0
787 test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
789 pushd "$vdir/" >/dev/null || return 1
790 _umountVserverInternal "$cfgdir"/fstab.local || is_ok=
791 _umountVserverInternal "$cfgdir"/fstab $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
792 popd >/dev/null || return 1
797 ## Usage: waitForSync <vserver> <context> <vshelper-fifo-varname>
801 test -n "$_NEED_VSHELPER_SYNC" && \
802 ! $_VSERVER_INFO - FEATURE vwait || _is_meth=async
804 vshelper.initSync "$1" "$3" "$_is_meth"
807 ## Usage: initWait <vserver> <context> <vwait-tmpdir-varname>
810 if $_VSERVER_INFO - FEATURE vwait; then
812 _is_tmpdir=$($_MKTEMPDIR /tmp/vwaitstat.XXXXXX)
815 $_VWAIT --timeout "$VSHELPER_SYNC_TIMEOUT" \
817 >>$_is_tmpdir/out 2>$_is_tmpdir/err 3>$_is_tmpdir/fifo
820 if test "$rc" -ne 0 -a "$rc" -ne 1; then
821 $_VPS axf | $_EGREP -e "^[^ \t]+[ \t]+$S_CONTEXT[ \t]+" >&4
822 killContext "$S_CONTEXT" 9
826 ) 4>$_is_tmpdir/procs &
828 echo "$!" >$_is_tmpdir/pid
829 eval "$3"=$_is_tmpdir
834 ## Usage: _waitForVWait <vserver> <fifo> <pid> <procs>
835 function _waitForVWait
840 declare -r procs=$(cat $4)
842 getFileArray status "$2"
847 'vwait' exited with error '$2' which indicates that vserver could not
852 A timeout occured while waiting for the vserver to finish and it was
853 killed by sending a SIGKILL signal. Please investigate the reasons
854 and/or increase the timeout in apps/vshelper/sync-timeout."
857 (TIMEOUT) warning $"\
858 A timeout occured while waiting for the vserver to finish and it will
859 be killed by sending a SIGKILL signal. The following process list
860 might be useful for finding out the reason of this behavior:
862 ----------------------------------------------------------------------
864 }----------------------------------------------------------------------"
867 (\?\?\?|*) warning $"\
868 internal error: 'vwait' exited with an unexpected status '$1'; I will
869 try to continue but be prepared for unexpected events."
876 ## Usage: waitForSync <vserver> [<vshelper-fifo>] [<vwait-statdir>]
881 local vwait_statdir=$3
884 if test -d "$vwait_statdir"; then
885 _waitForVWait "$cfgdir" "$vwait_statdir/fifo" "$( <$vwait_statdir/pid )" "$vwait_statdir/procs"
886 elif test -n "$_NEED_VSHELPER_SYNC"; then
887 $_VSHELPER_SYNC "$fifo" "$VSHELPER_SYNC_TIMEOUT" || \
889 A timeout or other error occured while waiting for the synchronization
890 signal from vserver '$VSERVER_NAME'.
891 The vserver will be killed nevertheless..."
892 elif test "${#INITCMD_STOP_SYNC[@]}" -ne 0; then
893 "${INITCMD_STOP_SYNC[@]}" || \
895 Stop-synchronization for vserver '$VSERVER_NAME' failed. The vserver
896 will be killed nevertheless..."
899 test -z "$OPTION_FORCE_SYNC" -a ! -e "$cfgdir"/sync ||
905 local vdir name flavor start i already_handled base
909 ## Usage: execScriptlets <vserver-cfgdir> <vserver-name> <script-flavor>
910 function execScriptlets
917 for base in "$vdir"/scripts "$__CONFDIR"/.defaults/scripts; do
918 local DONT_SKIP_DEFAULTS=
919 local already_handled=
921 for i in "$base/$flavor" "$base/$flavor.d"/*; do
922 isRegularFile "$i" || continue
923 test -r "$i" || continue
927 test -x "$i" || start=_sourceWrap
928 $start "$i" "$flavor" "$name"
931 test -z "$already_handled" -o -n "$DONT_SKIP_DEFAULTS" || break
940 ! test -e "$cfgdir"/fstab.local ||
942 WARNING: 'fstab' will *not* be executed in the network context of the
943 vserver anymore. Therefore, 'fstab.local' has the same functionality
944 and is obsoleted. When you need the old behaviour, put the mounts
947 ! test -e "$cfgdir"/hostname -a ! -L "$cfgdir"/hostname ||
949 WARNING: The hostname is now configured in 'uts/nodename' but not in
952 ! test -e "$cfgdir"/domainname -a ! -L "$cfgdir"/domainname ||
954 WARNING: The domainname is now configured in 'uts/domainname' but not
955 in 'domainname'." >&2
959 for i in "$cfgdir"/interfaces/*/only_ip; do
960 if test -e "$i"; then
962 iface=${i##$cfgdir/interfaces/}
963 iface=${iface%%/only_ip}
965 WARNING: The 'only_ip' flag for interface '$iface' is deprecated; use
970 find "$cfgdir" -type f -exec "$_CHECK_UNIXFILE" '{}' ';'
972 vshelper.doSanityCheck
974 $_VSERVER_INFO - VERIFYCAP ||
975 panic $"capabilities are not enabled in kernel-setup"
977 $_VSERVER_INFO - VERIFYPROC ||
979 /proc/uptime can not be accessed. Usually, this is caused by
980 procfs-security. Please read the FAQ for more details
981 http://www.linux-vserver.org/index.php?page=Linux-Vserver+FAQ"
985 function _setSingleDiskLimit
997 getFileValue ctx "$vdir/context"
998 getFileValue directory "$dlimit/directory" || return 0
999 getFileValue space_total "$dlimit/space_total" || return 0
1000 getFileValue inodes_total "$dlimit/inodes_total" || return 0
1001 getFileValue reserved "$dlimit/reserved" || return 0
1003 local cachename=`echo "$ctx$directory" | $_SED 's!/!_!g'`
1005 test -e "$vdir/cache/$cachename" && . "$vdir/cache/$cachename"
1006 # Remove the cache so if the machine goes down unexpectedly, we won't have a stale cache
1007 $_RM -f "$vdir/cache/$cachename"
1009 if test -z "$inodes_used" -o -z "$space_used"; then
1010 space_used=` $_VDU --xid $ctx --space --script "$directory"`
1011 inodes_used=`$_VDU --xid $ctx --inodes --script "$directory"`
1014 $_VDLIMIT --xid $ctx \
1015 --set space_used=$space_used \
1016 --set space_total=$space_total \
1017 --set inodes_used=$inodes_used \
1018 --set inodes_total=$inodes_total \
1019 --set reserved=$reserved \
1024 function setDiskLimits
1029 # Disk Limits without a static context are useless
1030 test -e "$vdir"/context || return 0
1032 for dlimit in "$vdir/dlimits/"*; do
1033 test -d "$dlimit" || continue
1034 test ! -e "$dlimit/disabled" || continue
1036 _setSingleDiskLimit "$vdir" "$dlimit"
1041 function _saveSingleDiskLimit
1048 getFileValue ctx "$vdir/context"
1049 getFileValue directory "$dlimit/directory" || return 0
1051 local cachename=`echo "$ctx$directory" | $_SED 's!/!_!g'`
1053 $_VDLIMIT --xid $ctx "$directory" | \
1054 $_GREP '_used=' > "$vdir/cache/$cachename"
1058 function saveDiskLimits
1063 test -e "$vdir"/context || return 0
1065 for dlimit in "$vdir/dlimits/"*; do
1066 test -d "$dlimit" || continue
1067 test ! -e "$dlimit/disabled" || continue
1069 _saveSingleDiskLimit "$vdir" "$dlimit"