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));
104 char ra_pathname[PATH_MAX] = { 0, };
106 char buffer[1024] = { 0, };
107 char *provides = NULL;
108 char *req_start = NULL;
109 char *req_stop = NULL;
110 char *shld_start = NULL;
111 char *shld_stop = NULL;
112 char *dflt_start = NULL;
113 char *dflt_stop = NULL;
114 char *s_dscrpt = NULL;
115 char *xml_l_dscrpt = NULL;
117 bool in_header = FALSE;
118 char description[
DESC_MAX] = { 0, };
120 if (
type[0] ==
'/') {
121 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s",
type);
123 snprintf(ra_pathname,
sizeof(ra_pathname),
"%s/%s",
127 crm_trace(
"Looking into %s", ra_pathname);
128 fp = fopen(ra_pathname,
"r");
134 while (fgets(buffer,
sizeof(buffer), fp)) {
146 if (lsb_meta_helper_get_value(buffer, &provides,
PROVIDES)) {
149 if (lsb_meta_helper_get_value(buffer, &req_start,
REQ_START)) {
152 if (lsb_meta_helper_get_value(buffer, &req_stop,
REQ_STOP)) {
155 if (lsb_meta_helper_get_value(buffer, &shld_start,
SHLD_START)) {
158 if (lsb_meta_helper_get_value(buffer, &shld_stop,
SHLD_STOP)) {
161 if (lsb_meta_helper_get_value(buffer, &dflt_start,
DFLT_START)) {
164 if (lsb_meta_helper_get_value(buffer, &dflt_stop,
DFLT_STOP)) {
167 if (lsb_meta_helper_get_value(buffer, &s_dscrpt,
SHORT_DSCR)) {
174 bool processed_line = TRUE;
177 offset += snprintf(description,
DESC_MAX,
"%s",
182 while (fgets(buffer,
sizeof(buffer), fp)) {
188 offset += snprintf(description + offset,
DESC_MAX - offset,
194 processed_line = FALSE;
200 xml_l_dscrpt = (
char *)xmlEncodeEntitiesReentrant(NULL, BAD_CAST(description));
202 if (processed_line) {
212 if (buffer[0] !=
'#') {
219 (xml_l_dscrpt? xml_l_dscrpt :
type),
220 (s_dscrpt? s_dscrpt :
type),
221 (provides? provides :
""),
222 (req_start? req_start :
""),
223 (req_stop? req_stop :
""),
224 (shld_start? shld_start :
""),
225 (shld_stop? shld_stop :
""),
226 (dflt_start? dflt_start :
""),
227 (dflt_stop? dflt_stop :
""));
240 (
unsigned long long) strlen(*output));
253 return (*agent ==
'/')? strdup(agent)
264 rc = (stat(path, &
st) == 0);
277 guint interval_ms,
int timeout)
#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
char * services__lsb_agent_path(const char *agent)
#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_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
#define PCMK_RESOURCE_CLASS_LSB
GList * services_list(void)
#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)