// Should we reset users? if (isset($options['r']) || isset($options['reset'])) { $app->add('Model_User')->each('delete'); echo "User access list emptied.\n"; } // Should we import key if (isset($options['k']) || isset($options['key'])) { $file = $options['k'] ?: $options['key']; if ($file == '-') { $file = 'php://stdin'; } $addr = $options['a'] ?: $options['addr']; if (!$addr) { throw $app->exception('Addr must be specified'); } $name = $options['n'] ?: $options['name'] ?: $addr; if (!$file || !is_readable($file)) { die("Specify a valid key file\n"); } echo "Importing key from " . ($file == '-' ? 'STDIN' : $file) . " for {$addr} ({$name})\n"; $private_key = file_get_contents($file == '-' ? STDIN : $file); $host = $app->add('dokku_alt/Model_Host'); $host->tryLoadBy('addr', $addr); $host['addr'] = $addr; $host['name'] = $name; $host['private_key'] = $private_key; $host->saveAndUnload(); } } catch (Exception $e) { $app->caughtException($e); }