EXEEXT=@EXEEXT@
CLIENT_TARGETS=citadel$(EXEEXT) whobbs$(EXEEXT) stress$(EXEEXT)
-SERVER_TARGETS=citserver setup $(CHKPWD)
+SERVER_TARGETS=citserver setup ctdlsvc $(CHKPWD)
SERV_MODULES=serv_chat.o \
serv_upgrade.o \
serv_smtp.o \
serv_newuser.c serv_pas2.c serv_pop3.c serv_rwho.c serv_smtp.c \
serv_spam.c serv_test.c serv_mrtg.c serv_spam.c serv_upgrade.c \
serv_vandelay.c serv_vcard.c serv_managesieve.c server_main.c \
- serv_sieve.c setup.c snprintf.c \
+ serv_sieve.c setup.c ctdlsvc.c snprintf.c \
stress.c support.c sysdep.c tools.c user_ops.c userlist.c \
whobbs.c vcard.c serv_notes.c serv_fulltext.c ft_wordbreaker.c \
crc16.c journaling.c citadel_dirs.c
setup: setup.o tools.o citadel_dirs.o
$(CC) setup.o tools.o citadel_dirs.o $(LDFLAGS) -o setup $(LIBS) $(SETUP_LIBS)
+ctdlsvc: ctdlsvc.o citadel_dirs.o
+ $(CC) ctdlsvc.o citadel_dirs.o $(LDFLAGS) -o ctdlsvc $(SETUP_LIBS)
+
chkpwd: chkpwd.o auth.o config.o citadel_dirs.o
$(CC) chkpwd.o auth.o config.o citadel_dirs.o $(LDFLAGS) -o chkpwd $(chkpwd_LIBS)
chmod 4755 chkpwd
FILE *sfp;
if (getservbyname(SERVICE_NAME, PROTO_NAME) == NULL) {
- for (i=0; i<=3; ++i) {
- progress("Adding service entry...", i, 3);
+ for (i=0; i<=2; ++i) {
+ progress("Adding service entry...", i, 2);
if (i == 0) {
sfp = fopen("/etc/services", "a");
if (sfp == NULL) {
}
+/*
+ * install_init_scripts() -- Try to configure to start Citadel at boot
+ *
+ */
+void install_init_scripts(void)
+{
+ FILE *fp;
+
+ if (yesno("Would you like to automatically start Citadel at boot?\n") == 0) {
+ return;
+ }
+
+ fp = fopen("/etc/init.d/citadel", "w");
+ if (fp == NULL) {
+ display_error("Cannot create /etc/init.d/citadel");
+ return;
+ }
+
+ fprintf(fp, "#!/bin/sh\n"
+ "\n"
+ "CITADEL_DIR=%s\n", setup_directory);
+ fprintf(fp, "\n"
+ "test -x $CITADEL_DIR/ctdlsvc || exit 0\n"
+ "test -d /var/run || exit 0\n"
+ "\n"
+ "case \"$1\" in\n"
+ "\n"
+ "start) echo -n \"Starting Citadel... \"\n"
+ " if $CITADEL_DIR/ctdlsvc /var/run/citadel.pid "
+ "$CITADEL_DIR/citserver "
+ "-t/dev/null\n"
+ " then\n"
+ " echo \"ok\"\n"
+ " else\n"
+ " echo \"failed\"\n"
+ " fi\n");
+ fprintf(fp, " ;;\n"
+ "stop) echo -n \"Stopping Citadel... \"\n"
+ " if $CITADEL_DIR/sendcommand DOWN >/dev/null 2>&1 ; then\n"
+ " echo \"ok\"\n"
+ " else\n"
+ " echo \"failed\"\n"
+ " fi\n"
+ " rm -f /var/run/citadel.pid 2>/dev/null\n");
+ fprintf(fp, " ;;\n"
+ "*) echo \"Usage: $0 {start|stop}\"\n"
+ " exit 1\n"
+ " ;;\n"
+ "esac\n"
+ );
+
+ fclose(fp);
+ chmod("/etc/init.d/citadel", 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");
+
+}
+
+
+
+
+
+
/*
* On systems which use xinetd, see if we can offer to install Citadel as
* the default telnet target.
/* Determine our host name, in case we need to use it as a default */
uname(&my_utsname);
+ /* Try to stop Citadel if we can */
+ if (!access("/etc/init.d/citadel", X_OK)) {
+ for (a=0; a<=2; ++a) {
+ progress("Stopping the Citadel service...", a, 2);
+ if (a == 0) system("/etc/init.d/citadel stop >/dev/null 2>&1");
+ sleep(1);
+ }
+ }
+
/* Make sure Citadel is not running. */
if (test_server() == 0) {
important_message("Citadel Setup",
sleep(1);
progress("Setting file permissions", 4, 4);
- /* See if we can start the Citadel service. */
- /* FIXME do this */
+ /*
+ * If we're running on SysV, install init scripts.
+ */
+ if (!access("/var/run", W_OK)) {
+ install_init_scripts();
+
+ if (!access("/etc/init.d/citadel", X_OK)) {
+ for (a=0; a<=2; ++a) {
+ progress("Starting the Citadel service...", a, 2);
+ if (a == 0) system("/etc/init.d/citadel start >/dev/null 2>&1");
+ sleep(1);
+ }
+ }
+
+ if (test_server() == 0) {
+ important_message("Setup finished",
+ "Setup of the Citadel server is complete.\n"
+ "If you will be using WebCit, please run its\n"
+ "setup program now; otherwise, run './citadel'\n"
+ "to log in.\n");
+ }
+ else {
+ important_message("Setup failed",
+ "Setup is finished, but the Citadel server failed to start.\n"
+ "Go back and check your configuration.\n"
+ );
+ }
- if (test_server() == 0) {
- important_message("Setup finished",
- "Setup of the Citadel server is complete.\n"
- "If you will be using WebCit, please run its\n"
- "setup program now; otherwise, run './citadel'\n"
- "to log in.\n");
}
+
else {
important_message("Setup finished",
"Setup is finished. You may now start the server.");