#!/bin/sh if [ $# -lt 2 ] ;then echo privscript vserver vserverdir command ... echo THis is the privilege script execute by the vserver echo command just in the middle of the initialisation echo of a vserver. At this point, the pid namespace echo is created, but the chroot is not done echo and all capabilities are still on. echo echo It enables process accounting echo mount proc and devpts and execute a command else VSERVER=$1 shift #echo PWD=`pwd` mkdir -p proc #mkdir -p dev/pts if [ ! -f proc/loadavg ] ; then # loadavg does not exist, we must mount #echo Mounting /proc and /dev/pts mount -n -t proc none proc elif [ ! -f proc/self/status ] ; then # proc/self does not exist, yet loadavg exist # it means proc is currently mounted in an old pid namespace # we umount and mount again #echo RE mounting /proc # On some kernel, umount proc fails, on other, umount ./proc does nothing umount -n proc 2>/dev/null umount -n ./proc 2>/dev/null mount -n -t proc none proc fi shift mkdir -p /var/run/vacct rm -f /var/run/vacct/acct-$VSERVER.log touch /var/run/vacct/acct-$VSERVER.log accton /var/run/vacct/acct-$VSERVER.log >/dev/null exec "$@" fi