View | Details | Raw Unified | Return to bug 75345
Collapse All | Expand All

(-)./Makefile (-1 / +1 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=	${APP_TITLE:L}
8
PORTNAME=	${APP_TITLE:L}
9
PORTVERSION=	4.0.0
9
PORTVERSION=	4.0.0
10
PORTREVISION=	1
10
PORTREVISION=	2
11
CATEGORIES=	java
11
CATEGORIES=	java
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
13
MASTER_SITE_SUBDIR=	${PORTNAME}
13
MASTER_SITE_SUBDIR=	${PORTNAME}
(-)./files/daemonctl.c (-165 / +136 lines)
Lines 27-43 Link Here
27
#define	TRUE	1
27
#define	TRUE	1
28
#define	FALSE	0
28
#define	FALSE	0
29
29
30
/* The maximum size of the PID file, in bytes */
31
#define MAX_FILE_SIZE			32
32
33
/* The interval in seconds between the checks to make sure the process
30
/* The interval in seconds between the checks to make sure the process
34
   died after a kill */
31
   died after a kill */
35
#define STOP_TIME_INTERVAL		1
32
#define STOP_TIME_INTERVAL		1
36
33
37
#define ERR_ILLEGAL_ARGUMENT				1
34
#define ERR_ILLEGAL_ARGUMENT				1
38
#define ERR_PID_FILE_NOT_FOUND				2
35
#define ERR_PID_FILE_NOT_FOUND				2
39
#define ERR_PID_FILE_TOO_LARGE				3
40
#define ERR_PID_FILE_CONTAINS_ILLEGAL_CHAR	4
41
#define ERR_KILL_FAILED						5
36
#define ERR_KILL_FAILED						5
42
#define ERR_ALREADY_RUNNING					6
37
#define ERR_ALREADY_RUNNING					6
43
#define ERR_NOT_RUNNING						7
38
#define ERR_NOT_RUNNING						7
Lines 56-73 Link Here
56
	Function declarations.
51
	Function declarations.
57
 */
52
 */
58
static void printUsage (void);
53
static void printUsage (void);
59
static int openPIDFile (void);
54
static int readPID (void);
60
static int readPID (int);
55
static void writePID (int pid);
61
static void writePID (int file, int pid);
56
static void clearPID (void);
62
static void start (int optcount, char * opts []);
57
static void start (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
63
static void stop (void);
58
static void stop (void);
64
static void restart (int optcount, char * opts []);
59
static void restart (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
65
static void logOutput (char *);
60
static void logOutput (char *);
66
61
67
/*
62
/*
68
	Globals
63
	Globals
69
 */
64
 */
70
static int isQuiet = FALSE;
65
static int isQuiet = FALSE;
66
static char * optQuiet = "-q",			/* quiet option */
67
			* optConfig = "-config";	/* jboss configuration option */
71
68
72
/**
69
/**
73
 * Main function. This function is called when this program is executed.
70
 * Main function. This function is called when this program is executed.
Lines 84-93 Link Here
84
 int argc,
81
 int argc,
85
 char *argv [])
82
 char *argv [])
86
{
83
{
87
88
	/* Declare variables, like all other good ANSI C programs do :) */
84
	/* Declare variables, like all other good ANSI C programs do :) */
89
	int i, jopt;
85
	int i, javaOpt, jbossOpt;
90
	char *argument, **jargs;
86
	char *argument, **javaArgs, **jbossArgs;
91
87
92
	/* Parse the arguments */
88
	/* Parse the arguments */
93
	if (argc < 2)
89
	if (argc < 2)
Lines 101-126 Link Here
101
	setgid (getegid ());
97
	setgid (getegid ());
102
98
103
	/*
99
	/*
104
		Build up java-option block.
100
		Build up java and jboss option blocks.
105
	 */
101
	 */
106
	jopt = 0;
102
	javaOpt = jbossOpt = 0;
107
	for (i = 1; i < argc; i++)
103
	for (i = 1; i < argc; i++)
108
	{
104
	{
109
		if (strcmp (argv [i], "-q") == 0)
105
		if (strcmp (argv [i], optQuiet) == 0)
106
		{
110
			isQuiet = TRUE;
107
			isQuiet = TRUE;
111
		else if (*argv [i] == '-')
108
112
			jopt++;
109
		} else if (strcmp (argv [i], optConfig) == 0)
110
		{
111
			jbossOpt += 2;
112
			if (++i >= argc)
113
			{
114
				printUsage ();
115
				return ERR_ILLEGAL_ARGUMENT;
116
			}
117
118
		} else if (*argv [i] == '-')
119
		{
120
			javaOpt++;
121
		}
122
	}
123
	if (javaOpt == 0)
124
		javaArgs = NULL;
125
	else
126
	{
127
		int j = 0;
128
		javaArgs = malloc (sizeof (char *) * javaOpt);
129
		for (i = 0; i < argc; i++)
130
		{
131
			if (strcmp (argv [i], optQuiet) &&
132
				strcmp (argv [i], optConfig) &&
133
				*argv [i] == '-')
134
			{
135
				javaArgs [j++] = argv [i];
136
			}
137
		}
113
	}
138
	}
114
	if (jopt == 0)
139
	if (jbossOpt == 0)
115
		jargs = NULL;
140
		jbossArgs = NULL;
116
	else
141
	else
117
	{
142
	{
118
		int j = 0;
143
		int j = 0;
119
		jargs = malloc (sizeof (char *) * jopt);
144
		jbossArgs = malloc (sizeof (char *) * jbossOpt);
120
		for (i = 0; i < argc; i++)
145
		for (i = 0; i < argc; i++)
121
		{
146
		{
122
			if (strcmp (argv [i], "-q") && *argv [i] == '-')
147
			if (strcmp (argv [i], optConfig) == 0)
123
				jargs [j++] = argv [i];
148
			{
149
				jbossArgs [j++] = "-c";
150
				jbossArgs [j++] = argv [++i];
151
			}
124
		}
152
		}
125
	}
153
	}
126
154
Lines 130-143 Link Here
130
	argument = argv [argc - 1];
158
	argument = argv [argc - 1];
131
	if (strcmp ("start", argument) == 0)
159
	if (strcmp ("start", argument) == 0)
132
	{
160
	{
133
		start (jopt, jargs);
161
		start (javaOpt, javaArgs, jbossOpt, jbossArgs);
134
162
135
	} else if (strcmp ("stop", argument) == 0)
163
	} else if (strcmp ("stop", argument) == 0)
136
	{
164
	{
137
		stop ();
165
		stop ();
166
138
	} else if (strcmp ("restart", argument) == 0)
167
	} else if (strcmp ("restart", argument) == 0)
139
	{
168
	{
140
		restart (jopt, jargs);
169
		restart (javaOpt, javaArgs, jbossOpt, jbossArgs);
141
170
142
	} else {
171
	} else {
143
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
172
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
Lines 145-278 Link Here
145
		exit (ERR_ILLEGAL_ARGUMENT);
174
		exit (ERR_ILLEGAL_ARGUMENT);
146
	}
175
	}
147
176
148
	return 0;
177
	return EXIT_SUCCESS;
149
}
178
}
150
179
151
152
/**
180
/**
153
 * Prints usage information to stdout.
181
 * Prints usage information to stdout.
154
 */
182
 */
155
static void
183
static void
156
printUsage (void)
184
printUsage (void)
157
{
185
{
158
	printf ("Usage: %%CONTROL_SCRIPT_NAME%% [java-options] {start|stop|restart}\n");
186
	printf ("Usage: %%CONTROL_SCRIPT_NAME%% [java-options] [-config jbossconfig] {start|stop|restart}\n");
159
}
187
}
160
188
161
/**
189
/**
162
 * Attempts to open the PID file. If that file is successfully opened, then
190
 * Reads a PID from the PID file.
163
 * the file handle (an int) will be returned.
164
 *
191
 *
165
 * @return
192
 * @return
166
 *    the file handle.
193
 *    the PID, or -1 if the file was empty.
167
 */
194
 */
168
static int
195
static int
169
openPIDFile (void)
196
readPID (void)
170
{
197
{
198
	FILE * file;
199
	int pid;
171
200
172
 	int file;
201
	logOutput (">> Reading PID file (%%PID_FILE%%)...");
173
202
	file = fopen ("%%PID_FILE%%", "r");
174
	/* Attempt to open the PID file */
203
	if (!file)
175
	file = open ("%%PID_FILE%%", O_RDWR);
204
	{
176
	if (file < 0) {
177
		logOutput (" [ FAILED ]\n");
205
		logOutput (" [ FAILED ]\n");
178
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading and writing: ");
206
		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading: ");
179
		perror (NULL);
180
		exit (ERR_PID_FILE_NOT_FOUND);
207
		exit (ERR_PID_FILE_NOT_FOUND);
181
	}
208
	}
209
	if (fscanf (file, "%d", &pid) < 1)
210
		pid = -1;
211
	fclose (file);
182
212
183
	return file;
184
}
185
186
187
/**
188
 * Reads a PID from the specified file. The file is identified by a file
189
 * handle.
190
 *
191
 * @param file
192
 *    the file handle.
193
 *
194
 * @return
195
 *    the PID, or -1 if the file was empty.
196
 */
197
static int
198
readPID (
199
 int file)
200
{
201
202
	char *buffer;
203
	int hadNewline = 0;
204
	unsigned int count;
205
	unsigned int i;
206
	int pid;
207
208
	/* Read the PID file contents */
209
	buffer = (char *) malloc ((MAX_FILE_SIZE + 1) * sizeof (char));
210
	count = read (file, buffer, MAX_FILE_SIZE + 1);
211
	if (count > MAX_FILE_SIZE) {
212
		logOutput (" [ FAILED ]\n");
213
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains more than %d bytes.\n", MAX_FILE_SIZE);
214
		exit (ERR_PID_FILE_TOO_LARGE);
215
	}
216
217
	/* Convert the bytes to a number */
218
	pid = 0;
219
	for (i=0; i<count; i++) {
220
		char c = buffer[i];
221
		if (c >= '0' && c <= '9') {
222
			char digit = c - '0';
223
			pid *= 10;
224
			pid += digit;
225
		} else if (i == (count - 1) && c == '\n') {
226
			/* XXX: Ignore a newline at the end of the file */
227
			hadNewline = 1;
228
		} else {
229
			logOutput (" [ FAILED ]\n");
230
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains an illegal character (%d) at position %d.\n", c, i);
231
			exit (ERR_PID_FILE_CONTAINS_ILLEGAL_CHAR);
232
		}
233
	}
234
	logOutput (" [ DONE ]\n");
213
	logOutput (" [ DONE ]\n");
235
236
	if (count == 0 || (count == 1 && hadNewline == 1)) {
237
		return -1;
238
	}
239
240
	return pid;
214
	return pid;
241
}
215
}
242
216
243
244
/**
217
/**
245
 * Writes a process ID to the specified file. The file is identified by a file
218
 * Writes a process ID to the specified file. The file is identified by a file
246
 * handle.
219
 * handle.
247
 *
220
 *
248
 * @param file
249
 *    the file handle, always greater than 0.
250
 *
251
 * @param pid
221
 * @param pid
252
 *    the PID to store, always greater than 0.
222
 *    the PID to store, always greater than 0.
253
 */
223
 */
254
static void
224
static void
255
writePID (
225
writePID (
256
 int file,
257
 int pid)
226
 int pid)
258
{
227
{
259
228
	FILE * file;
260
	char *buffer;
261
	int nbytes;
262
263
	/* Check preconditions */
264
	assert (file > 0);
265
	assert (pid > 0);
266
229
267
	logOutput (">> Writing PID file...");
230
	logOutput (">> Writing PID file...");
231
	file = fopen ("%%PID_FILE%%", "w");
232
	if (!file)
233
	{
234
		logOutput (" [ FAILED ]\n");
235
		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for writing: ");
236
		exit (ERR_PID_FILE_NOT_FOUND);
237
	}
238
	fprintf (file, "%d\n", pid);
239
	fclose (file);
268
240
269
	lseek (file, (off_t) 0, SEEK_SET);
270
	ftruncate (file, (off_t) 0);
271
	nbytes = asprintf (&buffer, "%d\n", pid);
272
	write (file, buffer, nbytes);
273
	logOutput (" [ DONE ]\n");
241
	logOutput (" [ DONE ]\n");
274
}
242
}
275
243
244
/**
245
	Truncate the PID file.
246
 */
247
static void
248
clearPID (void)
249
{
250
	if (truncate ("%%PID_FILE%%", 0) != 0)
251
	{
252
		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to clear %%PID_FILE%%: ");
253
		exit (ERR_PID_FILE_NOT_FOUND);
254
	}
255
}
276
256
277
/**
257
/**
278
 * Checks if the specified process is running.
258
 * Checks if the specified process is running.
Lines 287-293 Link Here
287
existsProcess (
267
existsProcess (
288
 int pid)
268
 int pid)
289
{
269
{
290
291
	int result;
270
	int result;
292
271
293
	/* Check preconditions */
272
	/* Check preconditions */
Lines 297-310 Link Here
297
   	result = kill (pid, 0);
276
   	result = kill (pid, 0);
298
277
299
	/* If the result is 0, then the process exists */
278
	/* If the result is 0, then the process exists */
300
	if (result == 0) {
279
	return result == 0;
301
		return 1;
302
	} else {
303
		return 0;
304
	}
305
}
280
}
306
281
307
308
/**
282
/**
309
 * Kills the process identified by the specified ID.
283
 * Kills the process identified by the specified ID.
310
 *
284
 *
Lines 315-321 Link Here
315
killProcess (
289
killProcess (
316
 int pid)
290
 int pid)
317
{
291
{
318
319
	int result;
292
	int result;
320
	unsigned int waited;
293
	unsigned int waited;
321
	unsigned int forced;
294
	unsigned int forced;
Lines 347-359 Link Here
347
320
348
	/* If the process still exists, then have no mercy and kill it */
321
	/* If the process still exists, then have no mercy and kill it */
349
	forced = 0;
322
	forced = 0;
350
	if (result == 1) {
323
	if (result == 1)
351
324
	{
352
		/* Force the process to die */
325
		/* Force the process to die */
353
		result = kill (pid, SIGKILL);
326
		result = kill (pid, SIGKILL);
354
		if (result == 0) {
327
		if (result == 0) {
355
			forced = 1;
328
			forced = 1;
356
			logOutput (" [ DONE ]\n");
329
			logOutput (" [ KILLED ]\n");
357
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
330
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
358
		} else if (result != ESRCH) {
331
		} else if (result != ESRCH) {
359
			logOutput (" [ FAILED ]\n");
332
			logOutput (" [ FAILED ]\n");
Lines 373-399 Link Here
373
 */
346
 */
374
static void
347
static void
375
start (
348
start (
376
 int optcount,
349
 int javaOpt,
377
 char * opts [])
350
 char * javaArgs [],
351
 int jbossOpt,
352
 char * jbossArgs [])
378
{
353
{
379
	int file;
354
	int i, argc;
355
	char ** argv;
380
	int pid;
356
	int pid;
381
	int result;
357
	int result;
382
	int stdoutLogFile;
358
	int stdoutLogFile;
383
	int stderrLogFile;
359
	int stderrLogFile;
384
	struct stat sb;
360
	struct stat sb;
385
361
386
	/* Open and read the PID file */
362
	pid = readPID ();
387
	logOutput (">> Reading PID file (%%PID_FILE%%)...");
388
	file = openPIDFile ();
389
	pid = readPID (file);
390
363
391
	logOutput (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
364
	logOutput (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
392
	if (pid != -1) {
365
	if (pid != -1)
393
366
	{
394
		/* Check if the process actually exists */
367
		/* Check if the process actually exists */
395
		result = existsProcess (pid);
368
		result = existsProcess (pid);
396
		if (result == 1) {
369
		if (result == 1)
370
		{
397
			logOutput (" [ FAILED ]\n");
371
			logOutput (" [ FAILED ]\n");
398
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
372
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
399
			exit (ERR_ALREADY_RUNNING);
373
			exit (ERR_ALREADY_RUNNING);
Lines 474-492 Link Here
474
	lseek (stderrLogFile, (off_t) 0, SEEK_END);
448
	lseek (stderrLogFile, (off_t) 0, SEEK_END);
475
449
476
	/* Split this process in two */
450
	/* Split this process in two */
477
	pid = fork ();
451
	switch (pid = fork ())
478
	if (pid == -1) {
452
	{
453
	case -1:
479
		logOutput (" [ FAILED ]\n");
454
		logOutput (" [ FAILED ]\n");
480
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
455
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
481
		perror (NULL);
456
		perror (NULL);
482
		exit (ERR_FORK_FAILED);
457
		exit (ERR_FORK_FAILED);
483
	}
458
		break;
484
485
	if (pid == 0)
486
	{
487
		int i, argc;
488
		char **argv;
489
459
460
	case 0:
490
		/* Redirect stdout to log file */
461
		/* Redirect stdout to log file */
491
		dup2 (stdoutLogFile, STDOUT_FILENO);
462
		dup2 (stdoutLogFile, STDOUT_FILENO);
492
463
Lines 494-522 Link Here
494
		dup2 (stderrLogFile, STDERR_FILENO);
465
		dup2 (stderrLogFile, STDERR_FILENO);
495
466
496
		/* TODO: Support redirection of both stdout and stderr to the same
467
		/* TODO: Support redirection of both stdout and stderr to the same
497
		         file using pipe (2) */
468
				 file using pipe (2) */
498
469
499
		/*
470
		/*
500
			Build the argument vector, with the java-options if any.
471
			Build the argument vector, with the java/jboss options if any.
501
		 */
472
		 */
502
		argv = malloc (sizeof (char *) * (optcount + 5));
473
		argv = malloc (sizeof (char *) * (javaOpt + jbossOpt + 5));
503
		argc = 0;
474
		argc = 0;
504
		argv [argc++] = "%%JAVA%%";
475
		argv [argc++] = "%%JAVA%%";
505
		for (i = 0; i < optcount; i++)
476
		for (i = 0; i < javaOpt; i++)
506
			argv [argc++] = opts [i];
477
			argv [argc++] = javaArgs [i];
507
		argv [argc++] = "-cp";
478
		argv [argc++] = "-cp";
508
		argv [argc++] = "%%JAVA_CP%%";
479
		argv [argc++] = "%%JAVA_CP%%";
509
		argv [argc++] = "%%JAVA_MAIN%%";
480
		argv [argc++] = "%%JAVA_MAIN%%";
481
		for (i = 0; i < jbossOpt; i++)
482
			argv [argc++] = jbossArgs [i];
510
		argv [argc++] = NULL;
483
		argv [argc++] = NULL;
511
484
512
		/* Execute the command */
485
		/* Execute the command */
513
		execv (argv [0], argv);
486
		execv (argv [0], argv);
514
515
		perror (NULL);
487
		perror (NULL);
516
	} else
488
		break;
517
	{
489
490
	default:
518
		logOutput (" [ DONE ]\n");
491
		logOutput (" [ DONE ]\n");
519
		writePID (file, pid);
492
		writePID (pid);
520
	}
493
	}
521
}
494
}
522
495
Lines 526-553 Link Here
526
static void
499
static void
527
stop (void)
500
stop (void)
528
{
501
{
529
530
	int file;
531
	int pid;
502
	int pid;
532
503
533
	/* Open and read the PID file */
504
	pid = readPID ();
534
	logOutput (">> Reading PID file (%%PID_FILE%%)...");
535
	file = openPIDFile ();
536
	pid = readPID (file);
537
505
538
	logOutput (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
506
	logOutput (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
539
507
540
	/* If there is a PID, see if the process still exists */
508
	/* If there is a PID, see if the process still exists */
541
	if (pid != -1) {
509
	if (pid != -1)
510
	{
542
		int result = kill (pid, 0);
511
		int result = kill (pid, 0);
543
		if (result != 0 && errno == ESRCH) {
512
		if (result != 0 && errno == ESRCH)
544
			ftruncate (file, (off_t) 0);
513
		{
514
			clearPID ();
545
			pid = -1;
515
			pid = -1;
546
		}
516
		}
547
	}
517
	}
548
518
549
	/* If there is no running process, produce an error */
519
	/* If there is no running process, produce an error */
550
	if (pid == -1) {
520
	if (pid == -1)
521
	{
551
		logOutput (" [ FAILED ]\n");
522
		logOutput (" [ FAILED ]\n");
552
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
523
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
553
		exit (ERR_NOT_RUNNING);
524
		exit (ERR_NOT_RUNNING);
Lines 556-564 Link Here
556
527
557
	/* Terminate the process */
528
	/* Terminate the process */
558
	killProcess (pid);
529
	killProcess (pid);
559
530
	clearPID ();
560
	/* Clear the PID file */
561
	ftruncate (file, (off_t) 0);
562
}
531
}
563
532
564
533
Lines 567-577 Link Here
567
 */
536
 */
568
static void
537
static void
569
restart (
538
restart (
570
 int optcount,
539
 int javaOpt,
571
 char * opts [])
540
 char * javaArgs [],
541
 int jbossOpt,
542
 char * jbossArgs [])
572
{
543
{
573
	stop ();
544
	stop ();
574
	start (optcount, opts);
545
	start (javaOpt, javaArgs, jbossOpt, jbossArgs);
575
}
546
}
576
547
577
/**
548
/**
(-)./files/startup.sh (-4 / +16 lines)
Lines 1-6 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# -*- mode: Fundamental; tab-width: 4; -*-
3
# ex:ts=4
4
#
2
#
5
# %%APP_TITLE%% startup script.
3
# %%APP_TITLE%% startup script.
6
#
4
#
Lines 15-20 Link Here
15
#				Set it to "YES" to enable %%APP_SHORTNAME%%
13
#				Set it to "YES" to enable %%APP_SHORTNAME%%
16
# %%APP_SHORTNAME%%_flags (str):		Set to "-server" by default.
14
# %%APP_SHORTNAME%%_flags (str):		Set to "-server" by default.
17
#				Extra JVM flags.
15
#				Extra JVM flags.
16
# %%APP_SHORTNAME%%_config (str):		Set to "" by default
17
#				JBoss server config, eg {all|default|minimal|standard}
18
#
18
#
19
. %%RC_SUBR%%
19
. %%RC_SUBR%%
20
20
Lines 28-46 Link Here
28
28
29
[ -z "$%%APP_SHORTNAME%%_enable" ]	&& %%APP_SHORTNAME%%_enable="NO"
29
[ -z "$%%APP_SHORTNAME%%_enable" ]	&& %%APP_SHORTNAME%%_enable="NO"
30
[ -z "$%%APP_SHORTNAME%%_flags" ]	&& %%APP_SHORTNAME%%_flags="-server"
30
[ -z "$%%APP_SHORTNAME%%_flags" ]	&& %%APP_SHORTNAME%%_flags="-server"
31
[ -z "$%%APP_SHORTNAME%%_config" ]	&& %%APP_SHORTNAME%%_config=""
31
32
32
%%APP_SHORTNAME%%_start ()
33
%%APP_SHORTNAME%%_start ()
33
{
34
{
34
	checkyesno %%APP_SHORTNAME%%_enable &&
35
	checkyesno %%APP_SHORTNAME%%_enable &&
35
		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} start &&
36
	{
37
		if [ ! -f ${pidfile} ]
38
		then
39
			touch ${pidfile}
40
			chown %%USER%%:%%GROUP%% ${pidfile}
41
		fi
42
43
		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} start &&
36
		echo -n " %%APP_SHORTNAME%%"
44
		echo -n " %%APP_SHORTNAME%%"
45
	}
37
}
46
}
38
47
39
%%APP_SHORTNAME%%_restart ()
48
%%APP_SHORTNAME%%_restart ()
40
{
49
{
41
	checkyesno %%APP_SHORTNAME%%_enable &&
50
	checkyesno %%APP_SHORTNAME%%_enable &&
42
		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} restart
51
		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} restart
43
}
52
}
44
53
45
load_rc_config $name
54
load_rc_config $name
55
56
[ -n "${%%APP_SHORTNAME%%_config}" ] && %%APP_SHORTNAME%%_configflag="-config"
57
46
run_rc_command "$1"
58
run_rc_command "$1"
(-)./pkg-message (+2 lines)
Line 0 Link Here
1
To run the JBoss4 server from startup, add jboss4_enable="YES"
2
in your /etc/rc.conf. Extra options can be found in startup script.

Return to bug 75345