function build() { checkdb(); patch_config_sh(); patch_bavd(); }
function build() { @unlink("/etc/greyhole.conf"); if (!checkdb()) { echo "Starting......: " . date("H:i:s") . " Checking database failed\n"; return; } @mkdir("/var/spool/greyhole", 0777, true); shell_exec("/bin/chmod 777 /var/spool/greyhole >/dev/null 2>&1"); $sock = new sockets(); $EnableGreyHoleDebug = $sock->GET_INFO("EnableGreyHoleDebug"); if (!is_numeric($EnableGreyHoleDebug)) { $EnableGreyHoleDebug = 0; } if ($EnableGreyHoleDebug == 1) { $DEBUG = "DEBUG"; } else { $DEBUG = "INFO"; } echo "Starting......: " . date("H:i:s") . " greyhole verbosity {$DEBUG}\n"; $unix = new unix(); $q = new mysql(); $f[] = "db_engine = mysql"; $f[] = "db_host = {$q->mysql_server}"; $f[] = "db_user = {$q->mysql_admin}"; $f[] = "db_pass = {$q->mysql_password}"; $f[] = "db_name = greyhole"; $f[] = "email_to = root"; $f[] = "greyhole_log_file = /var/log/greyhole.log"; $f[] = "log_level = {$DEBUG}"; $f[] = "log_memory_usage = no"; $f[] = "df_cache_time = 15"; $f[] = "balance_modified_files = no"; $f[] = "check_for_open_files = yes"; $f[] = "max_queued_tasks = 100000"; $f[] = "dir_selection_algorithm = most_available_space"; $touch = $unix->find_program("touch"); $sql = "SELECT * FROM greyhole_spools ORDER BY free_g DESC"; $results = $q->QUERY_SQL($sql, "artica_backup"); $autofs = new autofs(); $hash = $autofs->automounts_Browse(); if (!$q->ok) { echo $q->mysql_error; @file_put_contents("/etc/greyhole.conf", "#"); } $count = mysql_num_rows($results); if ($count == 0) { echo "Starting......: " . date("H:i:s") . " greyhole no pool defined\n"; return; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $array = $autofs->hash_by_dn[$ligne["dn"]]; $FOLDER = $array["FOLDER"]; $size = $ligne["free_g"]; echo "Starting......: " . date("H:i:s") . " greyhole storage pool directory {$FOLDER} min_free: {$size}gb\n"; $f[] = "storage_pool_directory = /automounts/{$FOLDER}, min_free: {$size}gb"; if (!is_file("/automounts/{$FOLDER}/.greyhole_uses_this")) { @file_put_contents("/automounts/{$FOLDER}/.greyhole_uses_this", "#"); } } $sql = "SELECT * FROM `greyhole_dirs` WHERE num_copies > 0"; $results = $q->QUERY_SQL($sql, "artica_backup"); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { echo "Starting......: " . date("H:i:s") . " greyhole {$ligne["shared_dir"]} with {$ligne["num_copies"]} num_copies\n"; $f[] = "num_copies[{$ligne["shared_dir"]}] = {$ligne["num_copies"]}"; } $unix = new unix(); $modprobe = $unix->find_program("modprobe"); shell_exec("{$modprobe} cifs >/dev/null 2>&1"); @file_put_contents("/proc/fs/cifs/OplockEnabled", "0"); @file_put_contents("/etc/greyhole.conf", @implode("\n", $f)); }