if (mysql_running() && get_mysql_tracker() == 'program') { // not a service print " MySQL currently running as a standard program.\n"; } if (mysql_running() && get_mysql_tracker() == 'service') { // Server running as a service echo " Stopping MySQL Service {$us_mysql_service_name} ...\n"; // Inform user echo " UnInstalling MySQL Service {$us_mysql_service_name} ...\n"; stop_mysql_service(); // Stop MySQL service uninstall_mysql_service(); // Remove service $no_mysql_service = false; } if (!mysql_running() && get_mysql_tracker() == 'service') { // Server running as a service echo " MySQL service {$us_mysql_service_name} was not running\n"; // Inform user echo " UnInstalling MySQL Service {$us_mysql_service_name} ...\n"; uninstall_mysql_service(); // Remove service $no_mysql_service = false; } if ($no_mysql_service) { print " MySQL is not installed as a service\n"; } } else { //User has not enabled this in config.inc.php print " MySQL service not enabled in config.inc.php\n"; }
print " Apache SSL port = " . get_apache_ssl_port() . " In use by this server\n"; } if (!apache_running() && get_apache_tracker() != "free" && ssl_enabled()) { print " Apache SSL port = " . get_apache_ssl_port() . " Undefined!\n"; } if (!apache_running() && get_apache_tracker() != "free" && !ssl_enabled()) { print " Apache SSL port = " . get_apache_ssl_port() . " Undefined!\n"; } if (apache_running() && get_apache_tracker() != "free" && !ssl_enabled()) { print " Apache SSL port = " . get_apache_ssl_port() . " SSL Not enabled free to use\n"; } if (port_in_use(get_apache_ssl_port()) && get_apache_tracker() == "free") { print " Apache SSL port = " . get_apache_ssl_port() . " In use by another program.\n"; } if (!port_in_use(get_apache_ssl_port()) && get_apache_tracker() == "free") { print " Apache SSL port = " . get_apache_ssl_port() . " Is free to use\n"; } //=== MySQL port if (mysql_running() && get_mysql_tracker() != "free") { print " MySQL port = " . get_mysql_port() . " In use by this server\n"; } if (!mysql_running() && get_mysql_tracker() != "free") { print " MySQL port = " . get_mysql_port() . " Undefined!\n"; } if (port_in_use(get_mysql_port()) && get_mysql_tracker() == "free") { print " MySQL port = " . get_mysql_port() . " In use by another program.\n"; } if (!port_in_use(get_mysql_port()) && get_mysql_tracker() == "free") { print " MySQL port = " . get_mysql_port() . " Is free to use.\n"; } print "\n\n";
// Have servers moved if moved update configuration print "\n"; //=== If no parameters passed use defaults from config.inc.php if ($argc == 2) { // Was a parameter passed $server_operation = $argv[1]; // yes: } else { $server_operation = $server_service; // no: Use user default } // == RUN MYSQL SERVICE ======================================================= if ((int) $server_operation & 2) { // Server enabled by config or parameter // === Check server running if (mysql_running() && file_exists($usf_mysql_pid)) { if (get_mysql_tracker() == 'program') { // Server running as a standard program print " Unable to install MySQL service!\n MySQL Server is running as a standard program.\n"; } if (get_mysql_tracker() == 'service') { // Server running as a service print " MySQL Server already installed as a service.\n"; } } else { // server not running, we have a chance to run as a service if ports are free! //=== Port test ===== $mysql_port = get_mysql_port(); if (port_in_use($mysql_port)) { echo " MySQL port = " . $mysql_port . " - Failed port already in use!\n"; echo " Failed! To install MySQL service port must be free!\n";
// Default 3306 User Changeable $MYSQL_USER = '******'; // root user can access all DBs $MYSQL_PASSWD = get_mysql_password(); // Default root User Changeable //=== Set path variables $DB_BASE = "{$base_f}/db_backup"; // Main archive folder $DEST = "{$DB_BASE}/archive"; // Destiation for final archived dbs $log_file = "{$DB_BASE}/log.txt"; // Log file $TEMP = "{$base_f}/tmp/backup_temp"; // Temp location for archive creation //== Check MySQL is running if (!mysql_running()) { // Is MySQL running print " Unable to run backup script \n"; print " MySQL Server not running! \n\n"; // No: give up exit; } //=== Create folders if they do not exist if (!is_dir($DB_BASE)) { mkdir($DB_BASE) or die("Failed to create main destination folder"); } if (!is_dir($DEST)) { mkdir($DEST) or die("Failed to create destination sub-folder"); } if (!is_dir($TEMP)) { mkdir($TEMP) or die("Failed to create temp folder");
$status = get_mysql_tracker(); if (mysql_running() && $status == "service") { print " MySQL service running\n"; print " Stopping MySQL service\n"; stop_mysql_service(); } if (mysql_running() && $status == "program") { print " MySQL program running\n"; print " Killing MySQL program\n"; kill_mysql(); //Note kill not stop. Stop uses password } //=== Wait for server to stop ===================================== $safety_timer = 0; // Set timer while (mysql_running()) { // Check Apache started if ($safety_timer == 40) { // Has safety time been reached exit(1); // Exit with error code } $safety_timer = $safety_timer + 1; // update timer usleep(500000); // delay 0.5 sec and repeat } //=== Update password file ============== print " Password file restored to root\n"; $wfile = fopen($usf_mysql_passwd, 'w'); fwrite($wfile, "root");
if ((int) $server_operation & 2) { // Server enabled by config or parameter // === MySQL Service priority // Running as a servive takes priority. A user must uninstal the service to // run server in standard program mode. Even afeter a power failure a service // will restart. Requires no special power recovery hence a good reference point. if (get_mysql_tracker() == 'service') { // Is server running as a service print "\n Unable to start MySQL server!\n MySQL Server currently running as a service.\n"; } else { // Not running as a service $free_to_run = true; // Assume free to run Apache if (file_exists($usf_mysql_pid)) { // This MySQL has been started if (mysql_running()) { // Running cannot start another instance echo "\n This MySQL server is already running!\n"; // Inform user echo " You can stop the server using Stop_Server.bat\n"; // $free_to_run = false; } else { // Left over from either a power fail or user not unlink($usf_mysql_pid); // stopping servers before powering pc off hence detlete } } if ($free_to_run) { // Some other program could be using the ports hence port check // Port test