MCPcopy Create free account
hub / github.com/cloudfoundry/bosh-agent / SetupOptDir

Method SetupOptDir

platform/linux_platform.go:1273–1315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1271}
1272
1273func (p linux) SetupOptDir() error {
1274 varOptDir := "/var/opt"
1275
1276 boshRootVarOptDirPath := path.Join(p.dirProvider.DataDir(), "root_var_opt")
1277 err := p.fs.MkdirAll(boshRootVarOptDirPath, userRootOptDirPermissions)
1278 if err != nil {
1279 return bosherr.WrapError(err, "Creating root var opt dir")
1280 }
1281
1282 _, _, _, err = p.cmdRunner.RunCommand("chown", "root:root", boshRootVarOptDirPath)
1283 if err != nil {
1284 return bosherr.WrapError(err, "Chowning root var opt dir")
1285 }
1286
1287 // Mount our /var/opt bind mount without the 'noexec' option. Binaries are
1288 // often in subdirectories of /var/opt, and folks expect to be able to execute them.
1289 err = p.bindMountDir(boshRootVarOptDirPath, varOptDir, true, true)
1290 if err != nil {
1291 return err
1292 }
1293
1294 optDir := "/opt"
1295
1296 boshRootOptDirPath := path.Join(p.dirProvider.DataDir(), "root_opt")
1297 err = p.fs.MkdirAll(boshRootOptDirPath, userRootOptDirPermissions)
1298 if err != nil {
1299 return bosherr.WrapError(err, "Creating root opt dir")
1300 }
1301
1302 _, _, _, err = p.cmdRunner.RunCommand("chown", "root:root", boshRootOptDirPath)
1303 if err != nil {
1304 return bosherr.WrapError(err, "Chowning root opt dir")
1305 }
1306
1307 // Mount our /opt bind mount without the 'noexec' option. Binaries are
1308 // often in subdirectories of /opt, and folks expect to be able to execute them.
1309 err = p.bindMountDir(boshRootOptDirPath, optDir, true, true)
1310 if err != nil {
1311 return err
1312 }
1313
1314 return err
1315}
1316
1317func (p linux) ensureFile(path, owner, mode string) error {
1318 _, _, _, err := p.cmdRunner.RunCommand("touch", path)

Callers

nothing calls this directly

Calls 4

bindMountDirMethod · 0.95
DataDirMethod · 0.80
MkdirAllMethod · 0.80
RunCommandMethod · 0.65

Tested by

no test coverage detected