23 #define lsb_metadata_template \ 24 "<?xml " PCMK_XA_VERSION "='1.0'?>\n" \ 25 "<" PCMK_XE_RESOURCE_AGENT " " \ 26 PCMK_XA_NAME "='%s' " \ 27 PCMK_XA_VERSION "='" PCMK_DEFAULT_AGENT_VERSION "'>\n" \ 28 " <" PCMK_XE_VERSION ">1.1</" PCMK_XE_VERSION ">\n" \ 29 " <" PCMK_XE_LONGDESC " " PCMK_XA_LANG "='" PCMK__VALUE_EN "'>\n" \ 31 " </" PCMK_XE_LONGDESC ">\n" \ 32 " <" PCMK_XE_SHORTDESC " " PCMK_XA_LANG "='" PCMK__VALUE_EN "'>" \ 34 "</" PCMK_XE_SHORTDESC ">\n" \ 35 " <" PCMK_XE_PARAMETERS "/>\n" \ 36 " <" PCMK_XE_ACTIONS ">\n" \ 37 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_META_DATA "'" \ 38 " " PCMK_META_TIMEOUT "='5s' />\n" \ 39 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_START "'" \ 40 " " PCMK_META_TIMEOUT "='15s' />\n" \ 41 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_STOP "'" \ 42 " " PCMK_META_TIMEOUT "='15s' />\n" \ 43 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_STATUS "'" \ 44 " " PCMK_META_TIMEOUT "='15s' />\n" \ 45 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='restart'" \ 46 " " PCMK_META_TIMEOUT "='15s' />\n" \ 47 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='force-reload'" \ 48 " " PCMK_META_TIMEOUT "='15s' />\n" \ 49 " <" PCMK_XE_ACTION " " PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "'" \ 50 " " PCMK_META_TIMEOUT "='15s'" \ 51 " " PCMK_META_INTERVAL "='15s' />\n" \ 52 " </" PCMK_XE_ACTIONS ">\n" \ 53 " <" PCMK_XE_SPECIAL " " PCMK_XA_TAG "='LSB'>\n" \ 54 " <Provides>%s</Provides>\n" \ 55 " <Required-Start>%s</Required-Start>\n" \ 56 " <Required-Stop>%s</Required-Stop>\n" \ 57 " <Should-Start>%s</Should-Start>\n" \ 58 " <Should-Stop>%s</Should-Stop>\n" \ 59 " <Default-Start>%s</Default-Start>\n" \ 60 " <Default-Stop>%s</Default-Stop>\n" \ 61 " </" PCMK_XE_SPECIAL ">\n" \ 62 "</" PCMK_XE_RESOURCE_AGENT ">\n" 67 #define LSB_INITSCRIPT_INFOBEGIN_TAG "### BEGIN INIT INFO" 68 #define LSB_INITSCRIPT_INFOEND_TAG "### END INIT INFO" 69 #define PROVIDES "# Provides:" 70 #define REQUIRED_START "# Required-Start:" 71 #define REQUIRED_STOP "# Required-Stop:" 72 #define SHOULD_START "# Should-Start:" 73 #define SHOULD_STOP "# Should-Stop:" 74 #define DEFAULT_START "# Default-Start:" 75 #define DEFAULT_STOP "# Default-Stop:" 76 #define SHORT_DESC "# Short-Description:" 77 #define DESCRIPTION "# Description:" 89 static inline gboolean
90 lsb_meta_helper_get_value(
const char *line, gchar **value,
const char *prefix)
105 char ra_pathname[PATH_MAX] = { 0, };
107 char buffer[1024] = { 0, };
108 gchar *provides = NULL;
109 gchar *required_start = NULL;
110 gchar *required_stop = NULL;
111 gchar *should_start = NULL;
112 gchar *should_stop = NULL;
113 gchar *default_start = NULL;
114 gchar *default_stop = NULL;
115 gchar *short_desc = NULL;
116 gchar *long_desc = NULL;
117 bool in_header = FALSE;
119 if (
type[0] ==
'/') {
120 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s",
type);
122 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s/%s",
126 crm_trace(
"Looking into %s", ra_pathname);
127 fp = fopen(ra_pathname,
"r");
133 while (fgets(buffer,
sizeof(buffer), fp)) {
145 if (lsb_meta_helper_get_value(buffer, &provides,
PROVIDES)) {
148 if (lsb_meta_helper_get_value(buffer, &required_start,
152 if (lsb_meta_helper_get_value(buffer, &required_stop,
REQUIRED_STOP)) {
155 if (lsb_meta_helper_get_value(buffer, &should_start,
SHOULD_START)) {
158 if (lsb_meta_helper_get_value(buffer, &should_stop,
SHOULD_STOP)) {
161 if (lsb_meta_helper_get_value(buffer, &default_start,
DEFAULT_START)) {
164 if (lsb_meta_helper_get_value(buffer, &default_stop,
DEFAULT_STOP)) {
167 if (lsb_meta_helper_get_value(buffer, &short_desc,
SHORT_DESC)) {
172 if ((long_desc == NULL)
174 bool processed_line = TRUE;
175 GString *desc = g_string_sized_new(2048);
178 g_string_append(desc, buffer +
sizeof(
DESCRIPTION) - 1);
182 while (fgets(buffer,
sizeof(buffer), fp)) {
188 g_string_append(desc, buffer + 1);
193 processed_line = FALSE;
200 g_string_free(desc, TRUE);
202 if (processed_line) {
212 if (buffer[0] !=
'#') {
219 pcmk__s(long_desc,
type),
220 pcmk__s(short_desc,
type),
221 pcmk__s(provides,
""),
222 pcmk__s(required_start,
""),
223 pcmk__s(required_stop,
""),
224 pcmk__s(should_start,
""),
225 pcmk__s(should_stop,
""),
226 pcmk__s(default_start,
""),
227 pcmk__s(default_stop,
""));
232 g_free(required_start);
233 g_free(required_stop);
234 g_free(should_start);
236 g_free(default_start);
237 g_free(default_stop);
254 rc = (stat(
path, &
st) == 0);
301 switch (exit_status) {
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
enum pcmk_ipc_server type
#define PCMK_ACTION_MONITOR
GList * services_os_get_directory_list(const char *root, gboolean files, gboolean executable)
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.
#define crm_trace(fmt, args...)
#define LSB_INITSCRIPT_INFOBEGIN_TAG
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
#define lsb_metadata_template
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)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1