]> code.citadel.org Git - citadel.git/blobdiff - webcit/setup.c
setup now writes the /etc/rc*.d/ links to start and
[citadel.git] / webcit / setup.c
index 3ef1dcbcb124331e72e2cd2fca88af641ee80def..34981e4c78a17ba0be249314efc4d91d58c90364 100644 (file)
@@ -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;