|
|
@ -25,8 +25,6 @@ type initState struct {
|
|
|
|
fs *fs.Filesystem
|
|
|
|
fs *fs.Filesystem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//var log = createLogger()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// By convention oz-init writes log messages to stderr with a single character
|
|
|
|
// By convention oz-init writes log messages to stderr with a single character
|
|
|
|
// prefix indicating the logging level. These messages are read one line at a time
|
|
|
|
// prefix indicating the logging level. These messages are read one line at a time
|
|
|
|
// over a pipe by oz-daemon and translated into appropriate log events.
|
|
|
|
// over a pipe by oz-daemon and translated into appropriate log events.
|
|
|
@ -61,6 +59,10 @@ func Main() {
|
|
|
|
Name: "uid",
|
|
|
|
Name: "uid",
|
|
|
|
EnvVar: "INIT_UID",
|
|
|
|
EnvVar: "INIT_UID",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
cli.IntFlag{
|
|
|
|
|
|
|
|
Name: "display",
|
|
|
|
|
|
|
|
EnvVar: "INIT_DISPLAY",
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
app.Run(os.Args)
|
|
|
|
app.Run(os.Args)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -71,6 +73,8 @@ func runInit(c *cli.Context) {
|
|
|
|
address := c.String("address")
|
|
|
|
address := c.String("address")
|
|
|
|
profile := c.String("profile")
|
|
|
|
profile := c.String("profile")
|
|
|
|
uid := uint32(c.Int("uid"))
|
|
|
|
uid := uint32(c.Int("uid"))
|
|
|
|
|
|
|
|
disp := c.Int("display")
|
|
|
|
|
|
|
|
|
|
|
|
if address == "" {
|
|
|
|
if address == "" {
|
|
|
|
st.log.Error("Error: missing required 'address' argument")
|
|
|
|
st.log.Error("Error: missing required 'address' argument")
|
|
|
|
os.Exit(1)
|
|
|
|
os.Exit(1)
|
|
|
@ -101,7 +105,11 @@ func runInit(c *cli.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
st.fs = fs
|
|
|
|
st.fs = fs
|
|
|
|
if p.XServer.Enabled {
|
|
|
|
if p.XServer.Enabled {
|
|
|
|
st.startXpraServer(&p.XServer, fs)
|
|
|
|
if disp == 0 {
|
|
|
|
|
|
|
|
st.log.Error("Cannot start xpra because no display number was passed to oz-init")
|
|
|
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
st.startXpraServer(&p.XServer, fs, disp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
oz.ReapChildProcs(st.log, st.handleChildExit)
|
|
|
|
oz.ReapChildProcs(st.log, st.handleChildExit)
|
|
|
@ -116,7 +124,7 @@ func runInit(c *cli.Context) {
|
|
|
|
st.log.Info("oz-init exiting...")
|
|
|
|
st.log.Info("oz-init exiting...")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (is *initState) startXpraServer (config *oz.XServerConf, fs *fs.Filesystem) {
|
|
|
|
func (is *initState) startXpraServer (config *oz.XServerConf, fs *fs.Filesystem, display int) {
|
|
|
|
workdir := fs.Xpra()
|
|
|
|
workdir := fs.Xpra()
|
|
|
|
if workdir == "" {
|
|
|
|
if workdir == "" {
|
|
|
|
is.log.Warning("Xpra work directory not set")
|
|
|
|
is.log.Warning("Xpra work directory not set")
|
|
|
@ -129,7 +137,7 @@ func (is *initState) startXpraServer (config *oz.XServerConf, fs *fs.Filesystem
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
defer f.Close()
|
|
|
|
xpra := xpra.NewServer(config, 123, workdir)
|
|
|
|
xpra := xpra.NewServer(config, uint64(display), workdir)
|
|
|
|
xpra.Process.Stdout = f
|
|
|
|
xpra.Process.Stdout = f
|
|
|
|
xpra.Process.Stderr = f
|
|
|
|
xpra.Process.Stderr = f
|
|
|
|
xpra.Process.Env = []string{
|
|
|
|
xpra.Process.Env = []string{
|
|
|
|