示例#1
0
/*
 * verify_directories()
 *
 * does all the hectic work of verifying directories and executables
 * of old and new server.
 *
 * NOTE: May update the values of all parameters
 */
void
verify_directories(void)
{

	prep_status("Checking current, bin, and data directories");

	if (access(".", R_OK | W_OK
#ifndef WIN32

	/*
	 * Do a directory execute check only on Unix because execute permission on
	 * NTFS means "can execute scripts", which we don't care about. Also, X_OK
	 * is not defined in the Windows API.
	 */
			   | X_OK
#endif
			   ) != 0)
		pg_log(PG_FATAL,
		  "You must have read and write access in the current directory.\n");

	check_bin_dir(&old_cluster);
	check_data_dir(old_cluster.pgdata);
	check_bin_dir(&new_cluster);
	check_data_dir(new_cluster.pgdata);
	check_ok();
}
示例#2
0
/*
 * verify_directories()
 *
 * does all the hectic work of verifying directories and executables
 * of old and new server.
 *
 * NOTE: May update the values of all parameters
 */
void
verify_directories(void)
{
#ifndef WIN32
	if (access(".", R_OK | W_OK | X_OK) != 0)
#else
	if (win32_check_directory_write_permissions() != 0)
#endif
		pg_fatal("You must have read and write access in the current directory.\n");

	check_bin_dir(&old_cluster);
	check_data_dir(old_cluster.pgdata);
	check_bin_dir(&new_cluster);
	check_data_dir(new_cluster.pgdata);
}
示例#3
0
/*
 * verify_directories()
 *
 * does all the hectic work of verifying directories and executables
 * of old and new server.
 *
 * NOTE: May update the values of all parameters
 */
void
verify_directories(void)
{

	prep_status("Checking current, bin, and data directories");

#ifndef WIN32
	if (access(".", R_OK | W_OK | X_OK) != 0)
#else
	if (win32_check_directory_write_permissions() != 0)
#endif
		pg_log(PG_FATAL,
		  "You must have read and write access in the current directory.\n");

	check_bin_dir(&old_cluster);
	check_data_dir(old_cluster.pgdata);
	check_bin_dir(&new_cluster);
	check_data_dir(new_cluster.pgdata);
	check_ok();
}
示例#4
0
/*
 * verify_directories()
 *
 * does all the hectic work of verifying directories and executables
 * of old and new server.
 *
 * NOTE: May update the values of all parameters
 */
void
verify_directories(void)
{

	if (access(".", R_OK | W_OK | X_OK) != 0)
		pg_log(PG_FATAL,
		"You must have read and write access in the current directory.\n");

	prep_status("Checking old data directory (%s)", old_cluster.pgdata);
	check_data_dir(old_cluster.pgdata);
	check_ok();

	prep_status("Checking old bin directory (%s)", old_cluster.bindir);
	check_bin_dir(&old_cluster);
	check_ok();

	prep_status("Checking new data directory (%s)", new_cluster.pgdata);
	check_data_dir(new_cluster.pgdata);
	check_ok();

	prep_status("Checking new bin directory (%s)", new_cluster.bindir);
	check_bin_dir(&new_cluster);
	check_ok();
}
示例#5
0
文件: admind.c 项目: CloCkWeRX/4store
int main(int argc, char **argv)
{
    int rv;

    /* Set program name globally */
    program_invocation_name = argv[0];
    program_invocation_short_name = basename(argv[0]);

    /* Log to stderr until (and if) we daemonize */
    fsa_log_to = ADM_LOG_TO_STDERR;
    fsa_log_level = ADM_LOG_LEVEL;

    /* parse command line args/opts into globals */
    rv = parse_cmdline_opts(argc, argv);
    if (rv == -1) {
        return EXIT_FAILURE;
    }

    /* check if debugging output turned on */
    if (debug_flag) {
        fsa_log_level = LOG_DEBUG;
    }

    /* handle simple commands (help/version) */
    if (help_flag) {
        print_help();
        return EXIT_SUCCESS;
    }

    if (version_flag) {
        print_version();
        return EXIT_SUCCESS;
    }

    /* make sure a valid port number is set/specified */
    rv = init_server_port();
    if (rv == -1) {
        return EXIT_FAILURE;
    }

    /* check that bin dir exists and is readable */
    rv = check_bin_dir();
    if (rv == -1) {
        return EXIT_FAILURE;        
    }

    /* daemonize if needed */
    if (daemonize_flag) {
        daemonize();
    }

    /* set up server listening socket */
    rv = setup_server();
    if (rv == -1) {
        return EXIT_FAILURE;
    }

    if (daemonize_flag) {
        /* make info message a bit clearer in syslog */
        fsa_error(LOG_INFO, "%s started on port %s",
                  program_invocation_short_name, server_port);
    }
    else {
        fsa_error(LOG_INFO, "started on port %s", server_port);
    }

    /* handle client connections and requests */
    rv = server_loop();
    if (rv == -1) {
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}