protected function writeHostsFile()
 {
     $config = Template::render('lxc/project-hosts.twig', array('hostname' => $this->getContainer()->getHostname()));
     $file = '/var/lib/lxc/' . $this->getContainer()->getName() . '/rootfs/etc/hosts';
     if ($this->getContainer()->isProjectBranch()) {
         $project = $this->getEntityManager()->getRepository('Rainmaker:Container')->getParentContainer($this->getContainer());
         $file = '/var/lib/lxc/' . $project->getName() . '/rootfs/var/lib/lxc/' . $this->getContainer()->getName() . '/rootfs/etc/hosts';
     }
     $this->getFilesystem()->putFileContents($file, $config);
 }
Exemplo n.º 2
0
 /**
  * Writes the Linux NFS exports file to disk.
  */
 protected function writeExportsFile()
 {
     $exports = Template::render('exports.twig', array('exports' => $this->getExports()));
     $exportsFile = $this->getFilesystem()->getFileContents('/etc/exports');
     $startMarker = '# Rainmaker - Start #';
     $endMarker = '# Rainmaker - End #';
     $count = 0;
     $exportsFile = preg_replace("/{$startMarker}(?:.+){$endMarker}/s", $exports, $exportsFile, -1, $count);
     if ($count < 1) {
         $exportsFile .= "\n{$exports}\n";
     }
     $this->getFilesystem()->putFileContents('/etc/exports', $exportsFile);
 }
 protected function writeHostsFile()
 {
     $config = Template::render('lxc/project-hosts.twig', array('hostname' => $this->getContainer()->getHostname()));
     $file = '/var/lib/lxc/' . $this->getContainer()->getName() . '/rootfs/etc/hosts';
     $this->getFilesystem()->putFileContents($file, $config);
 }
Exemplo n.º 4
0
 /**
  * Writes the configuration file for the Rainmaker project branch Linux container to the filesystem.
  */
 protected function writeProjectBranchLxcConfigurationFile()
 {
     $config = Template::render('lxc/project-branch-config.twig', array('lxc_root_fs' => $this->getContainer()->getLxcRootFs(), 'lxc_utsname' => $this->getContainer()->getLxcUtsName(), 'lxc_net_hwaddr' => $this->getContainer()->getLxcHwAddr()));
     $project = $this->getEntityManager()->getRepository('Rainmaker:Container')->getParentContainer($this->getContainer());
     $file = '/var/lib/lxc/' . $project->getName() . '/rootfs/var/lib/lxc/' . $this->getContainer()->getName() . '/config';
     $this->getFilesystem()->putFileContents($file, $config);
 }
Exemplo n.º 5
0
 /**
  * Writes the DHCPD configuration file for the subnet the containers reside in to the filesystem.
  */
 protected function writeDhcpSubnetFile()
 {
     $config = Template::render('dhcp/subnet.twig', array('repo' => $this->getEntityManager()->getRepository('Rainmaker:Container'), 'containers' => $this->getEntityManager()->getRepository('Rainmaker:Container')->getAllParentContainers()));
     $file = '/var/lib/lxc/services/rootfs/etc/dhcp/dhcpd.subnet.conf.d/10.100.0.0.conf';
     $this->getFilesystem()->putFileContents($file, $config);
 }
Exemplo n.º 6
0
 /**
  * Writes the DNS zone PTR file for the Rainmaker project branch Linux container to the filesystem.
  */
 protected function writeProjectBranchDnsZonePtrFile()
 {
     $project = $this->getEntityManager()->getRepository('Rainmaker:Container')->getParentContainer($this->getContainer());
     $config = Template::render('bind/ptr-zone.twig', array('repo' => $this->getEntityManager()->getRepository('Rainmaker:Container'), 'container' => $project));
     $file = '/var/lib/lxc/services/rootfs/etc/bind/db.rainmaker/db.' . $this->getContainer()->networkPrefix();
     $this->getFilesystem()->putFileContents($file, $config);
 }
Exemplo n.º 7
0
 /**
  * Writes the Linux fstab file to disk.
  */
 protected function writeFstab()
 {
     $mounts = Template::render('fstab.twig', array('fstabToolMounts' => $this->getFstabToolMounts(), 'fstabNfsMounts' => $this->getFstabNfsMounts()));
     $fstab = $this->getFilesystem()->getFileContents('/etc/fstab');
     $startMarker = '# Rainmaker - Start #';
     $endMarker = '# Rainmaker - End #';
     $count = 0;
     $fstab = preg_replace("/{$startMarker}(?:.+){$endMarker}/s", $mounts, $fstab, -1, $count);
     if ($count < 1) {
         $fstab .= "\n{$mounts}\n";
     }
     $this->getFilesystem()->putFileContents('/etc/fstab', $fstab);
 }