<?php
// This is executed at the first instalation.
// Or, if you want to create another admin user.
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 . "/struct.inc.php");
require_once($INC . "/state.inc.php");
require_once($INC . "/rights.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);
}
$r = rg_sql_struct_update($db, 0);
if ($r !== TRUE) {
echo "Cannot init structure. Check the logs!\n";
exit(1);
}
// creating admin user
$_u = array();
$_u['uid'] = 0;
$_u['username'] = "admin";
$_u['realname'] = "Master admin";
$_u['email'] = $rg_admin_email;
$_u['is_admin'] = 1;
$_u['disk_quota_mb'] = 0;
$_u['rights'] = rg_rights_all("user");
$_u['session_time'] = 3600;
$_u['confirm_token'] = "";
do {
$username0 = readline("User [" . $_u['username'] . "]: ");
if (!empty($username0))
$_u['username'] = $username0;
$email0 = readline("E-mail [" . $_u['email'] . "]: ");
if (!empty($email0))
$_u['email'] = $email0;
do {
$_u['pass'] = readline("Password: ");
$_u['pass2'] = readline("Password (confirmation): ");
if (strcmp($_u['pass'], $_u['pass2']) != 0) {
echo "Passwords mismatch!\n";
continue;
}
} while(0);
$r = rg_user_info($db, $_u['uid'], $_u['username'], "" /* email */);
if ($r['ok'] != 1) {
echo "Error looking up user " . $_u['username']
. " (" . rg_user_error() . ")!\n";
exit(1);
}
if ($r['exists'] == 1) {
echo "User " . $_u['username'] . " already exists."
. " Try another one!\n";
continue;
}
$r = rg_user_edit($db, $_u);
if ($r !== TRUE) {
echo "Cannot create user (" . rg_user_error() . ")!\n";
continue;
}
} while (0);
// Store the timestamp of the first install
$first_install = rg_state_get($db, "first_install");
if ($first_install == 0)
rg_state_set($db, "first_install", time());
$install_id = rg_state_get($db, "install_id");
if (empty($install_id))
rg_state_set($db, "install_id", sha1(microtime(TRUE)));
echo "Done!\n";
?>
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