username:"); $hasUser = Connection::read(); $state = match ($this->state) { State::PRESENT => str_starts_with($hasUser, "$this->username:"), State::ABSENT => empty($hasUser), }; Connection::disablePty(); return $state; } /** * @inheritDoc */ public function getCommands(): array { if ($this->state === State::PRESENT) { Connection::exec(implode(PHP_EOL, [ "sudo adduser $this->username --quiet" . " --shell " . $this->shell . ($this->createHome ? '' : ' --no-create-home'), "sudo usermod -" . ($this->append ? 'a' : '') . "G " . implode(',', $this->groups) . " $this->username" ])); } else if ($this->state === State::ABSENT) { Connection::exec("sudo userdel $this->username"); } return []; } }