253 |
let exists_users_ini = |
let exists_users_ini = |
254 |
Sys.file_exists (options_file_name users_ini) |
Sys.file_exists (options_file_name users_ini) |
255 |
in |
in |
256 |
if not exists_downloads_ini then |
if not exists_users_ini && exists_downloads_ini then |
257 |
begin |
begin |
258 |
let oc = open_out (options_file_name downloads_ini) in |
lprintf_nl "No config file (users.ini) found. Importing users from downloads.ini."; |
259 |
close_out oc; |
( try Unix2.copy "downloads.ini" "users.ini" with _ -> () ); |
260 |
if not exists_users_ini then |
end; |
261 |
begin |
|
262 |
let oc = open_out (options_file_name users_ini) in |
let ini_files_exist = Sys.file_exists (options_file_name downloads_ini) in |
263 |
close_out oc; |
|
|
end; |
|
|
end |
|
|
else |
|
|
if not exists_users_ini then |
|
|
begin |
|
|
lprintf_nl "No config file (users.ini) found. Importing users from downloads.ini."; |
|
|
( try Unix2.copy "downloads.ini" "users.ini" with _ -> () ); |
|
|
end; |
|
|
|
|
|
(* |
|
|
let exists_expert_ini = Sys.file_exists |
|
|
(options_file_name downloads_expert_ini) in |
|
|
if not exists_expert_ini then begin |
|
|
if exists_downloads_ini then begin |
|
|
lprintf "Using old config file\n"; |
|
|
(try Unix2.copy "downloads.ini" "downloads_expert.ini" with _ -> ()); |
|
|
(try Unix2.copy "downloads.ini" "donkey.ini" with _ -> ()); |
|
|
(try Unix2.copy "downloads.ini" "donkey_expert.ini" with _ -> ()); |
|
|
|
|
|
end else begin |
|
|
|
|
|
lprintf "No config file found. Generating one.\n"; |
|
|
let oc = open_out (options_file_name downloads_expert_ini) in |
|
|
close_out oc; |
|
|
end |
|
|
end; *) |
|
264 |
(try |
(try |
265 |
Options.load downloads_ini; |
Options.load downloads_ini; |
266 |
Options.load users_ini; |
Options.load users_ini; |
|
(* Options.load downloads_expert_ini; *) |
|
267 |
with e -> |
with e -> |
268 |
lprintf_nl "Exception %s during options load" (Printexc2.to_string e); |
lprintf_nl "Exception %s during options load" (Printexc2.to_string e); |
269 |
exit 70; |
exit 70; |
356 |
(* Files.dump_file file; exit 0 *) |
(* Files.dump_file file; exit 0 *) |
357 |
) ""; |
) ""; |
358 |
|
|
359 |
|
if not ini_files_exist && not !keep_console_output then log_file =:= "mlnet.log"; |
360 |
|
|
361 |
(**** CREATE DIRS ****) |
(**** CREATE DIRS ****) |
|
|
|
|
(* |
|
|
Unix2.safe_mkdir !!incoming_directory; |
|
|
|
|
|
File.from_string (Filename.concat !!incoming_directory "Readme.txt") |
|
|
"This directory contains the files downloaded, after commit. |
|
|
The 'incoming/files/' folder contains simple files. |
|
|
The 'incoming/directories/' folder contains whole directories (probably |
|
|
downloaded with Bittorrent). |
|
|
|
|
|
If you want to share files, you should: |
|
|
- Put simple files or directories where all files should be shared separately |
|
|
in the 'incoming/files/' folder, or better, in the shared/ folder. |
|
|
is for downloaded files. Files to be shared should be |
|
|
put in the 'shared/' directory instead. |
|
|
- Put directories that should be shared as one file in the |
|
|
'incoming/directories/' folder. Currently, such directories can only be |
|
|
shared on the Bittorrent network, by providing the corresponding |
|
|
.torrent in the 'torrents/seeded/' folder. |
|
|
"; |
|
|
|
|
|
Unix2.safe_mkdir (Filename.concat !!incoming_directory "files"); |
|
|
Unix2.safe_mkdir (Filename.concat !!incoming_directory "directories"); |
|
|
*) |
|
362 |
|
|
363 |
List.iter (fun s -> |
List.iter (fun s -> |
364 |
Unix2.safe_mkdir s.shdir_dirname; |
Unix2.safe_mkdir s.shdir_dirname; |
483 |
(if !!gui_bind_addr = Ip.any then "127.0.0.1" |
(if !!gui_bind_addr = Ip.any then "127.0.0.1" |
484 |
else Ip.to_string !!gui_bind_addr) !!gui_port; |
else Ip.to_string !!gui_bind_addr) !!gui_port; |
485 |
lprintf_nl (_b "If you connect from a remote machine adjust allowed_ips"); |
lprintf_nl (_b "If you connect from a remote machine adjust allowed_ips"); |
486 |
if Autoconf.system = "windows" then lprintf (_b "%s") win_message; |
if Autoconf.system = "windows" && not !keep_console_output then lprintf (_b "%s") win_message; |
487 |
|
|
488 |
if Autoconf.system <> "windows" then |
if Autoconf.system <> "windows" then |
489 |
(* Doesn't work on windows with mingw, because getpid always returns 948 *) |
(* Doesn't work on windows with mingw, because getpid always returns 948 *) |
616 |
lprintf_nl (_b "Core stopped") |
lprintf_nl (_b "Core stopped") |
617 |
); |
); |
618 |
|
|
619 |
if not !keep_console_output then begin |
if not !keep_console_output then |
620 |
lprintf_nl (_b "Disabling output to console, to enable: stdout true"); |
if !!log_file = "" then |
621 |
|
begin |
622 |
if !!log_file <> "" then begin |
lprintf_nl (_b "Option log_file is empty, disable logging completely..."); |
623 |
(* |
lprintf_nl (_b "Disabling output to console, to enable: stdout true"); |
624 |
try |
log_to_file stdout; |
625 |
Printf.printf "+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+\n"; |
close_log () |
626 |
let oc = open_out !!log_file in |
end |
|
lprintf "Logging in %s\n" !!log_file; |
|
|
|
|
|
(* Don't close stdout !!! |
|
|
(match !lprintf_output with |
|
|
None -> () | Some oc -> close_out oc); |
|
|
*) |
|
|
log_to_file oc; |
|
|
lprintf "Start log in %s\n" !!log_file; |
|
|
with e -> |
|
|
lprintf "Exception %s while opening log file: %s\n" |
|
|
(Printexc2.to_string e) !!log_file *) |
|
|
() |
|
|
end else |
|
|
close_log () |
|
|
end |
|