27 #define lsb_metadata_template \ 28 "<?xml " PCMK_XA_VERSION "='1.0'?>\n" \ 29 "<" PCMK_XE_RESOURCE_AGENT " " \ 30 PCMK_XA_NAME "='%s' " \ 31 PCMK_XA_VERSION "='" PCMK_DEFAULT_AGENT_VERSION "'>\n" \ 32 " <" PCMK_XE_VERSION ">1.1</" PCMK_XE_VERSION ">\n" \ 33 " <" PCMK_XE_LONGDESC " " PCMK_XA_LANG "='" PCMK__VALUE_EN "'>\n" \ 35 " </" PCMK_XE_LONGDESC ">\n" \ 36 " <" PCMK_XE_SHORTDESC " " PCMK_XA_LANG "='" PCMK__VALUE_EN "'>" \ 38 "</" PCMK_XE_SHORTDESC ">\n" \ 39 " <" PCMK_XE_PARAMETERS "/>\n" \ 40 " <" PCMK_XE_ACTIONS ">\n" \ 41 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_META_DATA "'" \ 42 " " PCMK_META_TIMEOUT "='5s' />\n" \ 43 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_START "'" \ 44 " " PCMK_META_TIMEOUT "='15s' />\n" \ 45 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_STOP "'" \ 46 " " PCMK_META_TIMEOUT "='15s' />\n" \ 47 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_STATUS "'" \ 48 " " PCMK_META_TIMEOUT "='15s' />\n" \ 49 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='restart'" \ 50 " " PCMK_META_TIMEOUT "='15s' />\n" \ 51 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='force-reload'" \ 52 " " PCMK_META_TIMEOUT "='15s' />\n" \ 53 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "'" \ 54 " " PCMK_META_TIMEOUT "='15s'" \ 55 " " PCMK_META_INTERVAL "='15s' />\n" \ 56 " </" PCMK_XE_ACTIONS ">\n" \ 57 " <" PCMK_XE_SPECIAL " " PCMK_XA_TAG "='LSB'>\n" \ 58 " <Provides>%s</Provides>\n" \ 59 " <Required-Start>%s</Required-Start>\n" \ 60 " <Required-Stop>%s</Required-Stop>\n" \ 61 " <Should-Start>%s</Should-Start>\n" \ 62 " <Should-Stop>%s</Should-Stop>\n" \ 63 " <Default-Start>%s</Default-Start>\n" \ 64 " <Default-Stop>%s</Default-Stop>\n" \ 65 " </" PCMK_XE_SPECIAL ">\n" \ 66 "</" PCMK_XE_RESOURCE_AGENT ">\n" 71 #define LSB_INITSCRIPT_INFOBEGIN_TAG "### BEGIN INIT INFO" 72 #define LSB_INITSCRIPT_INFOEND_TAG "### END INIT INFO" 73 #define PROVIDES "# Provides:" 74 #define REQUIRED_START "# Required-Start:" 75 #define REQUIRED_STOP "# Required-Stop:" 76 #define SHOULD_START "# Should-Start:" 77 #define SHOULD_STOP "# Should-Stop:" 78 #define DEFAULT_START "# Default-Start:" 79 #define DEFAULT_STOP "# Default-Stop:" 80 #define SHORT_DESC "# Short-Description:" 81 #define DESCRIPTION "# Description:" 93 static inline gboolean
94 lsb_meta_helper_get_value(
const char *line, gchar **value,
const char *prefix)
109 char ra_pathname[PATH_MAX] = { 0, };
111 char buffer[1024] = { 0, };
112 gchar *provides = NULL;
113 gchar *required_start = NULL;
114 gchar *required_stop = NULL;
115 gchar *should_start = NULL;
116 gchar *should_stop = NULL;
117 gchar *default_start = NULL;
118 gchar *default_stop = NULL;
119 gchar *short_desc = NULL;
120 gchar *long_desc = NULL;
121 bool in_header = FALSE;
123 if (
type[0] ==
'/') {
124 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s",
type);
126 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s/%s",
130 crm_trace(
"Looking into %s", ra_pathname);
131 fp = fopen(ra_pathname,
"r");
137 while (fgets(buffer,
sizeof(buffer), fp)) {
149 if (lsb_meta_helper_get_value(buffer, &provides,
PROVIDES)) {
152 if (lsb_meta_helper_get_value(buffer, &required_start,
156 if (lsb_meta_helper_get_value(buffer, &required_stop,
REQUIRED_STOP)) {
159 if (lsb_meta_helper_get_value(buffer, &should_start,
SHOULD_START)) {
162 if (lsb_meta_helper_get_value(buffer, &should_stop,
SHOULD_STOP)) {
165 if (lsb_meta_helper_get_value(buffer, &default_start,
DEFAULT_START)) {
168 if (lsb_meta_helper_get_value(buffer, &default_stop,
DEFAULT_STOP)) {
171 if (lsb_meta_helper_get_value(buffer, &short_desc,
SHORT_DESC)) {
176 if ((long_desc == NULL)
178 bool processed_line = TRUE;
179 GString *desc = g_string_sized_new(2048);
182 g_string_append(desc, buffer +
sizeof(
DESCRIPTION) - 1);
186 while (fgets(buffer,
sizeof(buffer), fp)) {
192 g_string_append(desc, buffer + 1);
197 processed_line = FALSE;
204 g_string_free(desc, TRUE);
206 if (processed_line) {
216 if (buffer[0] !=
'#') {
223 pcmk__s(long_desc,
type),
224 pcmk__s(short_desc,
type),
225 pcmk__s(provides,
""),
226 pcmk__s(required_start,
""),
227 pcmk__s(required_stop,
""),
228 pcmk__s(should_start,
""),
229 pcmk__s(should_stop,
""),
230 pcmk__s(default_start,
""),
231 pcmk__s(default_stop,
""));
236 g_free(required_start);
237 g_free(required_stop);
238 g_free(should_start);
240 g_free(default_start);
241 g_free(default_stop);
258 rc = (stat(
path, &
st) == 0);
305 switch (exit_status) {
332 guint interval_ms,
int timeout)
ocf_exitcode
Exit status codes for resource agents.
char * pcmk__xml_escape(const char *text, enum pcmk__xml_escape_type type)
#define LSB_INITSCRIPT_INFOEND_TAG
#define PCMK_ACTION_MONITOR
GList * services_os_get_directory_list(const char *root, gboolean files, gboolean executable)
svc_action_t * resources_action_create(const char *name, const char *standard, const char *provider, const char *agent, const char *action, guint interval_ms, int timeout, GHashTable *params, enum svc_action_flags flags)
Create a new resource action.
enum crm_ais_msg_types type
int services__get_lsb_metadata(const char *type, char **output)
#define PCMK_ACTION_STATUS
GList * services__list_lsb_agents(void)
svc_action_private_t * opaque
This field should be treated as internal to Pacemaker.
svc_action_t * services_action_create(const char *name, const char *action, guint interval_ms, int timeout)
#define crm_trace(fmt, args...)
#define LSB_INITSCRIPT_INFOBEGIN_TAG
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
Object for executing external actions.
char * agent
Resource agent name for resource actions, otherwise NULL.
Wrappers for and extensions to libxml2.
int services__lsb_prepare(svc_action_t *op)
char * pcmk__full_path(const char *filename, const char *dirname)
Duplicate a file path, inserting a prefix if not absolute.
Dependencies not available locally.
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
enum ocf_exitcode services__lsb2ocf(const char *action, int exit_status)
char * action
Name of action being executed for resource actions, otherwise NULL.
#define PCMK__LSB_INIT_DIR
GList * services_list(void)
#define PCMK_RESOURCE_CLASS_LSB
#define lsb_metadata_template
GList * resources_list_agents(const char *standard, const char *provider)
Get a list of resource agents.
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
bool services__lsb_agent_exists(const char *agent)