Exemple #1
0
 /**
  * @return string
  * @throws \Exception
  */
 public function createNewConfig()
 {
     $file_system = new \Amp\Util\Filesystem();
     $new_config_file_path = Path::join($this->tmp_path, basename($this->app_armor_config_file_path));
     $file_system->copy($this->app_armor_config_file_path, $new_config_file_path);
     $new_config_file = FileExt::open($new_config_file_path, 'a');
     FileExt::write($new_config_file, "\n");
     foreach ($this->getFormattedAppArmorLines() as $app_armor_line) {
         FileExt::write($new_config_file, $app_armor_line);
     }
     FileExt::close($new_config_file);
     return $new_config_file_path;
 }
Exemple #2
0
 public function configure()
 {
     $file_system = new \Amp\Util\Filesystem();
     $new_config_file_path = Path::join($this->tmp_path, basename($this->app_armor_config_file_path));
     $file_system->copy($this->app_armor_config_file_path, $new_config_file_path);
     $new_config_file = FileExt::open($new_config_file_path, 'a');
     FileExt::write($new_config_file, "\n");
     foreach ($this->getFormattedAppArmorLines() as $app_armor_line) {
         FileExt::write($new_config_file, $app_armor_line);
     }
     FileExt::close($new_config_file);
     $this->runCommand("sudo mv {$new_config_file_path} {$this->app_armor_config_file_path}");
     $this->runCommand("sudo /etc/init.d/apparmor restart", array('throw_exception_on_nonzero' => FALSE));
 }
 /**
  * @param \Amp\RamDisk\RamDiskInterface $ram_disk
  * @void
  */
 public function setRamDisk($ram_disk)
 {
     $this->ram_disk = $ram_disk;
     Path::mkdir_p_if_not_exists($ram_disk->getPath());
     $this->mysql_data_path = Path::join($ram_disk->getPath(), 'mysql');
     $this->tmp_path = Path::join($ram_disk->getPath(), 'tmp');
     $this->mysqld_pid_file_path = Path::join($this->tmp_path, 'mysqld.pid');
     $this->mysql_socket_path = Path::join($this->tmp_path, 'mysqld.sock');
 }
Exemple #4
0
 /**
  * @param bool $force
  *   Initialize database files, even files exist.
  * @throws \Exception
  */
 protected function initializeDatabase($force = FALSE)
 {
     // FIXME: This should probably be rewritten as a wrapper for mysql_install_db
     // with options communicated by creating a custom ~/.amp/ram_disk/tmp/my.cnf
     if (!$force && glob("{$this->mysql_data_path}/*")) {
         return;
     }
     $mysqldVersion = $this->getVersion();
     $options = '';
     $pipe = '';
     if (version_compare($mysqldVersion, '5.7.6', '<=')) {
         Path::mkdir_p_if_not_exists(Path::join($this->mysql_data_path, 'mysql'));
         $this->runCommand("echo \"use mysql;\" > {$this->tmp_path}/install_mysql.sql");
         if ($this->getDefaultDataFiles()) {
             $this->runCommand("cat " . implode(' ', array_map('escapeshellarg', (array) $this->getDefaultDataFiles())) . " >> {$this->tmp_path}/install_mysql.sql");
         } else {
             throw new \Exception("Error finding default data files");
         }
         $pipe = "< {$this->tmp_path}/install_mysql.sql";
         $options .= ' --bootstrap ';
     } else {
         $options .= ' --initialize-insecure';
     }
     $options .= version_compare($mysqldVersion, '5.7.2', '<=') ? ' --log-warnings=0' : ' --log-error-verbosity=1';
     $options .= ' --innodb';
     $options .= ' --default-storage-engine=innodb';
     $options .= ' --max_allowed_packet=8M';
     $options .= ' --net_buffer_length=16K';
     $this->runCommand("{$this->getMySQLDBaseCommand()} {$options} {$pipe}");
 }