public function usherServerConnections($request, $match) { $server = $match[1]; if (!in_array($server, IDF_Scm_Monotone_Usher::getServerList())) { throw new Pluf_HTTP_Error404(); } $title = sprintf(__('Open connections for "%s"'), $server); $connections = IDF_Scm_Monotone_Usher::getConnectionList($server); if (count($connections) == 0) { $request->user->setMessage(sprintf(__('no connections for server "%s"'), $server)); $url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::usher'); return new Pluf_HTTP_Response_Redirect($url); } return Pluf_Shortcuts_RenderToResponse('idf/gadmin/usher/connections.html', array('page_title' => $title, 'server' => $server, 'connections' => $connections), $request); }
/** * Clean up after a mtn project was deleted * * @param IDF_Project */ public function processProjectDelete($project) { if ($project->getConf()->getVal('scm') != 'mtn') { return; } if (Pluf::f('mtn_db_access', 'local') == 'local') { return; } $usher_config = Pluf::f('mtn_usher_conf', false); if (!$usher_config || !is_writable($usher_config)) { throw new IDF_Scm_Exception(__('"mtn_usher_conf" does not exist or is not writable.')); } $shortname = $project->shortname; IDF_Scm_Monotone_Usher::killServer($shortname); $projecttempl = Pluf::f('mtn_repositories', false); if ($projecttempl === false) { throw new IDF_Scm_Exception(__('"mtn_repositories" must be defined in your configuration file.')); } $projectpath = sprintf($projecttempl, $shortname); if (file_exists($projectpath)) { if (!self::_delete_recursive($projectpath)) { throw new IDF_Scm_Exception(sprintf(__('One or more paths underknees %s could not be deleted.'), $projectpath)); } } $keydir = Pluf::f('tmp_folder') . '/mtn-client-keys'; $keyname = $project->getConf()->getVal('mtn_client_key_name', false); $keyhash = $project->getConf()->getVal('mtn_client_key_hash', false); if ($keyname && $keyhash && file_exists($keydir . '/' . $keyname . '.' . $keyhash)) { if (!@unlink($keydir . '/' . $keyname . '.' . $keyhash)) { throw new IDF_Scm_Exception(sprintf(__('Could not delete client private key %s'), $keyname)); } } $usher_rc = file_get_contents($usher_config); $parsed_config = array(); try { $parsed_config = IDF_Scm_Monotone_BasicIO::parse($usher_rc); } catch (Exception $e) { throw new IDF_Scm_Exception(sprintf(__('Could not parse usher configuration in "%s": %s'), $usher_config, $e->getMessage())); } foreach ($parsed_config as $idx => $stanzas) { foreach ($stanzas as $stanza_line) { if ($stanza_line['key'] == 'server' && $stanza_line['values'][0] == $shortname) { unset($parsed_config[$idx]); break; } } } $usher_rc = IDF_Scm_Monotone_BasicIO::compile($parsed_config); // FIXME: more sanity - what happens on failing writes? we do not // have a backup copy of usher.conf around... if (file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) { throw new IDF_Scm_Exception(sprintf(__('Could not write usher configuration file "%s"'), $usher_config)); } IDF_Scm_Monotone_Usher::reload(); }