config = $config; $this->logger = $logger; $this->ngControl = $ngControl; $this->ifConfig = $ifConfig; $this->kldLoad = $kldLoad; } /** * {@inheritDoc} */ protected function execute( InputInterface $input, OutputInterface $output ): int { switch ($this->getVariant()) { case 'opnsense': $this->logger->info('loading netgraph kernel modules...'); $this->kldLoad->execute('netgraph'); $this->kldLoad->execute('ng_ether'); $this->kldLoad->execute('ng_etf'); $this->kldLoad->execute('ng_vlan'); $this->kldLoad->execute('ng_eiface'); $this->kldLoad->execute('ng_one2many'); $this->logger->info('OK!'); break; case 'pfsense': default: $attach = function (string $interface): Process { return new Process([ '/usr/local/bin/php', '-r', '"pfSense_ngctl_attach(\'.\', \'' . $interface . '\');"' ]); }; $this->logger->info('attaching interfaces to ng_ether...'); $attach($this->config->getOntInterface())->mustRun(); $attach($this->config->getRgInterface())->mustRun(); $this->logger->info('OK!'); break; } $this->ngControl->createBridge( $this->config->getOntInterface(), $this->config->getRgInterface(), $this->config->getRgEthernetMac() ); $this->ifConfig->start( $this->config->getOntInterface(), $this->config->getRgInterface() ); $this->logger->info("ngeth0 should now be available to configure as your pfSense WAN"); $this->logger->info("Done"); return Command::SUCCESS; } /** * @return string */ private function getVariant(): string { // @todo detect the variant to trigger different behaviors. return 'opnsense'; } }