Home | History | Annotate | Download | only in apache
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the License).
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/CDDL.txt
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/CDDL.txt.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets [] replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 
     22 /*
     23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  *
     26  * apache_validate.c - validate method for highly available apache
     27  */
     28 
     29 #pragma ident	"@(#)apache_validate.c	1.23	07/06/06 SMI"
     30 
     31 #include <stdio.h>
     32 #include <locale.h>
     33 #include <libintl.h>
     34 #include <rgm/libdsdev.h>
     35 #include "apache.h"
     36 
     37 /*
     38  * Check to make sure that the properties have been set properly.
     39  */
     40 
     41 int
     42 main(int argc, char *argv[])
     43 {
     44 	scds_handle_t		scds_handle;
     45 	int			rc;
     46 
     47 	/* I18N stuff */
     48 	(void) setlocale(LC_ALL, "");
     49 	(void) textdomain(TEXT_DOMAIN);
     50 	(void) bindtextdomain(TEXT_DOMAIN, MESSAGE_DIR);
     51 
     52 	/* Process arguments passed by RGM and initialize syslog */
     53 	if ((rc = scds_initialize(&scds_handle, argc, argv)) !=
     54 			SCHA_ERR_NOERR) {
     55 		/*
     56 		 * SCMSGS
     57 		 * @explanation
     58 		 * Need explanation of this message!
     59 		 * @user_action
     60 		 * Need a user action for this message.
     61 		 */
     62 		scds_syslog(LOG_ERR, "Failed to retrieve the resource "
     63 			"handle: %s", scds_error_string(rc));
     64 		(void) fprintf(stderr, gettext("Failed to retrieve the "
     65 			"resource handle: %s\n"),
     66 			gettext(scds_error_string(rc)));
     67 		return (1);
     68 	}
     69 
     70 	rc = svc_validate(scds_handle, B_TRUE);
     71 	if (rc != SCHA_ERR_NOERR) {
     72 		scds_syslog(LOG_ERR, "Failed to validate configuration.");
     73 		(void) fprintf(stderr, gettext("Failed to validate "
     74 			"configuration.\n"));
     75 	} else
     76 		scds_syslog(LOG_INFO, "Completed successfully.");
     77 
     78 	/* Free up all the memory allocated by scds_initialize */
     79 	scds_close(&scds_handle);
     80 
     81 	/* Return the result of validate method */
     82 	return (rc);
     83 
     84 }
     85