X-Git-Url: http://git.onelab.eu/?p=util-vserver-pl.git;a=blobdiff_plain;f=scripts%2Fvuseradd;h=f64d62da30e06fc24ed797934decb8b32bd73c80;hp=b54aec9204d08a164c5b60065b9931e07296e46f;hb=HEAD;hpb=a6e1134d8bdb41b0146cdac83e4e82909e74cb47 diff --git a/scripts/vuseradd b/scripts/vuseradd index b54aec9..f64d62d 100755 --- a/scripts/vuseradd +++ b/scripts/vuseradd @@ -39,11 +39,15 @@ usage() } # Get options -while getopts "t:" opt ; do +ISOLATE=false +while getopts "it:" opt ; do case $opt in t) TYPE="$OPTARG" ;; + i) + ISOLATE=true + ;; *) usage ;; @@ -77,22 +81,36 @@ if [ ! -d $__CONFDIR/$NAME ] ; then HAS_VSERVERDIR=0 fi - $_VSERVER $NAME build -m skeleton --context $USERID \ + if [ "$ISOLATE" = "true" ] ; then + $_VSERVER $NAME build -m skeleton --context $USERID \ + --interface nodev:`hostname -i` \ + --flags persistent,~info_init + else + $_VSERVER $NAME build -m skeleton --context $USERID \ --interface nodev:`hostname -i` \ - --interface nodev:127.0.0.1 \ + --interface nodev:127.0.0.1 \ --flags persistent,~info_init + fi + RETVAL=$? DIR=$__CONFDIR/$NAME if [ $RETVAL -ne 0 ] ; then echo "Error $RETVAL building $DIR" rm -rf $DIR $__DEFAULT_VSERVERDIR/$NAME fi - mkdir -p $DIR/apps/init $DIR/rlimits $DIR/sched $DIR/dlimits/0 $DIR/sysctl/0 + mkdir -p $DIR/apps/init $DIR/rlimits $DIR/sched $DIR/cgroup $DIR/dlimits/0 $DIR/sysctl/0 echo default > $DIR/apps/init/mark - echo 1000 > $DIR/rlimits/nproc.hard # Set persistent for the network context - echo persistent,lback_allow > $DIR/nflags + if [ "$ISOLATE" = "true" ]; then + echo persistent,lback_allow,hide_lback,lback_remap > $DIR/nflags + else + echo persistent,lback_allow > $DIR/nflags + fi + + # Set default capabilities + echo "CAP_NET_RAW" > $DIR/bcapabilities + touch $DIR/ccapabilities # Set up the scheduler echo 100 > $DIR/sched/interval @@ -104,19 +122,18 @@ if [ ! -d $__CONFDIR/$NAME ] ; then echo 50 > $DIR/sched/tokens-min echo 100 > $DIR/sched/tokens-max - # Set up disk limits (unlimited) + echo 1024 > $DIR/cgroup/cpu.shares + + # Set up disk limits (10 GB) echo `$_READLINK $DIR/vdir` > $DIR/dlimits/0/directory echo 2 > $DIR/dlimits/0/reserved echo -1 > $DIR/dlimits/0/inodes_total - echo -1 > $DIR/dlimits/0/space_total + echo 10000000 > $DIR/dlimits/0/space_total # Set up sysctl variables echo net.ipv4.ip_forward > $DIR/sysctl/0/setting echo 1 > $DIR/sysctl/0/value - # Disable mount namespaces - touch $DIR/nonamespace - # Add spaces directory mkdir -p $DIR/spaces