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

(-)./Makefile (-3 / +6 lines)
Lines 7-12 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
CATEGORIES=	java
11
CATEGORIES=	java
11
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITE_SUBDIR=	${PORTNAME}
13
MASTER_SITE_SUBDIR=	${PORTNAME}
Lines 22-38 Link Here
22
JAVA_VERSION=	1.4+
23
JAVA_VERSION=	1.4+
23
24
24
USE_REINPLACE=	YES
25
USE_REINPLACE=	YES
26
USE_RC_SUBR=	YES
25
USE_BZIP2=	YES
27
USE_BZIP2=	YES
26
28
27
.if !defined(NOPORTDOCS)
29
.if !defined(NOPORTDOCS)
28
PORTDOCS=	*
30
PORTDOCS=	*
29
.endif
31
.endif
30
32
31
APP_HOME?=	${PREFIX}/${PKGBASE}${PORTVERSION:R}
33
APP_HOME?=	${PREFIX}/${APP_SHORTNAME}
32
DOCSDIR=	${PREFIX}/share/doc/${PKGBASE}${PORTVERSION:R}
34
DOCSDIR=	${PREFIX}/share/doc/${PKGBASE}${PORTVERSION:R}
33
LOG_DIR=	${APP_HOME}/log
35
LOG_DIR=	${APP_HOME}/log
34
APP_TITLE=	JBoss
36
APP_TITLE=	JBoss
35
APP_SHORTNAME=	${PORTNAME}${PORTVERSION:R:R}
37
APP_SHORTNAME=	${UNIQUENAME}
36
CONTROL_SCRIPT_NAME=	${APP_SHORTNAME}ctl
38
CONTROL_SCRIPT_NAME=	${APP_SHORTNAME}ctl
37
CONTROL_SCRIPT=	${PREFIX}/bin/${CONTROL_SCRIPT_NAME}
39
CONTROL_SCRIPT=	${PREFIX}/bin/${CONTROL_SCRIPT_NAME}
38
CONTROL_SCRIPT_MANPAGE_TITLE=	${CONTROL_SCRIPT_NAME:U}
40
CONTROL_SCRIPT_MANPAGE_TITLE=	${CONTROL_SCRIPT_NAME:U}
Lines 66-71 Link Here
66
do-configure:
68
do-configure:
67
	@(cd ${DAEMONCTL_DIR} && ${CP} ${DAEMONCTL_FILES} ${WRKDIR})
69
	@(cd ${DAEMONCTL_DIR} && ${CP} ${DAEMONCTL_FILES} ${WRKDIR})
68
	@(cd ${WRKDIR} && ${REINPLACE_CMD} \
70
	@(cd ${WRKDIR} && ${REINPLACE_CMD} \
71
		-e "s|%%RC_SUBR%%|${RC_SUBR}|g;" \
69
		-e "s|%%APP_HOME%%|${APP_HOME}|g;" \
72
		-e "s|%%APP_HOME%%|${APP_HOME}|g;" \
70
		-e "s|%%APP_SHORTNAME%%|${APP_SHORTNAME}|g;" \
73
		-e "s|%%APP_SHORTNAME%%|${APP_SHORTNAME}|g;" \
71
		-e "s|%%APP_TITLE%%|${APP_TITLE}|g;" \
74
		-e "s|%%APP_TITLE%%|${APP_TITLE}|g;" \
Lines 73-80 Link Here
73
		-e "s|%%CONTROL_SCRIPT_MANPAGE_TITLE%%|${CONTROL_SCRIPT_MANPAGE_TITLE}|g;" \
76
		-e "s|%%CONTROL_SCRIPT_MANPAGE_TITLE%%|${CONTROL_SCRIPT_MANPAGE_TITLE}|g;" \
74
		-e "s|%%CONTROL_SCRIPT_NAME%%|${CONTROL_SCRIPT_NAME}|g;" \
77
		-e "s|%%CONTROL_SCRIPT_NAME%%|${CONTROL_SCRIPT_NAME}|g;" \
75
		-e "s|%%GROUP%%|${GROUP}|g;" \
78
		-e "s|%%GROUP%%|${GROUP}|g;" \
79
		-e "s|%%JAVA%%|${JAVA}|g;" \
76
		-e "s|%%JAVA_CP%%|${JAVA_CP}|g;" \
80
		-e "s|%%JAVA_CP%%|${JAVA_CP}|g;" \
77
		-e "s|%%JAVA_CMD%%|bin/java|g;" \
78
		-e "s|%%JAVA_HOME%%|${JAVA_HOME}|g;" \
81
		-e "s|%%JAVA_HOME%%|${JAVA_HOME}|g;" \
79
		-e "s|%%JAVA_MAIN%%|${JAVA_MAIN}|g;" \
82
		-e "s|%%JAVA_MAIN%%|${JAVA_MAIN}|g;" \
80
		-e "s|%%JAVA_OPTS%%|${JAVA_OPTS}|g;" \
83
		-e "s|%%JAVA_OPTS%%|${JAVA_OPTS}|g;" \
(-)./files/daemonctl.c (-39 / +62 lines)
Lines 24-29 Link Here
24
#include <sys/types.h>
24
#include <sys/types.h>
25
#include <sys/uio.h>
25
#include <sys/uio.h>
26
26
27
#define	TRUE	1
28
#define	FALSE	0
29
27
/* The maximum size of the PID file, in bytes */
30
/* The maximum size of the PID file, in bytes */
28
#define MAX_FILE_SIZE			32
31
#define MAX_FILE_SIZE			32
29
32
Lines 59-64 Link Here
59
static void start (int optcount, char * opts []);
62
static void start (int optcount, char * opts []);
60
static void stop (void);
63
static void stop (void);
61
static void restart (int optcount, char * opts []);
64
static void restart (int optcount, char * opts []);
65
static void logOutput (char *);
66
67
/*
68
	Globals
69
 */
70
static int isQuiet = FALSE;
62
71
63
/**
72
/**
64
 * Main function. This function is called when this program is executed.
73
 * Main function. This function is called when this program is executed.
Lines 97-103 Link Here
97
	jopt = 0;
106
	jopt = 0;
98
	for (i = 1; i < argc; i++)
107
	for (i = 1; i < argc; i++)
99
	{
108
	{
100
		if (*argv [i] == '-')
109
		if (strcmp (argv [i], "-q") == 0)
110
			isQuiet = TRUE;
111
		else if (*argv [i] == '-')
101
			jopt++;
112
			jopt++;
102
	}
113
	}
103
	if (jopt == 0)
114
	if (jopt == 0)
Lines 108-114 Link Here
108
		jargs = malloc (sizeof (char *) * jopt);
119
		jargs = malloc (sizeof (char *) * jopt);
109
		for (i = 0; i < argc; i++)
120
		for (i = 0; i < argc; i++)
110
		{
121
		{
111
			if (*argv [i] == '-')
122
			if (strcmp (argv [i], "-q") && *argv [i] == '-')
112
				jargs [j++] = argv [i];
123
				jargs [j++] = argv [i];
113
		}
124
		}
114
	}
125
	}
Lines 163-169 Link Here
163
	/* Attempt to open the PID file */
174
	/* Attempt to open the PID file */
164
	file = open ("%%PID_FILE%%", O_RDWR);
175
	file = open ("%%PID_FILE%%", O_RDWR);
165
	if (file < 0) {
176
	if (file < 0) {
166
		printf (" [ FAILED ]\n");
177
		logOutput (" [ FAILED ]\n");
167
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading and writing: ");
178
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading and writing: ");
168
		perror (NULL);
179
		perror (NULL);
169
		exit (ERR_PID_FILE_NOT_FOUND);
180
		exit (ERR_PID_FILE_NOT_FOUND);
Lines 198-204 Link Here
198
	buffer = (char *) malloc ((MAX_FILE_SIZE + 1) * sizeof (char));
209
	buffer = (char *) malloc ((MAX_FILE_SIZE + 1) * sizeof (char));
199
	count = read (file, buffer, MAX_FILE_SIZE + 1);
210
	count = read (file, buffer, MAX_FILE_SIZE + 1);
200
	if (count > MAX_FILE_SIZE) {
211
	if (count > MAX_FILE_SIZE) {
201
		printf (" [ FAILED ]\n");
212
		logOutput (" [ FAILED ]\n");
202
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains more than %d bytes.\n", MAX_FILE_SIZE);
213
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains more than %d bytes.\n", MAX_FILE_SIZE);
203
		exit (ERR_PID_FILE_TOO_LARGE);
214
		exit (ERR_PID_FILE_TOO_LARGE);
204
	}
215
	}
Lines 215-226 Link Here
215
			/* XXX: Ignore a newline at the end of the file */
226
			/* XXX: Ignore a newline at the end of the file */
216
			hadNewline = 1;
227
			hadNewline = 1;
217
		} else {
228
		} else {
218
			printf (" [ FAILED ]\n");
229
			logOutput (" [ FAILED ]\n");
219
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains an illegal character (%d) at position %d.\n", c, i);
230
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains an illegal character (%d) at position %d.\n", c, i);
220
			exit (ERR_PID_FILE_CONTAINS_ILLEGAL_CHAR);
231
			exit (ERR_PID_FILE_CONTAINS_ILLEGAL_CHAR);
221
		}
232
		}
222
	}
233
	}
223
	printf (" [ DONE ]\n");
234
	logOutput (" [ DONE ]\n");
224
235
225
	if (count == 0 || (count == 1 && hadNewline == 1)) {
236
	if (count == 0 || (count == 1 && hadNewline == 1)) {
226
		return -1;
237
		return -1;
Lines 253-265 Link Here
253
	assert (file > 0);
264
	assert (file > 0);
254
	assert (pid > 0);
265
	assert (pid > 0);
255
266
256
	printf (">> Writing PID file...");
267
	logOutput (">> Writing PID file...");
257
268
258
	lseek (file, (off_t) 0, SEEK_SET);
269
	lseek (file, (off_t) 0, SEEK_SET);
259
	ftruncate (file, (off_t) 0);
270
	ftruncate (file, (off_t) 0);
260
	nbytes = asprintf (&buffer, "%d\n", pid);
271
	nbytes = asprintf (&buffer, "%d\n", pid);
261
	write (file, buffer, nbytes);
272
	write (file, buffer, nbytes);
262
	printf (" [ DONE ]\n");
273
	logOutput (" [ DONE ]\n");
263
}
274
}
264
275
265
276
Lines 314-323 Link Here
314
	/* Check preconditions */
325
	/* Check preconditions */
315
	assert (pid > 0);
326
	assert (pid > 0);
316
327
317
	printf (">> Terminating process %d...", pid);
328
	if (!isQuiet)
329
		printf (">> Terminating process %d...", pid);
318
	result = kill (pid, SIGTERM);
330
	result = kill (pid, SIGTERM);
319
	if (result < 0) {
331
	if (result < 0) {
320
		printf (" [ FAILED ]\n");
332
		logOutput (" [ FAILED ]\n");
321
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
333
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
322
		perror (NULL);
334
		perror (NULL);
323
		exit (ERR_KILL_FAILED);
335
		exit (ERR_KILL_FAILED);
Lines 327-334 Link Here
327
    result = existsProcess (pid);
339
    result = existsProcess (pid);
328
	for (waited=0; result == 1 && waited < timeout; waited += interval)
340
	for (waited=0; result == 1 && waited < timeout; waited += interval)
329
	{
341
	{
330
		printf (".");
342
		logOutput (".");
331
		fflush (NULL);
343
		fflush (stdout);
332
		sleep (interval);
344
		sleep (interval);
333
    	result = existsProcess (pid);
345
    	result = existsProcess (pid);
334
	}
346
	}
Lines 341-350 Link Here
341
		result = kill (pid, SIGKILL);
353
		result = kill (pid, SIGKILL);
342
		if (result == 0) {
354
		if (result == 0) {
343
			forced = 1;
355
			forced = 1;
344
			printf (" [ DONE ]\n");
356
			logOutput (" [ DONE ]\n");
345
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
357
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
346
		} else if (result != ESRCH) {
358
		} else if (result != ESRCH) {
347
			printf (" [ FAILED ]\n");
359
			logOutput (" [ FAILED ]\n");
348
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
360
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
349
			perror (NULL);
361
			perror (NULL);
350
			exit (ERR_KILL_FAILED);
362
			exit (ERR_KILL_FAILED);
Lines 352-358 Link Here
352
	}
364
	}
353
365
354
	if (forced == 0) {
366
	if (forced == 0) {
355
		printf (" [ DONE ]\n");
367
		logOutput (" [ DONE ]\n");
356
	}
368
	}
357
}
369
}
358
370
Lines 372-388 Link Here
372
	struct stat sb;
384
	struct stat sb;
373
385
374
	/* Open and read the PID file */
386
	/* Open and read the PID file */
375
	printf (">> Reading PID file (%%PID_FILE%%)...");
387
	logOutput (">> Reading PID file (%%PID_FILE%%)...");
376
	file = openPIDFile ();
388
	file = openPIDFile ();
377
	pid = readPID (file);
389
	pid = readPID (file);
378
390
379
	printf (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
391
	logOutput (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
380
	if (pid != -1) {
392
	if (pid != -1) {
381
393
382
		/* Check if the process actually exists */
394
		/* Check if the process actually exists */
383
		result = existsProcess (pid);
395
		result = existsProcess (pid);
384
		if (result == 1) {
396
		if (result == 1) {
385
			printf (" [ FAILED ]\n");
397
			logOutput (" [ FAILED ]\n");
386
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
398
			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
387
			exit (ERR_ALREADY_RUNNING);
399
			exit (ERR_ALREADY_RUNNING);
388
		}
400
		}
Lines 391-424 Link Here
391
	/* Check if the JDK home directory is actually a directory */
403
	/* Check if the JDK home directory is actually a directory */
392
	result = stat ("%%JAVA_HOME%%", &sb);
404
	result = stat ("%%JAVA_HOME%%", &sb);
393
	if (result != 0) {
405
	if (result != 0) {
394
		printf (" [ FAILED ]\n");
406
		logOutput (" [ FAILED ]\n");
395
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%: ");
407
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%: ");
396
		perror (NULL);
408
		perror (NULL);
397
		exit (ERR_STAT_JAVA_HOME);
409
		exit (ERR_STAT_JAVA_HOME);
398
	}
410
	}
399
	if (!S_ISDIR (sb.st_mode)) {
411
	if (!S_ISDIR (sb.st_mode)) {
400
		printf (" [ FAILED ]\n");
412
		logOutput (" [ FAILED ]\n");
401
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java home directory %%JAVA_HOME%% is not a directory.\n");
413
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java home directory %%JAVA_HOME%% is not a directory.\n");
402
		exit (ERR_JAVA_HOME_NOT_DIR);
414
		exit (ERR_JAVA_HOME_NOT_DIR);
403
	}
415
	}
404
416
405
	/* Check if the Java command is actually an executable regular file */
417
	/* Check if the Java command is actually an executable regular file */
406
	result = stat ("%%JAVA_HOME%%/%%JAVA_CMD%%", &sb);
418
	result = stat ("%%JAVA%%", &sb);
407
	if (result != 0) {
419
	if (result != 0) {
408
		printf (" [ FAILED ]\n");
420
		logOutput (" [ FAILED ]\n");
409
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%/%%JAVA_CMD%%: ");
421
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA%%: ");
410
		perror (NULL);
422
		perror (NULL);
411
		exit (ERR_STAT_JAVA_CMD);
423
		exit (ERR_STAT_JAVA_CMD);
412
	}
424
	}
413
	if (!S_ISREG (sb.st_mode)) {
425
	if (!S_ISREG (sb.st_mode)) {
414
		printf (" [ FAILED ]\n");
426
		logOutput (" [ FAILED ]\n");
415
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA_HOME%%/%%JAVA_CMD%% is not a regular file.\n");
427
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not a regular file.\n");
416
		exit (ERR_JAVA_CMD_NOT_FILE);
428
		exit (ERR_JAVA_CMD_NOT_FILE);
417
	}
429
	}
418
	result = access ("%%JAVA_HOME%%/%%JAVA_CMD%%", X_OK);
430
	result = access ("%%JAVA%%", X_OK);
419
	if (result != 0) {
431
	if (result != 0) {
420
		printf (" [ FAILED ]\n");
432
		logOutput (" [ FAILED ]\n");
421
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA_HOME%%/%%JAVA_CMD%% is not executable: ");
433
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not executable: ");
422
		perror (NULL);
434
		perror (NULL);
423
		exit (ERR_JAVA_CMD_NOT_EXECUTABLE);
435
		exit (ERR_JAVA_CMD_NOT_EXECUTABLE);
424
	}
436
	}
Lines 426-432 Link Here
426
	/* Change directory */
438
	/* Change directory */
427
	result = chdir ("%%APP_HOME%%");
439
	result = chdir ("%%APP_HOME%%");
428
	if (result < 0) {
440
	if (result < 0) {
429
		printf (" [ FAILED ]\n");
441
		logOutput (" [ FAILED ]\n");
430
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access directory %%APP_HOME%%: ");
442
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access directory %%APP_HOME%%: ");
431
		perror (NULL);
443
		perror (NULL);
432
		exit (ERR_CHDIR_TO_APP_HOME);
444
		exit (ERR_CHDIR_TO_APP_HOME);
Lines 435-441 Link Here
435
	/* See if the JAR file exists */
447
	/* See if the JAR file exists */
436
	result = access ("%%APP_HOME%%/%%JAR_FILE%%", R_OK);
448
	result = access ("%%APP_HOME%%/%%JAR_FILE%%", R_OK);
437
	if (result < 0) {
449
	if (result < 0) {
438
		printf (" [ FAILED ]\n");
450
		logOutput (" [ FAILED ]\n");
439
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access JAR file %%APP_HOME%%/%%JAR_FILE%%: ");
451
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access JAR file %%APP_HOME%%/%%JAR_FILE%%: ");
440
		perror (NULL);
452
		perror (NULL);
441
		exit (ERR_ACCESS_JAR_FILE);
453
		exit (ERR_ACCESS_JAR_FILE);
Lines 444-450 Link Here
444
	/* Open the stdout log file */
456
	/* Open the stdout log file */
445
	stdoutLogFile = open ("%%STDOUT_LOG%%", O_WRONLY);
457
	stdoutLogFile = open ("%%STDOUT_LOG%%", O_WRONLY);
446
	if (stdoutLogFile < 0) {
458
	if (stdoutLogFile < 0) {
447
		printf (" [ FAILED ]\n");
459
		logOutput (" [ FAILED ]\n");
448
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDOUT_LOG%% for writing: ");
460
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDOUT_LOG%% for writing: ");
449
		perror (NULL);
461
		perror (NULL);
450
		exit (ERR_STDOUT_LOGFILE_OPEN);
462
		exit (ERR_STDOUT_LOGFILE_OPEN);
Lines 454-460 Link Here
454
	/* Open the stderr log file */
466
	/* Open the stderr log file */
455
	stderrLogFile = open ("%%STDERR_LOG%%", O_WRONLY);
467
	stderrLogFile = open ("%%STDERR_LOG%%", O_WRONLY);
456
	if (stderrLogFile < 0) {
468
	if (stderrLogFile < 0) {
457
		printf (" [ FAILED ]\n");
469
		logOutput (" [ FAILED ]\n");
458
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDERR_LOG%% for writing: ");
470
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDERR_LOG%% for writing: ");
459
		perror (NULL);
471
		perror (NULL);
460
		exit (ERR_STDERR_LOGFILE_OPEN);
472
		exit (ERR_STDERR_LOGFILE_OPEN);
Lines 464-470 Link Here
464
	/* Split this process in two */
476
	/* Split this process in two */
465
	pid = fork ();
477
	pid = fork ();
466
	if (pid == -1) {
478
	if (pid == -1) {
467
		printf (" [ FAILED ]\n");
479
		logOutput (" [ FAILED ]\n");
468
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
480
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
469
		perror (NULL);
481
		perror (NULL);
470
		exit (ERR_FORK_FAILED);
482
		exit (ERR_FORK_FAILED);
Lines 489-495 Link Here
489
		 */
501
		 */
490
		argv = malloc (sizeof (char *) * (optcount + 5));
502
		argv = malloc (sizeof (char *) * (optcount + 5));
491
		argc = 0;
503
		argc = 0;
492
		argv [argc++] = "%%JAVA_HOME%%/%%JAVA_CMD%%";
504
		argv [argc++] = "%%JAVA%%";
493
		for (i = 0; i < optcount; i++)
505
		for (i = 0; i < optcount; i++)
494
			argv [argc++] = opts [i];
506
			argv [argc++] = opts [i];
495
		argv [argc++] = "-cp";
507
		argv [argc++] = "-cp";
Lines 503-509 Link Here
503
		perror (NULL);
515
		perror (NULL);
504
	} else
516
	} else
505
	{
517
	{
506
		printf (" [ DONE ]\n");
518
		logOutput (" [ DONE ]\n");
507
		writePID (file, pid);
519
		writePID (file, pid);
508
	}
520
	}
509
}
521
}
Lines 519-529 Link Here
519
	int pid;
531
	int pid;
520
532
521
	/* Open and read the PID file */
533
	/* Open and read the PID file */
522
	printf (">> Reading PID file (%%PID_FILE%%)...");
534
	logOutput (">> Reading PID file (%%PID_FILE%%)...");
523
	file = openPIDFile ();
535
	file = openPIDFile ();
524
	pid = readPID (file);
536
	pid = readPID (file);
525
537
526
	printf (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
538
	logOutput (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
527
539
528
	/* If there is a PID, see if the process still exists */
540
	/* If there is a PID, see if the process still exists */
529
	if (pid != -1) {
541
	if (pid != -1) {
Lines 536-546 Link Here
536
548
537
	/* If there is no running process, produce an error */
549
	/* If there is no running process, produce an error */
538
	if (pid == -1) {
550
	if (pid == -1) {
539
		printf (" [ FAILED ]\n");
551
		logOutput (" [ FAILED ]\n");
540
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
552
		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
541
		exit (ERR_NOT_RUNNING);
553
		exit (ERR_NOT_RUNNING);
542
	}
554
	}
543
	printf (" [ DONE ]\n");
555
	logOutput (" [ DONE ]\n");
544
556
545
	/* Terminate the process */
557
	/* Terminate the process */
546
	killProcess (pid);
558
	killProcess (pid);
Lines 560-563 Link Here
560
{
572
{
561
	stop ();
573
	stop ();
562
	start (optcount, opts);
574
	start (optcount, opts);
575
}
576
577
/**
578
	Output log to stdout.
579
 */
580
static void
581
logOutput (
582
 char * string)
583
{
584
	if (!isQuiet)
585
		printf (string);
563
}
586
}
(-)./files/patch-serial-autoinc (+86 lines)
Line 0 Link Here
1
$FreeBSD$
2
3
This patch allows JBoss to correctly create tables when
4
using the auto-increment feature with Postgresql.
5
6
diff -r -u ./server/src/etc/conf/default/standardjbosscmp-jdbc.xml /tmp/jboss-4.0.0-src/server/src/etc/conf/default/standardjbosscmp-jdbc.xml
7
--- ./server/src/etc/conf/default/standardjbosscmp-jdbc.xml	Thu Sep 16 03:48:58 2004
8
+++ /tmp/jboss-4.0.0-src/server/src/etc/conf/default/standardjbosscmp-jdbc.xml	Sun Dec  5 22:21:18 2004
9
@@ -1169,7 +1169,7 @@
10
          <row-locking-template>SELECT ?1 FROM ?2 WHERE ?3 ORDER BY ?4 FOR UPDATE</row-locking-template>
11
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
12
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
13
-         <auto-increment-template>?1</auto-increment-template>
14
+         <auto-increment-template>?1 serial</auto-increment-template>
15
          <alias-header-prefix>t</alias-header-prefix>
16
          <alias-header-suffix>_</alias-header-suffix>
17
          <alias-max-length>32</alias-max-length>
18
@@ -1296,7 +1296,7 @@
19
          <row-locking-template>SELECT ?1 FROM ?2 WHERE ?3 ORDER BY ?4 FOR UPDATE</row-locking-template>
20
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
21
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
22
-         <auto-increment-template>?1</auto-increment-template>
23
+         <auto-increment-template>?1 serial</auto-increment-template>
24
          <alias-header-prefix>t</alias-header-prefix>
25
          <alias-header-suffix>_</alias-header-suffix>
26
          <alias-max-length>32</alias-max-length>
27
@@ -1423,7 +1423,7 @@
28
          <row-locking-template/>
29
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
30
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
31
-         <auto-increment-template>?1 IDENTITY</auto-increment-template>
32
+         <auto-increment-template>?1 ?2 ?3 IDENTITY</auto-increment-template>
33
          <add-column-template>ALTER TABLE ?1 ADD COLUMN ?2 ?3</add-column-template>
34
          <drop-column-template>ALTER TABLE ?1 DROP COLUMN ?2</drop-column-template>
35
          <alias-header-prefix>t</alias-header-prefix>
36
@@ -1717,7 +1717,7 @@
37
               <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
38
          -->
39
          <fk-constraint-template>ALTER TABLE ?1 ADD INDEX (?3), ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
40
-         <auto-increment-template>?1 auto_increment</auto-increment-template>
41
+         <auto-increment-template>?1 ?2 ?3 auto_increment</auto-increment-template>
42
          <alter-column-template>ALTER TABLE ?1 MODIFY ?2 ?3</alter-column-template>
43
          <alias-header-prefix>t</alias-header-prefix>
44
          <alias-header-suffix>_</alias-header-suffix>
45
@@ -1857,7 +1857,7 @@
46
          <row-locking-template>SELECT ?1 FROM ?2 with (updlock) WHERE ?3 ORDER BY ?4</row-locking-template>
47
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
48
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
49
-         <auto-increment-template>?1 IDENTITY</auto-increment-template>
50
+         <auto-increment-template>?1 ?2 ?3 IDENTITY</auto-increment-template>
51
          <alter-column-template>ALTER TABLE ?1 ALTER COLUMN ?2 ?3</alter-column-template>
52
          <alias-header-prefix>t</alias-header-prefix>
53
          <alias-header-suffix>_</alias-header-suffix>
54
@@ -1989,7 +1989,7 @@
55
          <row-locking-template>SELECT ?1 FROM ?2 with (xlock) WHERE ?3 ORDER BY ?4</row-locking-template>
56
          <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
57
          <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
58
-         <auto-increment-template>?1 IDENTITY</auto-increment-template>
59
+         <auto-increment-template>?1 ?2 ?3 IDENTITY</auto-increment-template>
60
          <alias-header-prefix>t</alias-header-prefix>
61
          <alias-header-suffix>_</alias-header-suffix>
62
          <alias-max-length>32</alias-max-length>
63
diff -r -u ./server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java /tmp/jboss-4.0.0-src/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
64
--- ./server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java	Tue Sep 14 09:23:02 2004
65
+++ /tmp/jboss-4.0.0-src/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java	Sun Dec  5 22:04:56 2004
66
@@ -916,14 +916,18 @@
67
       // apply auto-increment template
68
       if(type.getAutoIncrement()[0])
69
       {
70
-         String columnClause = SQLUtil.getCreateTableColumnsClause(type);
71
          JDBCFunctionMappingMetaData autoIncrement =
72
             manager.getMetaData().getTypeMapping().getAutoIncrementTemplate();
73
          if(autoIncrement == null)
74
          {
75
             throw new IllegalStateException("auto-increment template not found");
76
          }
77
-         String[] args = new String[]{columnClause};
78
+         String[] args = new String[]
79
+							{
80
+								type.getColumnNames () [0],
81
+								type.getSQLTypes () [0],
82
+								type.getNotNull () [0] ? " not null " : ""
83
+							};
84
          autoIncrement.getFunctionSql(args, sqlBuffer);
85
       }
86
       else
(-)./files/startup.sh (-25 / +36 lines)
Lines 7-35 Link Here
7
# $FreeBSD: ports/java/jboss4/files/startup.sh,v 1.1 2004/06/21 16:42:59 vanilla Exp $
7
# $FreeBSD: ports/java/jboss4/files/startup.sh,v 1.1 2004/06/21 16:42:59 vanilla Exp $
8
#
8
#
9
9
10
# PROVIDE: %%APP_SHORTNAME%%
11
# REQUIRE: NETWORKING SERVERS
10
12
11
# Set some variables
13
# Add the following lines to /etc/rc.conf to enable %%APP_SHORTNAME%%:
12
MYSELF=`basename $0`
14
# %%APP_SHORTNAME%%_enable (bool):		Set to "NO" by default.
13
JAVA_OPTS="%%JAVA_OPTS%%"
15
#				Set it to "YES" to enable %%APP_SHORTNAME%%
14
16
# %%APP_SHORTNAME%%_flags (str):		Set to "-server" by default.
15
case "$1" in
17
#				Extra JVM flags.
16
	start)
18
#
17
		echo -n ' '
19
. %%RC_SUBR%%
18
		truncate -s 0 %%PID_FILE%%
20
19
		chown %%USER%%:%%GROUP%% %%PID_FILE%%
21
name="%%APP_SHORTNAME%%"
20
		chmod 600 %%PID_FILE%%
22
rcvar=`set_rcvar`
21
		su -f -m %%USER%% -c "exec %%CONTROL_SCRIPT%% ${JAVA_OPTS} start" >/dev/null && echo -n '%%APP_SHORTNAME%%'
23
22
		;;
24
start_cmd="%%APP_SHORTNAME%%_start"
23
	stop)
25
restart_cmd="%%APP_SHORTNAME%%_restart"
24
		echo -n ' '
26
pidfile="%%PID_FILE%%"
25
		chown %%USER%%:%%GROUP%% %%PID_FILE%%
27
procname="%%JAVA%%"
26
		chmod 600 %%PID_FILE%%
28
27
		su -f -m %%USER%% -c "exec %%CONTROL_SCRIPT%% stop" >/dev/null 2>&1 ; echo -n '%%APP_SHORTNAME%%'
29
[ -z "$%%APP_SHORTNAME%%_enable" ]	&& %%APP_SHORTNAME%%_enable="NO"
28
		;;
30
[ -z "$%%APP_SHORTNAME%%_flags" ]	&& %%APP_SHORTNAME%%_flags="-server"
29
	*)
31
30
		echo ""
32
%%APP_SHORTNAME%%_start ()
31
		echo "Usage: ${MYSELF} { start | stop }"
33
{
32
		echo ""
34
	checkyesno %%APP_SHORTNAME%%_enable &&
33
		exit 64
35
		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} start &&
34
		;;
36
		echo -n " %%APP_SHORTNAME%%"
35
esac
37
}
38
39
%%APP_SHORTNAME%%_restart ()
40
{
41
	checkyesno %%APP_SHORTNAME%%_enable &&
42
		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} restart
43
}
44
45
load_rc_config $name
46
run_rc_command "$1"

Return to bug 75032