25 #define lsb_metadata_template \ 26 "<?xml version='1.0'?>\n" \ 27 "<!DOCTYPE resource-agent SYSTEM 'ra-api-1.dtd'>\n" \ 28 "<resource-agent name='%s' version='" PCMK_DEFAULT_AGENT_VERSION "'>\n" \ 29 " <version>1.0</version>\n" \ 30 " <longdesc lang='en'>\n" \ 33 " <shortdesc lang='en'>%s</shortdesc>\n" \ 37 " <action name='meta-data' timeout='5' />\n" \ 38 " <action name='start' timeout='15' />\n" \ 39 " <action name='stop' timeout='15' />\n" \ 40 " <action name='status' timeout='15' />\n" \ 41 " <action name='restart' timeout='15' />\n" \ 42 " <action name='force-reload' timeout='15' />\n" \ 43 " <action name='monitor' timeout='15' interval='15' />\n" \ 45 " <special tag='LSB'>\n" \ 46 " <Provides>%s</Provides>\n" \ 47 " <Required-Start>%s</Required-Start>\n" \ 48 " <Required-Stop>%s</Required-Stop>\n" \ 49 " <Should-Start>%s</Should-Start>\n" \ 50 " <Should-Stop>%s</Should-Stop>\n" \ 51 " <Default-Start>%s</Default-Start>\n" \ 52 " <Default-Stop>%s</Default-Stop>\n" \ 59 #define LSB_INITSCRIPT_INFOBEGIN_TAG "### BEGIN INIT INFO" 60 #define LSB_INITSCRIPT_INFOEND_TAG "### END INIT INFO" 61 #define PROVIDES "# Provides:" 62 #define REQ_START "# Required-Start:" 63 #define REQ_STOP "# Required-Stop:" 64 #define SHLD_START "# Should-Start:" 65 #define SHLD_STOP "# Should-Stop:" 66 #define DFLT_START "# Default-Start:" 67 #define DFLT_STOP "# Default-Stop:" 68 #define SHORT_DSCR "# Short-Description:" 69 #define DESCRIPTION "# Description:" 71 #define lsb_meta_helper_free_value(m) \ 89 static inline gboolean
90 lsb_meta_helper_get_value(
const char *line,
char **value,
const char *prefix)
93 *value = (
char *)xmlEncodeEntitiesReentrant(NULL, BAD_CAST line+strlen(prefix));
102 char ra_pathname[PATH_MAX] = { 0, };
104 char buffer[1024] = { 0, };
105 char *provides = NULL;
106 char *req_start = NULL;
107 char *req_stop = NULL;
108 char *shld_start = NULL;
109 char *shld_stop = NULL;
110 char *dflt_start = NULL;
111 char *dflt_stop = NULL;
112 char *s_dscrpt = NULL;
113 char *xml_l_dscrpt = NULL;
114 bool in_header = FALSE;
116 if (
type[0] ==
'/') {
117 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s",
type);
119 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s/%s",
123 crm_trace(
"Looking into %s", ra_pathname);
124 fp = fopen(ra_pathname,
"r");
130 while (fgets(buffer,
sizeof(buffer), fp)) {
142 if (lsb_meta_helper_get_value(buffer, &provides,
PROVIDES)) {
145 if (lsb_meta_helper_get_value(buffer, &req_start,
REQ_START)) {
148 if (lsb_meta_helper_get_value(buffer, &req_stop,
REQ_STOP)) {
151 if (lsb_meta_helper_get_value(buffer, &shld_start,
SHLD_START)) {
154 if (lsb_meta_helper_get_value(buffer, &shld_stop,
SHLD_STOP)) {
157 if (lsb_meta_helper_get_value(buffer, &dflt_start,
DFLT_START)) {
160 if (lsb_meta_helper_get_value(buffer, &dflt_stop,
DFLT_STOP)) {
163 if (lsb_meta_helper_get_value(buffer, &s_dscrpt,
SHORT_DSCR)) {
168 if ((xml_l_dscrpt == NULL)
170 bool processed_line = TRUE;
171 GString *desc = g_string_sized_new(2048);
174 g_string_append(desc, buffer +
sizeof(
DESCRIPTION) - 1);
178 while (fgets(buffer,
sizeof(buffer), fp)) {
184 g_string_append(desc, buffer + 1);
189 processed_line = FALSE;
196 (
char *) xmlEncodeEntitiesReentrant(NULL,
198 g_string_free(desc, TRUE);
200 if (processed_line) {
210 if (buffer[0] !=
'#') {
217 (xml_l_dscrpt? xml_l_dscrpt :
type),
218 (s_dscrpt? s_dscrpt :
type),
219 (provides? provides :
""),
220 (req_start? req_start :
""),
221 (req_stop? req_stop :
""),
222 (shld_start? shld_start :
""),
223 (shld_stop? shld_stop :
""),
224 (dflt_start? dflt_start :
""),
225 (dflt_stop? dflt_stop :
""));
238 (
unsigned long long) strlen(*output));
255 rc = (stat(
path, &
st) == 0);
301 switch (exit_status) {
328 guint interval_ms,
int timeout)
ocf_exitcode
Exit status codes for resource agents.
#define LSB_INITSCRIPT_INFOEND_TAG
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
#define lsb_meta_helper_free_value(m)
int services__get_lsb_metadata(const char *type, char **output)
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.
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
const xmlChar * pcmkXmlStr
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)