]> code.citadel.org Git - citadel.git/commitdiff
* check for /etc/rc.d/init.d if /etc/init.d/ is not there and create the file there.
authorWilfried Göesgens <willi@citadel.org>
Mon, 19 Mar 2007 20:04:39 +0000 (20:04 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 19 Mar 2007 20:04:39 +0000 (20:04 +0000)
* use the preput-init file + dir for the shell commands.

citadel/setup.c

index dabf100c72e45721d7340423f3d3065a2259848b..cbeb6168512f2ac5d453cf7de2fd969316f936e4 100644 (file)
@@ -377,14 +377,21 @@ void install_init_scripts(void)
        struct stat etcinitd;
        FILE *fp;
        char *initfile = "/etc/init.d/citadel";
+       char command[SIZ];
 
        if (yesno("Would you like to automatically start Citadel at boot?\n", 1) == 0) {
                return;
        }
 
-       if ((stat("/etc/init.d/",&etcinitd) == -1) && 
+       if ((stat("/etc/init.d/", &etcinitd) == -1) && 
            (errno == ENOENT))
-               initfile = CTDLDIR"/citadel.init";
+       {
+               if ((stat("/etc/rc.d/init.d/", &etcinitd) == -1) &&
+                   (errno == ENOENT))
+                       initfile = CTDLDIR"/citadel.init";
+               else
+                       initfile = "/etc/rc.d/init.d/citadel";
+       }
 
        fp = fopen(initfile, "w");
        if (fp == NULL) {
@@ -440,12 +447,14 @@ void install_init_scripts(void)
        );
 
        fclose(fp);
-       chmod("/etc/init.d/citadel", 0755);
+       chmod(initfile, 0755);
 
        /* Set up the run levels. */
        system("/bin/rm -f /etc/rc?.d/[SK]??citadel 2>/dev/null");
-       system("for x in 2 3 4 5 ; do [ -d /etc/rc$x.d ] && ln -s /etc/init.d/citadel /etc/rc$x.d/S79citadel ; done 2>/dev/null");
-       system("for x in 0 6 S; do [ -d /etc/rc$x.d ] && ln -s /etc/init.d/citadel /etc/rc$x.d/K30citadel ; 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/S79citadel ; 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/K30citadel ; done 2>/dev/null", initfile);
+       system(command);
 
 }