From a7cd049a298d006f67b36dcd13f7f17774b5df92 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Mon, 19 Mar 2007 20:04:39 +0000 Subject: [PATCH] * check for /etc/rc.d/init.d if /etc/init.d/ is not there and create the file there. * use the preput-init file + dir for the shell commands. --- citadel/setup.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/citadel/setup.c b/citadel/setup.c index dabf100c7..cbeb61685 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -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); } -- 2.39.2