2 #----------------------------------------------------
3 #shell used to setup the host part (network, cgroup)
4 #while starting a vzgot Virtual Host
5 #This shell is called from the vzgot executable
8 #----------------------------------------------------
10 #vzgot.open VE_name VE_pid [base_dir]
11 # VE_name is the container dir name
12 # HS_pid is the vzgot container master process
13 # VE_pid is the container main process ID as seen
15 # base_dir is this application root directory
16 # used for devel only.
17 #----------------------------------------------------
22 #----------------------------------------------------
23 if ! [ -f $BASE/etc/vzgot/vzgot_config ] ; then
24 echo "Missing vzgot config file"
25 exit 1 #trouble trouble
27 . $BASE/etc/vzgot/vzgot_config
29 #specific container configuration override (if needed)
30 if [ -f $BASE/$VZLIB/vzdir/$CONTNAME/vzgot_config ] ; then
31 $BASE/$VZLIB/vzdir/$CONTNAME/vzgot_config
33 #----------------------------------------------------
34 #Using cgroup if available and operational
35 if [ -f $CGROUP/tasks ] ; then
36 ln -nsf $CGROUP/$VEPID $BASE/$VZLIB/vzdir/$CONTNAME/cgroup
37 if [ -d $BASE/$VZLIB/vzdir/$CONTNAME/cgroup.d ] ; then
38 for c in `ls $BASE/$VZLIB/vzdir/$CONTNAME/cgroup.d`
39 do #setting container limits
40 sed 's/#.*//g' $BASE/$VZLIB/vzdir/$CONTNAME/cgroup.d/$c | \
41 grep -v '^[[:space:]]*$' > /tmp/$c.$$
43 while read -r -u 5 COMMAND
45 echo $COMMAND > $BASE/$VZLIB/vzdir/$CONTNAME/cgroup/$c
53 #----------------------------------------------------
54 #to be sure to start fresh with veth pair
55 ip link del To_$HSPID > /dev/null 2>&1
56 #creation the veth pair.
57 ip link add name To_$HSPID type veth peer name From_$HSPID
59 if [ $ret -ne 0 ]; then
60 echo "vzgot.init, unable to create veth To_$HSPID/From_$HSPID pair"
63 #activating vteh HOST interface
66 if [ $ret -ne 0 ]; then
67 echo "vzgot.init, unable to activate veth HOST part"
70 #linking HOST vteh to bridge
71 brctl addif $BRIDGENAME To_$HSPID
73 if [ $ret -ne 0 ]; then
74 echo "vzgot.init, unable to link veth HOST part to bridge"
77 #giving the "from" part of the pair to VZ
78 ip link set From_$HSPID netns $VEPID
79 if [ $ret -ne 0 ]; then
80 echo "vzgot.init, unable to give From_$HSPID veth pair to VZ process"
83 #----------------------------------------------------
84 #lets prepare all routing
85 $BASE/$VZLIB/shell/vzgot.net $CONTNAME assign $BASE
86 #----------------------------------------------------