xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
<root> / admin / init.php (df61bede72c9caaa49cc4046a03f302d7269e942) (1,779B) (mode 100644) [raw]
<?php
// This is executed at the first instalation
error_reporting(E_ALL);
ini_set("track_errors", "On");

require_once("/etc/rocketgit/config.php");

$INC = dirname(__FILE__) . "/../inc";
require_once($INC . "/util.inc.php");
require_once($INC . "/log.inc.php");
require_once($INC . "/sql.inc.php");
require_once($INC . "/db/struct.inc.php");

rg_log_set_file("init.log");

$db = rg_sql_open($rg_sql);
if ($db === FALSE) {
	echo "Internal error (" . rg_sql_error() . ")!\n";
	exit(1);
}

$ignore_errors = FALSE;
$drop_tables = FALSE;
$old_schema_ver = 0;
$r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
if ($r !== TRUE) {
	echo "Cannot init structure (" . rg_sql_error() . ")!\n";
	exit(1);
}

// creating admin user
$uid = 0;
$is_admin = 1;
$disk_quota_mb = 0;
$rights = rg_rights_all("user");
$user = "admin";
$email = $rg_admin_email;
$session_time = 3600;
$confirm_token = "";
while (1) {
	$user0 = readline("User [$user]: ");
	if (!empty($user0))
		$user = $user0;
	$email0 = readline("E-mail [$email]: ");
	if (!empty($email0))
		$email = $email0;
	while (1) {
		$pass = readline("Password: ");
		$pass2 = readline("Password (confirmation): ");
		if (strcmp($pass, $pass2) != 0) {
			echo "Passwords mismatch!\n";
			continue;
		}
		break;
	}

	$r = rg_user_info($db, $uid, $user, "" /* email */);
	if ($r['ok'] != 1) {
		echo "Error looking up user $user (" . rg_user_error() . ")!\n";
		exit(1);
	}
	if ($r['exists'] == 1) {
		echo "User $user already exists. Try another one!\n";
		continue;
	}

	$r = rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
		$disk_quota_mb, $rights, $session_time, $confirm_token);
	if ($r !== TRUE) {
		echo "Cannot create user (" . rg_user_error() . ")!\n";
		continue;
	}
	break;
}

echo "Done!\n";
?>
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master