/**
  * Disable remote access
  */
 public function disableRemoteAccess()
 {
     $this->climate->lightBlue()->inline("Disabling remote access... ");
     try {
         if (file_exists("/etc/mysql/mariadb.conf.d/50-server.cnf")) {
             CommandExecutor::executeCommand("/bin/sed -i 's/^#bind-address/bind-address/g' /etc/mysql/mariadb.conf.d/50-server.cnf");
             CommandExecutor::executeCommand("/usr/sbin/service mysql restart");
         } elseif (file_exists("/etc/mysql/mysql.conf.d/mysqld.cnf")) {
             CommandExecutor::executeCommand("/bin/sed -i 's/^#bind-address/bind-address/g' /etc/mysql/mysql.conf.d/mysqld.cnf");
             CommandExecutor::executeCommand("/usr/sbin/service mysql restart");
         } elseif (file_exists("/etc/mysql/my.cnf")) {
             CommandExecutor::executeCommand("/bin/sed -i 's/^#bind-address/bind-address/g' /etc/mysql/my.cnf");
             CommandExecutor::executeCommand("/usr/sbin/service mysql restart");
         } else {
             $this->climate->shout("Can't find the MySQL configuration file - this is probably an unsupported version of Ubuntu. Please notify support@sonar.software and we'll get it fixed!");
             return;
         }
     } catch (RuntimeException $e) {
         $this->climate->shout("FAILED!");
         $this->climate->shout($e->getMessage());
         $this->climate->shout("See /tmp/_genie_output for failure details.");
         return;
     }
     $this->climate->info("SUCCESS!");
 }
 /**
  * Configure the FreeRADIUS configuration files
  */
 public function configureFreeRadiusToUseSql()
 {
     $mysqlPassword = getenv("MYSQL_PASSWORD");
     $this->climate->lightBlue()->inline("Configuring FreeRADIUS to use the SQL database... ");
     try {
         CommandExecutor::executeCommand("/bin/cp " . __DIR__ . "/../conf/radiusd.conf /etc/freeradius/");
         CommandExecutor::executeCommand("/bin/cp " . __DIR__ . "/../conf/sql.conf /etc/freeradius/");
         CommandExecutor::executeCommand("/bin/cp " . __DIR__ . "/../conf/default /etc/freeradius/sites-available/");
         CommandExecutor::executeCommand("/bin/sed -i 's/password = \"radpass\"/password = \"{$mysqlPassword}\"/g' /etc/freeradius/sql.conf");
         CommandExecutor::executeCommand("/usr/sbin/service freeradius restart");
     } catch (RuntimeException $e) {
         $this->climate->shout("FAILED!");
         $this->climate->shout($e->getMessage());
         $this->climate->shout("See /tmp/_genie_output for failure details.");
     }
     $this->climate->info("SUCCESS!");
 }
 /**
  * Delete a NAS
  */
 public function deleteNas()
 {
     $input = $this->climate->lightBlue()->input("What is the IP address of the NAS you want to remove?");
     $ipAddress = null;
     while ($ipAddress == null || filter_var($ipAddress, FILTER_VALIDATE_IP) === false) {
         $ipAddress = $input->prompt();
         if ($ipAddress == null) {
             $this->climate->shout("You must input an IP address.");
         } elseif (filter_var($ipAddress, FILTER_VALIDATE_IP) === false) {
             $this->climate->shout("That IP address is not valid.");
         }
     }
     $sth = $this->dbh->prepare("DELETE from nas WHERE nasname=?");
     if ($sth->execute([$ipAddress])) {
         $this->climate->shout("NAS was deleted!");
         try {
             CommandExecutor::executeCommand("/usr/sbin/service freeradius restart");
         } catch (RuntimeException $e) {
             $this->climate->shout("Failed to restart FreeRADIUS!");
         }
     } else {
         $this->climate->shout("Failed to delete the NAS from the database. Maybe the IP wasn't found? Try using the List NAS entries function first.");
     }
 }