Skip to content

Commit

Permalink
Fixed some installation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gubi committed Dec 10, 2013
1 parent a46c6a7 commit 4c35d4a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
27 changes: 15 additions & 12 deletions common/include/funcs/_ajax/install.generate_smb_conf.php 100644 → 100755
Expand Up @@ -74,49 +74,52 @@

// Files creation
// Main config file
if($fp = fopen($output["server_root"] . "common/include/conf/config.ini", "w")) {
if($fp = @fopen($output["server_root"] . "common/include/conf/config.ini", "w")) {
fwrite($fp, $smb_conf . PHP_EOL);
fclose($fp);
$log->write("notice", "[install] The new file 'config.ini' is located in 'common/include/conf/'");

// Main config file
if($fg = fopen($output["server_root"] . "common/include/conf/general_settings.ini", "w")) {
if($fg = @fopen($output["server_root"] . "common/include/conf/general_settings.ini", "w")) {
fwrite($fg, $general_settings . PHP_EOL);
fclose($fg);
$log->write("notice", "[install] The new file 'general_settings.ini' is located in 'common/include/conf/'");

// User login file
mkdir("common/include/conf/user/" . sha1($output["user_username"]) . "/");
chmod("common/include/conf/user/" . sha1($output["user_username"]) . "/", 0777);
if($fu = fopen($output["server_root"] . "common/include/conf/user/" . sha1($output["user_username"]) . "/user.conf", "w")) {
if(!file_exists($output["server_root"] . "common/include/conf/user/" . sha1($output["user_username"]))) {
mkdir($output["server_root"] . "common/include/conf/user/" . sha1($output["user_username"]) . "/");
chmod($output["server_root"] . "common/include/conf/user/" . sha1($output["user_username"]) . "/", 0777);
}
if($fu = @fopen($output["server_root"] . "common/include/conf/user/" . sha1($output["user_username"]) . "/user.conf", "w")) {
fwrite($fu, $user_conf . PHP_EOL);
fclose($fu);
$log->write("notice", "[install] The new file 'user.conf' is located in 'common/include/conf/user/" . sha1($output["user_username"]) . "/'");

// User public PGP file
if($fpgp = fopen($output["server_root"] . "common/include/conf/user/" . sha1($output["user_username"]) . "/pubkey.asc", "w")) {
if($fpgp = @fopen($output["server_root"] . "common/include/conf/user/" . sha1($output["user_username"]) . "/pubkey.asc", "w")) {
fwrite($fpgp, $output["pgp_pubkey"] . PHP_EOL);
fclose($fpgp);
$log->write("notice", "[install] The new file 'pubkey.asc' is located in 'common/include/conf/user/" . sha1($output["user_username"]) . "/'");

// Database config file
if($fdb = fopen($output["server_root"] . "common/include/conf/db.ini", "w")) {
if($fdb = @fopen($output["server_root"] . "common/include/conf/db.ini", "w")) {
fwrite($fdb, $mysql_conf . PHP_EOL);
fclose($fdb);
$log->write("notice", "[install] The new file 'db.ini' is located in 'common/include/conf/'");

// Crontab
$fc = fopen($output["server_root"] . "crontab", "w+");
if(fwrite($fc, "# Ninuxoo Local scan job\n00 */6 * * * root /usr/bin/php " . $output["server_root"] . "scan.php" . PHP_EOL) === false) {
$log->write("error", "[install] Can't create 'crontab' file in '" . $output["server_root"] . "'. Installation malformed");
$data = "error::Sono stati riscontrati dei problemi nella creazione del crontab.\nInstallazione avvenuta con successo.\nInstallare il cronjob manualmente.\nConsultare la documentazione per maggiori informazioni.";
} else {
if($fc = @fopen($output["server_root"] . "crontab", "w+")) {
fwrite($fc, "# Ninuxoo Local scan job\n00 */6 * * * root /usr/bin/php " . $output["server_root"] . "scan.php" . PHP_EOL);
fclose($fc);

if(!exec("crontab " . $output["server_root"] . "crontab")) {
$log->write("notice", "[warning] A problem has occurred during installation of crontab. Please open and copy '" . $output["server_root"] . "crontab' and paste in '$ (sudo) crontab -e' manually.");
}
mail($output["user_username"], "Benvenuto in Ninuxoo!", "Prova", "From: ninuxoo@ninux.org");
$data = "ok";
} else {
$log->write("error", "[install] Can't create 'crontab' file in '" . $output["server_root"] . "'. Installation malformed");
$data = "error::Sono stati riscontrati dei problemi nella creazione del crontab.\nInstallazione avvenuta con successo.\nInstallare il cronjob manualmente.\nConsultare la documentazione per maggiori informazioni.";
}
} else {
$log->write("error", "[install] Can't create 'db.ini' in 'common/include/conf/'. Installation malformed");
Expand Down
8 changes: 6 additions & 2 deletions common/js/include/setup.js
Expand Up @@ -271,7 +271,7 @@ function install() {
var password = makeid();

$.jCryption.authenticate(password, "common/include/funcs/_ajax/decrypt.php?getPublicKey=true", "common/include/funcs/_ajax/decrypt.php?handshake=true", function(AESKey) {
var encryptedString = $.jCryption.encrypt($("#content > form").serialize(), password);
var encryptedString = $.jCryption.encrypt($("#install_frm").serialize(), password);

$.ajax({
url: "common/include/funcs/_ajax/decrypt.php",
Expand All @@ -285,7 +285,11 @@ function install() {
if (response["data"] !== "ok") {
var risp = response["data"].split("::");
if(risp[0] == "error") {
alert("Si è verificato un errore durante l'installazione:\n" + risp[1], {icon: "error", title: "Ouch!"});
apprise("Si &egrave; verificato un errore durante l'installazione:<br />" + risp[1].replace("\n", "<br />"), {icon: "error", title: "Ouch!"}, function(r) {
if(r) {
$("#setup_loader").hide();
}
});
}
} else {
$("#setup_loader > span").text("Scansione dei files...");
Expand Down
2 changes: 1 addition & 1 deletion common/tpl/setup.tpl
Expand Up @@ -203,7 +203,7 @@
<span id="alert_no_internet" class="error"></span>
<button id="show_form" class="save" <?php print $btn_next_disabled; ?>>Prosegui</button>

<form method="post" action="" class="frm" style="display: none;" onsubmit="install()">
<form method="post" action="" class="frm" id="install_frm" style="display: none;" onsubmit="install()">
<fieldset>
<legend>Dati per l'accesso</legend>
<p>I dati a seguire consentiranno l'accesso al pannello di controllo, dal quale si potr&agrave;:</p>
Expand Down

0 comments on commit 4c35d4a

Please sign in to comment.