diff options
author | Ernst de Haan <znerd@FreeBSD.org> | 2002-04-03 20:42:07 +0000 |
---|---|---|
committer | Ernst de Haan <znerd@FreeBSD.org> | 2002-04-03 20:42:07 +0000 |
commit | d0f2cbece8e3b221960dc6bbbc78f32036560203 (patch) | |
tree | d358b93575eb3a0b2c4f3e9e7fbc0b4a2da89993 /www/tomcat41/files/daemonctl.c | |
parent | Update to 0.51 (diff) |
Now checking for the Java VM too in the control
program. Bumped PORTREVISION.
Diffstat (limited to '')
-rw-r--r-- | www/tomcat41/files/daemonctl.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/www/tomcat41/files/daemonctl.c b/www/tomcat41/files/daemonctl.c index 49a45728ac74..a8b09bfb79b1 100644 --- a/www/tomcat41/files/daemonctl.c +++ b/www/tomcat41/files/daemonctl.c @@ -4,7 +4,7 @@ * * Daemon control program. * - * $FreeBSD: /tmp/pcvs/ports/www/tomcat41/files/Attic/daemonctl.c,v 1.2 2002-04-03 19:49:27 znerd Exp $ + * $FreeBSD: /tmp/pcvs/ports/www/tomcat41/files/Attic/daemonctl.c,v 1.3 2002-04-03 20:42:07 znerd Exp $ */ #include <assert.h> @@ -17,10 +17,11 @@ #include <syslog.h> #include <unistd.h> #include <sys/errno.h> +#include <sys/stat.h> #include <sys/types.h> #include <sys/uio.h> -#define MAX_FILE_SIZE 32 +#define MAX_FILE_SIZE 32 #define ERR_ILLEGAL_ARGUMENT 1 #define ERR_PID_FILE_NOT_FOUND 2 @@ -33,6 +34,11 @@ #define ERR_STDOUT_LOGFILE_OPEN 9 #define ERR_STDERR_LOGFILE_OPEN 10 #define ERR_FORK_FAILED 11 +#define ERR_STAT_JAVA_HOME 12 +#define ERR_JAVA_HOME_NOT_DIR 13 +#define ERR_STAT_JAVA_CMD 14 +#define ERR_JAVA_CMD_NOT_FILE 15 +#define ERR_JAVA_CMD_NOT_EXECUTABLE 16 #define private static @@ -236,6 +242,7 @@ void start(void) { int result; int stdoutLogFile; int stderrLogFile; + struct stat sb; /* Open and read the PID file */ file = openPIDFile(); @@ -255,7 +262,40 @@ void start(void) { printf(" [ DONE ]\n"); - /* XXX: printf(">> Checking for Java VM..."); */ + printf(">> Checking for Java VM..."); + result = stat("%%JAVA_HOME%%", &sb); + if (result != 0) { + printf(" [ FAILED ]\n"); + fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%: "); + perror(NULL); + exit(ERR_STAT_JAVA_HOME); + } + if (!S_ISDIR(sb.st_mode)) { + printf(" [ FAILED ]\n"); + fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Java home directory %%JAVA_HOME%% is not a directory.\n"); + exit(ERR_JAVA_HOME_NOT_DIR); + } + + result = stat("%%JAVA_HOME%%/%%JAVA_CMD%%", &sb); + if (result != 0) { + printf(" [ FAILED ]\n"); + fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%/%%JAVA_CMD%%: "); + perror(NULL); + exit(ERR_STAT_JAVA_CMD); + } + if (!S_ISREG(sb.st_mode)) { + printf(" [ FAILED ]\n"); + fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA_HOME%%/%%JAVA_CMD%% is not a regular file.\n"); + exit(ERR_JAVA_CMD_NOT_FILE); + } + result = access("%%JAVA_HOME%%/%%JAVA_CMD%%", X_OK); + if (result != 0) { + printf(" [ FAILED ]\n"); + fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA_HOME%%/%%JAVA_CMD%% is not executable: "); + perror(NULL); + exit(ERR_JAVA_CMD_NOT_EXECUTABLE); + } + printf(" [ DONE ]\n"); printf(">> Starting %%APP_TITLE%%..."); |