diff --git a/crm/crmd/Makefile.am b/crm/crmd/Makefile.am index 5037f6beae..2f54eda3cd 100644 --- a/crm/crmd/Makefile.am +++ b/crm/crmd/Makefile.am @@ -1,98 +1,122 @@ # # Copyright (C) 2004 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ -I$(top_builddir) -I$(top_srcdir) +EXTRA_DIST = version.h + hadir = $(sysconfdir)/ha.d halibdir = $(libdir)/@HB_PKG@ commmoddir = $(halibdir)/modules/comm havarlibdir = $(localstatedir)/lib/@HB_PKG@ # sockets with path crmdir = $(havarlibdir)/crm apigid = @HA_APIGID@ crmuid = @HA_CCMUID@ COMMONLIBS = $(CRM_DEBUG_LIBS) \ $(top_builddir)/lib/clplumbing/libplumb.la \ $(top_builddir)/lib/pils/libpils.la \ $(top_builddir)/lib/crm/common/libcrmcommon.la \ $(top_builddir)/lib/crm/pengine/libpe_rules.la \ $(top_builddir)/lib/crm/cib/libcib.la \ $(top_builddir)/lib/apphb/libapphb.la \ $(top_builddir)/lib/hbclient/libhbclient.la \ $(GLIBLIB) \ $(LIBRT) LIBRT = @LIBRT@ AM_CFLAGS = @CFLAGS@ \ $(CRM_DEBUG_FLAGS) ## libraries lib_LTLIBRARIES = ## binary progs halib_PROGRAMS = crmd atest ## SOURCES noinst_HEADERS = crmd.h crmd_fsa.h crmd_messages.h fsa_defines.h \ fsa_matrix.h fsa_proto.h crmd_utils.h crmd_callbacks.h \ - crmd_lrm.h + crmd_lrm.h version.h atest_SOURCES = atest.c atest_CFLAGS = -DHA_VARLIBDIR='"@HA_VARLIBDIR@"' atest_LDADD = $(COMMONLIBS) crmd_SOURCES = main.c crmd.c \ fsa.c control.c messages.c ccm.c callbacks.c \ election.c join_client.c join_dc.c subsystems.c \ cib.c pengine.c tengine.c lrm.c \ utils.c misc.c crmd_CFLAGS = -DHA_VARLIBDIR='"@HA_VARLIBDIR@"' crmd_LDADD = $(COMMONLIBS) \ $(top_builddir)/lib/lrm/liblrm.la \ $(top_builddir)/membership/ccm/libccmclient.la # Simple HA client app #clnt_SOURCES = clnt.c #clnt_CFLAGS = $(XML_FLAGS) -DHA_VARLIBDIR='"@HA_VARLIBDIR@"' #clnt_LDFLAGS = $(XML_LIBS) #clnt_LDADD = $(COMMONLIBS) clean-generic: rm -f *.log *.debug *.xml *~ install-exec-local: uninstall-local: graphs: fsa_inputs.png fsa_inputs_by_action.png fsa_actions_by_state.png %.png: %.dot dot -Tpng $< > $@ %.dot : fsa_matrix.h perl make_dot.pl + +version.h: version + +VERSION_FILE="$(top_builddir)/crm/crmd/version.h" +CRM_HG_VERSION=$(shell hg -R $(top_srcdir) id | tr ' ' ':') +CRM_NOW_VERSION=$(shell test -f $(VERSION_FILE) && head -n 1 $(VERSION_FILE)) + +version: + if [ "x$(CRM_HG_VERSION)" = "x" -a "x$(CRM_NOW_VERSION)" = "x" ]; then \ + echo "Unknown CRM version"; \ + echo "/* unknown */" > $(VERSION_FILE); \ + echo "#define CRM_HG_VERSION \"unknown\"" >> $(VERSION_FILE); \ + elif [ "x$(CRM_HG_VERSION)" = "x" ]; then \ + echo "Exported CRM version correct: $(CRM_NOW_VERSION)"; \ + elif [ "/* $(CRM_HG_VERSION) */" = "$(CRM_NOW_VERSION)" ]; then \ + echo "CRM version correct: $(CRM_NOW_VERSION)"; \ + else \ + echo "Updating CRM version"; \ + echo "/* $(CRM_HG_VERSION) */" > $(VERSION_FILE); \ + echo "#define CRM_HG_VERSION \"$(CRM_HG_VERSION)\"" >> $(VERSION_FILE); \ + fi + diff --git a/crm/crmd/main.c b/crm/crmd/main.c index 9c491f76f9..3a76e5bad4 100644 --- a/crm/crmd/main.c +++ b/crm/crmd/main.c @@ -1,194 +1,199 @@ /* $Id: main.c,v 1.21 2006/08/14 09:06:31 andrew Exp $ */ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include #include const char* crm_system_name = SYS_NAME; #define OPTARGS "hV" void usage(const char* cmd, int exit_status); int init_start(void); void crmd_hamsg_callback(const HA_Message * msg, void* private_data); gboolean crmd_tickle_apphb(gpointer data); extern void init_dotfile(void); GMainLoop* crmd_mainloop = NULL; int main(int argc, char ** argv) { int flag; int argerr = 0; crm_log_init(crm_system_name); + crm_info("CRM Hg Version: %s\n", CRM_HG_VERSION); + while ((flag = getopt(argc, argv, OPTARGS)) != EOF) { switch(flag) { case 'V': cl_log_enable_stderr(1); alter_debug(DEBUG_INC); break; case 'h': /* Help message */ usage(crm_system_name, LSB_EXIT_OK); break; default: ++argerr; break; } } if(argc - optind == 1 && safe_str_eq("metadata", argv[optind])) { crmd_metadata(); return 0; + } else if(argc - optind == 1 && safe_str_eq("version", argv[optind])) { + fprintf(stderr, "CRM Version: "); + fprintf(stdout, "%s (%s)\n", CRM_FEATURE_SET, CRM_HG_VERSION); + return 0; } if (optind > argc) { ++argerr; } if (argerr) { usage(crm_system_name,LSB_EXIT_GENERIC); } /* read local config file */ crm_debug_3("Enabling coredumps"); if(cl_enable_coredumps(1) != 0) { crm_warn("Cannot enable coredumps"); } return init_start(); } int init_start(void) { int exit_code = 0; enum crmd_fsa_state state; fsa_state = S_STARTING; fsa_input_register = 0; /* zero out the regester */ init_dotfile(); crm_info("Starting %s", crm_system_name); register_fsa_input(C_STARTUP, I_STARTUP, NULL); state = s_crmd_fsa(C_STARTUP); if (state == S_PENDING || state == S_STARTING) { /* Create the mainloop and run it... */ crmd_mainloop = g_main_new(FALSE); crm_info("Starting %s's mainloop", crm_system_name); #ifdef REALTIME_SUPPORT static int crm_realtime = 1; if (crm_realtime == 1){ cl_enable_realtime(); }else if (crm_realtime == 0){ cl_disable_realtime(); } cl_make_realtime(SCHED_RR, 5, 64, 64); #endif g_main_run(crmd_mainloop); return_to_orig_privs(); if(is_set(fsa_input_register, R_STAYDOWN)) { crm_info("Inhibiting respawn by Heartbeat"); exit_code = 100; } } else { crm_err("Startup of %s failed. Current state: %s", crm_system_name, fsa_state2string(state)); exit_code = 1; } crm_info("[%s] stopped (%d)", crm_system_name, exit_code); return exit_code; } void usage(const char* cmd, int exit_status) { FILE* stream; stream = exit_status ? stderr : stdout; - fprintf(stream, "usage: %s [-srkh]" - "[-c configure file]\n", cmd); -/* fprintf(stream, "\t-d\tsets debug level\n"); */ -/* fprintf(stream, "\t-s\tgets daemon status\n"); */ -/* fprintf(stream, "\t-r\trestarts daemon\n"); */ -/* fprintf(stream, "\t-k\tstops daemon\n"); */ -/* fprintf(stream, "\t-h\thelp message\n"); */ + fprintf(stream, "usage: %s [-V] [-h|version|metadata]\n", cmd); + fprintf(stream, "\t-h\t: this help message\n"); + fprintf(stream, "\t-V\t: increase verbosity\n"); + fprintf(stream, "\tmetadata\t: show configurable crmd options\n"); + fprintf(stream, "\tversion\t\t: show version information and quit\n"); fflush(stream); exit(exit_status); } gboolean crmd_tickle_apphb(gpointer data) { char app_instance[APPNAME_LEN]; int rc = 0; sprintf(app_instance, "%s_%ld", crm_system_name, (long)getpid()); rc = apphb_hb(); if (rc < 0) { cl_perror("%s apphb_hb failure", app_instance); exit(3); } return TRUE; }