*
*/
-#include "config.h"
+#include "sysdep.h"
#include "webcit.h"
#include "webserver.h"
strcpy(init_entry, "");
- /* Determine the fully qualified path name of webserver */
- snprintf(looking_for, sizeof looking_for, "%s/webserver ", setup_directory);
+ /* Determine the fully qualified path name of webcit */
+ snprintf(looking_for, sizeof looking_for, "%s/webcit ", setup_directory);
/* Pound through /etc/inittab line by line. Set have_entry to 1 if
- * an entry is found which we believe starts webserver.
+ * an entry is found which we believe starts webcit.
*/
infp = fopen("/etc/inittab", "r");
if (infp == NULL) {
#endif
char hostname[128];
char portname[128];
+ char command[SIZ];
struct utsname my_utsname;
struct stat etcinitd;
FILE *fp;
char *initfile = "/etc/init.d/webcit";
+ fp = fopen(initfile, "r");
+ if (fp != NULL) {
+ if (yesno("WebCit already appears to be configured to start at boot.\n"
+ "Would you like to keep your boot configuration as is?\n", 1) == 1) {
+ return;
+ }
+ fclose(fp);
+
+ }
+
/* Otherwise, prompt the user to create an entry. */
snprintf(question, sizeof question,
"Would you like to automatically start WebCit at boot?"
* in a previous install, if we are upgrading: read them out of
* the existing init script.
*/
-
- if ((stat("/etc/init.d/",&etcinitd) == -1) &&
+ if ((stat("/etc/init.d/", &etcinitd) == -1) &&
(errno == ENOENT))
- initfile = PREFIX"/webcit.init";
+ {
+ if ((stat("/etc/rc.d/init.d/", &etcinitd) == -1) &&
+ (errno == ENOENT))
+ initfile = WEBCITDIR"/webcit.init";
+ else
+ initfile = "/etc/rc.d/init.d/webcit";
+ }
fp = fopen(initfile, "r");
if (fp != NULL) {
}
- fp = fopen("/etc/init.d/webcit", "w");
- if (fp == NULL) {
- display_error("Cannot create /etc/init.d/webcit");
- return;
- }
+ fp = fopen(initfile, "w");
fprintf(fp, "#!/bin/sh\n"
"\n"
"case \"$1\" in\n"
"\n"
"start) echo -n \"Starting WebCit... \"\n"
- " if $WEBCIT_DIR/webserver "
+ " if $WEBCIT_DIR/webcit "
"-D/var/run/webcit.pid "
"-p$HTTP_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
" then\n"
" fi\n");
#ifdef HAVE_OPENSSL
fprintf(fp, " echo -n \"Starting WebCit SSL... \"\n"
- " if $WEBCIT_DIR/webserver "
+ " if $WEBCIT_DIR/webcit "
"-D/var/run/webcit-ssl.pid "
"-s -p$HTTPS_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
" then\n"
);
fclose(fp);
- chmod("/etc/init.d/webcit", 0755);
+ chmod(initfile, 0755);
/* Set up the run levels. */
system("/bin/rm -f /etc/rc?.d/[SK]??webcit 2>/dev/null");
- system("for x in 2 3 4 5 ; do [ -d /etc/rc$x.d ] && ln -s /etc/init.d/webcit /etc/rc$x.d/S84webcit ; done 2>/dev/null");
- system("for x in 0 6 S; do [ -d /etc/rc$x.d ] && ln -s /etc/init.d/webcit /etc/rc$x.d/K15webcit ; done 2>/dev/null");
+ snprintf(command, sizeof(command), "for x in 2 3 4 5 ; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/S84webcit ; done 2>/dev/null", initfile);
+ system(command);
+ snprintf(command, sizeof(command), "for x in 0 6 S; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/K15webcit ; done 2>/dev/null", initfile);
+ system(command);
}
}
/* Get started in a valid setup directory. */
- strcpy(setup_directory, PREFIX);
+ strcpy(setup_directory, WEBCITDIR);
if ( (using_web_installer) && (getenv("WEBCIT") != NULL) ) {
strcpy(setup_directory, getenv("WEBCIT"));
}