import time
import traceback
-#import mount
+import mountimpl
import linuxcaps
import passfdimpl
+import utmp
import vserverimpl
from util_vserver_vars import *
garbage += filter(os.path.isfile, map((LOCKDIR + "/").__add__,
os.listdir(LOCKDIR)))
for f in garbage:
- print >>log, "removing " + f
os.unlink(f)
# set the initial runlevel
+ f = open(RUNDIR + "/utmp", "w")
+ utmp.set_runlevel(f, runlevel)
+ f.close()
# mount /proc and /dev/pts
+ self.__do_mount("none", "/proc", "proc")
+ # XXX - magic mount options
+ self.__do_mount("none", "/dev/pts", "devpts", 0, "gid=5,mode=0620")
+
+ def __do_mount(self, *mount_args):
+
+ try:
+ mountimpl.mount(*mount_args)
+ except OSError, ex:
+ if ex.errno == errno.EBUSY:
+ # assume already mounted
+ return
+ raise ex
def enter(self):
self.__do_chroot()
self.__do_chcontext(state_file)
- def start(self, runlevel = 3):
+ def start(self, wait, runlevel = 3):
child_pid = os.fork()
if child_pid == 0:
# XXX - we don't support all scripts that vserver script does
cmd_pid = 0
for cmd in self.INITSCRIPTS + [None]:
- # don't bother waiting for last command to terminate
- if cmd == None:
- os._exit(0)
-
- # wait for previous command to terminate
- if cmd_pid:
+ # wait for previous command to terminate, unless it
+ # is the last one and the caller has specified to wait
+ if cmd_pid and (cmd != None or wait):
try:
os.waitpid(cmd_pid, 0)
except:
print >>log, "error waiting for %s:" % cmd_pid
traceback.print_exc()
+ # end of list
+ if cmd == None:
+ os._exit(0)
+
# fork and exec next command
cmd_pid = os.fork()
if cmd_pid == 0: