From: Art Cancro Date: Mon, 27 Nov 2006 17:34:43 +0000 (+0000) Subject: setup now writes the /etc/rc*.d/ links to start and X-Git-Tag: v7.86~3827 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=39574079432114857da30a7e2d229fb1dad7a23f;p=citadel.git setup now writes the /etc/rc*.d/ links to start and stop webcit during run level changes, if running on a system that has a SysV init style directory layout. This *should* work on most Linuxes, including those running upstart, but we don't know yet. It should also work on Solaris. WebCit is also started or restarted at the end of setup in this case. --- diff --git a/webcit/setup.c b/webcit/setup.c index 3ef1dcbcb..34981e4c7 100644 --- a/webcit/setup.c +++ b/webcit/setup.c @@ -28,7 +28,7 @@ int using_web_installer = 0; char suggested_url[SIZ]; /* - * Set an entry in inittab to the desired state + * Delete an entry from /etc/inittab */ void delete_init_entry(char *which_entry) { @@ -564,6 +564,12 @@ void install_init_scripts(void) fclose(fp); chmod("/etc/init.d/webcit", 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"); + } @@ -673,26 +679,27 @@ int main(int argc, char *argv[]) */ if (!access("/var/run", W_OK)) { install_init_scripts(); - } - /* FIXME - for (a=0; a<=3; ++a) { - progress("Starting the WebCit service...", a, 3); - if (a == 0) start_the_service(); - sleep(1); - } - */ + if (!access("/etc/init.d/webcit", X_OK)) { + for (a=0; a<=2; ++a) { + progress("Restarting the WebCit service...", a, 3); + if (a == 0) system("/etc/init.d/webcit stop >/dev/null 2>&1"); + if (a == 1) system("/etc/init.d/webcit start >/dev/null 2>&1"); + sleep(1); + } + } - sprintf(aaa, - "Setup is finished. You may now log in.\n" - "Point your web browser at %s\n", suggested_url - ); - important_message("Setup finished", aaa); + sprintf(aaa, + "Setup is finished. You may now log in.\n" + "Point your web browser at %s\n", suggested_url + ); + important_message("Setup finished", aaa); + } - /* else { + else { important_message("Setup finished", "Setup is finished. You may now start the server."); - } */ + } cleanup(0); return 0;