1995-10-22 20:15:07 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
1997-01-14 07:20:47 +00:00
|
|
|
* $FreeBSD$
|
1995-10-22 20:15:07 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Coranth Gryphon. All rights reserved.
|
1996-09-01 08:17:14 +00:00
|
|
|
* Copyright (c) 1996
|
|
|
|
* Jordan K. Hubbard. All rights reserved.
|
1995-10-22 20:15:07 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
1996-09-01 08:17:14 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
|
1995-10-22 20:15:07 +00:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
1996-09-01 08:17:14 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR THEIR PETS BE LIABLE
|
1995-10-22 20:15:07 +00:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
1997-01-03 06:32:39 +00:00
|
|
|
#include <sys/param.h>
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-01-21 19:38:05 +00:00
|
|
|
|
1995-10-26 08:56:18 +00:00
|
|
|
#define APACHE_HELPFILE "apache"
|
1996-06-08 12:01:25 +00:00
|
|
|
#define FREEBSD_GIF "http://www.freebsd.org/gifs/powerlogo.gif"
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1995-10-30 08:04:58 +00:00
|
|
|
/* These change if the package uses different defaults */
|
|
|
|
|
1996-06-15 17:58:51 +00:00
|
|
|
#define DEFAULT_USER "bin"
|
|
|
|
#define DEFAULT_GROUP "bin"
|
1996-01-21 19:38:05 +00:00
|
|
|
#define WELCOME_FILE "index.html"
|
|
|
|
#define USER_HOMEDIR "public_html"
|
|
|
|
|
1995-10-30 08:04:58 +00:00
|
|
|
#define APACHE_BASE "/usr/local/www"
|
1995-11-12 20:39:18 +00:00
|
|
|
#define DATA_SUBDIR "data"
|
1996-01-21 19:38:05 +00:00
|
|
|
#define CONFIG_SUBDIR "server/conf"
|
|
|
|
|
|
|
|
#define LOGS_SUBDIR "/var/log"
|
|
|
|
#define ACCESS_LOGNAME "httpd.access"
|
|
|
|
#define ERROR_LOGNAME "httpd.error"
|
1995-10-30 08:04:58 +00:00
|
|
|
|
|
|
|
/* Set up the structure to hold configuration information */
|
|
|
|
/* Note that this is only what we could fit onto the one screen */
|
|
|
|
|
1996-03-18 15:28:10 +00:00
|
|
|
typedef struct {
|
1995-10-22 20:15:07 +00:00
|
|
|
char docroot[128]; /* DocumentRoot */
|
|
|
|
char userdir[128]; /* UserDir */
|
1995-10-30 08:04:58 +00:00
|
|
|
char welcome[32]; /* Welcome Doc */
|
1995-10-22 20:15:07 +00:00
|
|
|
char email[64]; /* ServerAdmin */
|
|
|
|
char hostname[64]; /* ServerName */
|
1996-01-21 19:38:05 +00:00
|
|
|
char logdir[64]; /* Where to put Logs */
|
|
|
|
char accesslog[32]; /* access_log */
|
|
|
|
char errorlog[32]; /* error_log */
|
|
|
|
char defuser[16]; /* default user id */
|
|
|
|
char defgroup[16]; /* default group id */
|
1995-10-22 20:15:07 +00:00
|
|
|
} ApacheConf;
|
|
|
|
|
|
|
|
static ApacheConf tconf;
|
|
|
|
|
|
|
|
#define APACHE_DOCROOT_LEN 128
|
|
|
|
#define APACHE_USERDIR_LEN 128
|
1995-10-30 08:04:58 +00:00
|
|
|
#define APACHE_WELCOME_LEN 32
|
1995-10-22 20:15:07 +00:00
|
|
|
#define APACHE_EMAIL_LEN 64
|
|
|
|
#define APACHE_HOSTNAME_LEN 64
|
1996-01-21 19:38:05 +00:00
|
|
|
#define APACHE_LOGDIR_LEN 64
|
|
|
|
#define APACHE_ACCESSLOG_LEN 32
|
|
|
|
#define APACHE_ERRORLOG_LEN 32
|
|
|
|
#define APACHE_DEFUSER_LEN 16
|
|
|
|
#define APACHE_DEFGROUP_LEN 16
|
1995-10-22 20:15:07 +00:00
|
|
|
|
|
|
|
static int okbutton, cancelbutton;
|
|
|
|
|
|
|
|
/* What the screen size is meant to be */
|
|
|
|
#define APACHE_DIALOG_Y 0
|
1996-01-21 19:38:05 +00:00
|
|
|
#define APACHE_DIALOG_X 0
|
|
|
|
#define APACHE_DIALOG_WIDTH COLS
|
1995-10-22 20:15:07 +00:00
|
|
|
#define APACHE_DIALOG_HEIGHT LINES - 2
|
|
|
|
|
|
|
|
static Layout layout[] = {
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_HOSTNAME 0
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 1, 2, 30, HOSTNAME_FIELD_LEN - 1,
|
1995-10-22 20:15:07 +00:00
|
|
|
"Host Name:",
|
|
|
|
"What name to report this host as to client browsers",
|
|
|
|
tconf.hostname, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_EMAIL 1
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 1, 40, 32, APACHE_EMAIL_LEN - 1,
|
1995-10-22 20:15:07 +00:00
|
|
|
"Email Address:",
|
|
|
|
"The email address of the site maintainer, e.g. webmaster@bar.com",
|
|
|
|
tconf.email, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_WELCOME 2
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 5, 5, 20, APACHE_WELCOME_LEN - 1,
|
1996-01-21 19:38:05 +00:00
|
|
|
"Default Document:",
|
|
|
|
"The name of the default document found in each directory",
|
|
|
|
tconf.welcome, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_DEFUSER 3
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 5, 40, 14, APACHE_DEFUSER_LEN - 1,
|
1996-01-21 19:38:05 +00:00
|
|
|
"Default UserID:", "Default UID for access to web pages",
|
|
|
|
tconf.defuser, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_DEFGROUP 4
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 5, 60, 14, APACHE_DEFGROUP_LEN - 1,
|
1996-01-21 19:38:05 +00:00
|
|
|
"Default Group ID:", "Default GID for access to web pages",
|
|
|
|
tconf.defgroup, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_DOCROOT 5
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 10, 4, 36, APACHE_DOCROOT_LEN - 1,
|
1995-10-22 20:15:07 +00:00
|
|
|
"Root Document Path:",
|
|
|
|
"The top directory that holds the system web pages",
|
|
|
|
tconf.docroot, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_USERDIR 6
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 10, 50, 14, APACHE_USERDIR_LEN - 1,
|
1995-10-22 20:15:07 +00:00
|
|
|
"User Directory:",
|
|
|
|
"Personal sub-directory that holds users' web pages (eg. ~/Web)",
|
|
|
|
tconf.userdir, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_LOGDIR 7
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 14, 4, 28, APACHE_LOGDIR_LEN - 1,
|
1996-01-21 19:38:05 +00:00
|
|
|
"Log Dir:", "Directory to put httpd log files",
|
|
|
|
tconf.logdir, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_ACCESSLOG 8
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 14, 38, 16, APACHE_ACCESSLOG_LEN - 1,
|
1996-01-21 19:38:05 +00:00
|
|
|
"Access Log:", "Name of log file to report access",
|
|
|
|
tconf.accesslog, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_ERRORLOG 9
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 14, 60, 16, APACHE_ERRORLOG_LEN - 1,
|
1996-01-21 19:38:05 +00:00
|
|
|
"Error Log:", "Name of log file to report errors",
|
|
|
|
tconf.errorlog, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_OKBUTTON 10
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 19, 15, 0, 0,
|
1995-10-22 20:15:07 +00:00
|
|
|
"OK", "Select this if you are happy with these settings",
|
|
|
|
&okbutton, BUTTONOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_CANCELBUTTON 11
|
1996-03-18 15:28:10 +00:00
|
|
|
{ 19, 45, 0, 0,
|
1995-10-22 20:15:07 +00:00
|
|
|
"CANCEL", "Select this if you wish to cancel this screen",
|
|
|
|
&cancelbutton, BUTTONOBJ, NULL },
|
1996-03-18 15:28:10 +00:00
|
|
|
{ NULL },
|
1995-10-22 20:15:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This is it - how to get Apache setup values */
|
1996-04-23 01:29:35 +00:00
|
|
|
static int
|
1996-03-18 15:28:10 +00:00
|
|
|
apacheOpenDialog(void)
|
1995-10-22 20:15:07 +00:00
|
|
|
{
|
|
|
|
WINDOW *ds_win;
|
1997-01-03 06:32:39 +00:00
|
|
|
ComposeObj *obj = NULL;
|
|
|
|
int n = 0, cancel = FALSE;
|
1995-10-22 20:15:07 +00:00
|
|
|
int max;
|
|
|
|
char *tmp;
|
|
|
|
char title[80];
|
|
|
|
|
|
|
|
/* We need a curses window */
|
1997-01-03 06:32:39 +00:00
|
|
|
if (!(ds_win = openLayoutDialog(APACHE_HELPFILE, " Apache HTTPD Configuration ",
|
|
|
|
APACHE_DIALOG_X, APACHE_DIALOG_Y, APACHE_DIALOG_WIDTH, APACHE_DIALOG_HEIGHT))) {
|
1995-10-22 20:15:07 +00:00
|
|
|
beep();
|
|
|
|
msgConfirm("Cannot open apache dialog window!!");
|
1997-01-03 06:32:39 +00:00
|
|
|
return DITEM_SUCCESS;
|
1995-10-22 20:15:07 +00:00
|
|
|
}
|
|
|
|
|
1997-01-03 06:32:39 +00:00
|
|
|
/* Draw a sub-box for the path configuration */
|
1996-01-21 19:38:05 +00:00
|
|
|
draw_box(ds_win, APACHE_DIALOG_Y + 9, APACHE_DIALOG_X + 1, APACHE_DIALOG_HEIGHT - 13, APACHE_DIALOG_WIDTH - 2,
|
1995-10-22 20:15:07 +00:00
|
|
|
dialog_attr, border_attr);
|
|
|
|
wattrset(ds_win, dialog_attr);
|
|
|
|
sprintf(title, " Path Configuration ");
|
|
|
|
mvwaddstr(ds_win, APACHE_DIALOG_Y + 9, APACHE_DIALOG_X + 22, title);
|
|
|
|
|
|
|
|
/** Initialize the config Data Structure **/
|
|
|
|
bzero(&tconf, sizeof(tconf));
|
|
|
|
|
|
|
|
tmp = variable_get(VAR_DOMAINNAME);
|
1996-03-18 15:28:10 +00:00
|
|
|
if (tmp) {
|
1995-10-22 20:15:07 +00:00
|
|
|
sprintf(tconf.email, "webmaster@%s", tmp);
|
|
|
|
sprintf(tconf.hostname, "www.%s", tmp);
|
|
|
|
}
|
|
|
|
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.defuser, DEFAULT_USER);
|
|
|
|
SAFE_STRCPY(tconf.defgroup, DEFAULT_GROUP);
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.userdir, USER_HOMEDIR);
|
|
|
|
SAFE_STRCPY(tconf.welcome, WELCOME_FILE);
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.logdir, LOGS_SUBDIR);
|
|
|
|
SAFE_STRCPY(tconf.accesslog, ACCESS_LOGNAME);
|
|
|
|
SAFE_STRCPY(tconf.errorlog, ERROR_LOGNAME);
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1996-01-21 19:38:05 +00:00
|
|
|
sprintf(tconf.docroot, "%s/%s", APACHE_BASE,DATA_SUBDIR);
|
1995-10-22 20:15:07 +00:00
|
|
|
|
|
|
|
/* Some more initialisation before we go into the main input loop */
|
1997-01-03 06:32:39 +00:00
|
|
|
obj = initLayoutDialog(ds_win, layout, APACHE_DIALOG_X, APACHE_DIALOG_Y, &max);
|
|
|
|
|
|
|
|
cancelbutton = okbutton = 0;
|
|
|
|
while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel)) {
|
|
|
|
if (n == LAYOUT_HOSTNAME) {
|
|
|
|
if ((tmp = index(tconf.hostname, '.')) != NULL) {
|
|
|
|
sprintf(tconf.email, "webmaster@%s", tmp + 1);
|
|
|
|
RefreshStringObj(layout[LAYOUT_EMAIL].obj);
|
1996-03-18 15:28:10 +00:00
|
|
|
}
|
1997-01-03 06:32:39 +00:00
|
|
|
}
|
1995-10-22 20:15:07 +00:00
|
|
|
}
|
1997-01-03 06:32:39 +00:00
|
|
|
|
1995-10-22 20:15:07 +00:00
|
|
|
/* Clear this crap off the screen */
|
1996-08-03 10:11:56 +00:00
|
|
|
dialog_clear_norefresh();
|
1995-10-22 20:15:07 +00:00
|
|
|
use_helpfile(NULL);
|
|
|
|
|
|
|
|
if (cancel)
|
1996-04-28 03:27:26 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE;
|
|
|
|
return DITEM_SUCCESS | DITEM_RESTORE;
|
1995-10-22 20:15:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
configApache(dialogMenuItem *self)
|
1995-10-22 20:15:07 +00:00
|
|
|
{
|
1996-01-21 19:38:05 +00:00
|
|
|
int i;
|
1995-10-27 17:31:03 +00:00
|
|
|
char company[64], file[128];
|
1995-10-22 20:15:07 +00:00
|
|
|
char *tptr;
|
|
|
|
FILE *fptr;
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1995-11-05 01:00:31 +00:00
|
|
|
/* Be optimistic */
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_SUCCESS;
|
1996-04-29 19:34:25 +00:00
|
|
|
|
1996-08-03 10:11:56 +00:00
|
|
|
dialog_clear_norefresh();
|
1995-10-26 08:11:24 +00:00
|
|
|
msgConfirm("Since you elected to install the WEB server, we'll now add the\n"
|
|
|
|
"Apache HTTPD package and set up a few configuration files.");
|
1996-11-04 12:56:33 +00:00
|
|
|
i = package_add(PACKAGE_APACHE);
|
1996-04-28 03:27:26 +00:00
|
|
|
if (DITEM_STATUS(i) != DITEM_SUCCESS) {
|
1995-10-26 08:11:24 +00:00
|
|
|
msgConfirm("Hmmmmm. Looks like we weren't able to fetch the Apache WEB server\n"
|
|
|
|
"package. You may wish to fetch and configure it by hand by looking\n"
|
|
|
|
"in /usr/ports/net/apache (in the ports collection) or looking for the\n"
|
1996-11-04 12:56:33 +00:00
|
|
|
"precompiled apache package in packages/networking/%s.", PACKAGE_APACHE);
|
1996-04-29 19:34:25 +00:00
|
|
|
return i | DITEM_RESTORE;
|
1995-10-26 08:11:24 +00:00
|
|
|
}
|
1996-04-13 13:32:15 +00:00
|
|
|
|
1996-08-03 10:11:56 +00:00
|
|
|
dialog_clear_norefresh();
|
1995-10-27 02:12:58 +00:00
|
|
|
i = apacheOpenDialog();
|
1996-04-28 03:27:26 +00:00
|
|
|
if (DITEM_STATUS(i) != DITEM_SUCCESS) {
|
1995-10-27 02:12:58 +00:00
|
|
|
msgConfirm("Configuration of the Apache WEB server was cancelled per\n"
|
|
|
|
"user request.");
|
1996-04-28 03:27:26 +00:00
|
|
|
return i;
|
1995-10-27 02:12:58 +00:00
|
|
|
}
|
1995-10-22 20:15:07 +00:00
|
|
|
/*** Fix defaults for invalid value ***/
|
1996-04-28 03:27:26 +00:00
|
|
|
if (!tconf.logdir[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.logdir, LOGS_SUBDIR);
|
1996-04-28 03:27:26 +00:00
|
|
|
if (!tconf.accesslog[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.accesslog, ACCESS_LOGNAME);
|
1996-04-28 03:27:26 +00:00
|
|
|
if (!tconf.errorlog[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.errorlog, ERROR_LOGNAME);
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-04-28 03:27:26 +00:00
|
|
|
if (!tconf.welcome[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.welcome, WELCOME_FILE);
|
1996-04-28 03:27:26 +00:00
|
|
|
if (!tconf.userdir[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.userdir, USER_HOMEDIR);
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-04-28 03:27:26 +00:00
|
|
|
if (!tconf.defuser[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.defuser, DEFAULT_USER);
|
1996-04-28 03:27:26 +00:00
|
|
|
if (!tconf.defgroup[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.defgroup, DEFAULT_GROUP);
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1995-10-22 20:15:07 +00:00
|
|
|
/*** If the user did not specify a directory, use default ***/
|
|
|
|
|
1996-03-18 15:28:10 +00:00
|
|
|
if (tconf.docroot[strlen(tconf.docroot) - 1] == '/')
|
|
|
|
tconf.docroot[strlen(tconf.docroot) - 1] = '\0';
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1995-10-27 17:31:03 +00:00
|
|
|
if (!tconf.docroot[0])
|
1996-04-28 03:27:26 +00:00
|
|
|
sprintf(tconf.docroot, "%s/%s", APACHE_BASE, DATA_SUBDIR);
|
1995-10-22 20:15:07 +00:00
|
|
|
|
|
|
|
/*** If DocRoot does not exist, create it ***/
|
|
|
|
|
1996-03-18 15:28:10 +00:00
|
|
|
if (!directory_exists(tconf.docroot))
|
1995-10-27 17:31:03 +00:00
|
|
|
vsystem("mkdir -p %s", tconf.docroot);
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-03-18 15:28:10 +00:00
|
|
|
if (directory_exists(tconf.docroot)) {
|
1996-04-28 03:27:26 +00:00
|
|
|
sprintf(file, "%s/%s", tconf.docroot, tconf.welcome);
|
1996-03-18 15:28:10 +00:00
|
|
|
if (!file_readable(file)) {
|
1996-04-23 01:29:35 +00:00
|
|
|
tptr = msgGetInput(NULL, "What is your company name?");
|
1996-01-21 19:38:05 +00:00
|
|
|
if (tptr && tptr[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(company, tptr);
|
1995-10-22 20:15:07 +00:00
|
|
|
else
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(company, "our Web Page");
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1995-10-27 02:12:58 +00:00
|
|
|
msgNotify("Creating sample web page...");
|
1995-10-22 20:15:07 +00:00
|
|
|
fptr = fopen(file,"w");
|
1996-03-18 15:28:10 +00:00
|
|
|
if (fptr) {
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "<CENTER>\n<TITLE>Welcome Page</TITLE>\n");
|
|
|
|
fprintf(fptr, "<H1>Welcome to %s </H1>\n</CENTER>\n",company);
|
|
|
|
fprintf(fptr, "<P><HR SIZE=4>\n<CENTER>\n");
|
|
|
|
fprintf(fptr, "<A HREF=\"http://www.FreeBSD.org/What\">\n");
|
1996-06-08 12:01:25 +00:00
|
|
|
fprintf(fptr, "<IMG SRC=\"%s\" ALIGN=CENTER BORDER=0 ", FREEBSD_GIF);
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, " ALT=\"Powered by FreeBSD\"></A>\n");
|
|
|
|
if (!tconf.email[0]) {
|
1995-10-22 20:15:07 +00:00
|
|
|
if ((tptr = variable_get(VAR_DOMAINNAME)))
|
1996-04-28 03:27:26 +00:00
|
|
|
sprintf(tconf.email, "root@%s", tptr);
|
1995-10-22 20:15:07 +00:00
|
|
|
}
|
1996-03-18 15:28:10 +00:00
|
|
|
if (tconf.email[0]) {
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "<ADDRESS><H4>\n");
|
|
|
|
fprintf(fptr, " For questions or comments, please send mail to:\n");
|
|
|
|
fprintf(fptr, " <A HREF=\"mailto:%s\">%s</A>\n",
|
1995-10-27 17:31:03 +00:00
|
|
|
tconf.email, tconf.email);
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "</H4></ADDRESS>\n");
|
1995-10-22 20:15:07 +00:00
|
|
|
}
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "</CENTER>\n\n");
|
1995-10-22 20:15:07 +00:00
|
|
|
fclose(fptr);
|
|
|
|
}
|
1995-11-05 01:00:31 +00:00
|
|
|
else {
|
1995-10-22 20:15:07 +00:00
|
|
|
msgConfirm("Unable to create sample Web Page.");
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1995-11-05 01:00:31 +00:00
|
|
|
}
|
1995-10-22 20:15:07 +00:00
|
|
|
}
|
|
|
|
}
|
1995-11-05 01:00:31 +00:00
|
|
|
else {
|
1995-10-22 20:15:07 +00:00
|
|
|
msgConfirm("Unable to create Document Root Directory.");
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1995-11-05 01:00:31 +00:00
|
|
|
}
|
1995-10-22 20:15:07 +00:00
|
|
|
|
|
|
|
msgNotify("Writing configuration files....");
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1996-04-28 01:07:27 +00:00
|
|
|
(void)vsystem("mkdir -p %s/%s", APACHE_BASE, CONFIG_SUBDIR);
|
|
|
|
sprintf(file, "%s/%s/access.conf", APACHE_BASE, CONFIG_SUBDIR);
|
1995-10-22 20:15:07 +00:00
|
|
|
if (file_readable(file))
|
1995-10-27 17:31:03 +00:00
|
|
|
vsystem("mv -f %s %s.ORIG", file, file);
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1995-10-22 20:15:07 +00:00
|
|
|
fptr = fopen(file,"w");
|
1996-03-18 15:28:10 +00:00
|
|
|
if (fptr) {
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "<Directory %s/cgi-bin>\n", APACHE_BASE);
|
|
|
|
fprintf(fptr, "Options Indexes FollowSymLinks\n");
|
|
|
|
fprintf(fptr, "</Directory>\n");
|
|
|
|
fprintf(fptr, "\n");
|
|
|
|
fprintf(fptr, "<Directory %s>\n", tconf.docroot);
|
|
|
|
fprintf(fptr, "Options Indexes FollowSymLinks\n");
|
|
|
|
fprintf(fptr, "AllowOverride All\n");
|
|
|
|
fprintf(fptr, "</Directory>\n");
|
|
|
|
fprintf(fptr, "\n");
|
1995-10-22 20:15:07 +00:00
|
|
|
fclose(fptr);
|
|
|
|
}
|
1995-11-05 01:00:31 +00:00
|
|
|
else {
|
1995-10-22 20:15:07 +00:00
|
|
|
msgConfirm("Could not create %s",file);
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1995-11-05 01:00:31 +00:00
|
|
|
}
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-04-28 01:07:27 +00:00
|
|
|
sprintf(file, "%s/%s/httpd.conf", APACHE_BASE, CONFIG_SUBDIR);
|
1995-10-22 20:15:07 +00:00
|
|
|
if (file_readable(file))
|
1995-10-27 17:31:03 +00:00
|
|
|
vsystem("mv -f %s %s.ORIG", file, file);
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1995-10-22 20:15:07 +00:00
|
|
|
fptr = fopen(file,"w");
|
1996-03-18 15:28:10 +00:00
|
|
|
if (fptr) {
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "ServerType standalone\n");
|
|
|
|
fprintf(fptr, "Port 80\n");
|
|
|
|
fprintf(fptr, "TimeOut 400\n");
|
|
|
|
fprintf(fptr, "\n");
|
|
|
|
fprintf(fptr, "ErrorLog %s/%s\n", LOGS_SUBDIR, ERROR_LOGNAME);
|
|
|
|
fprintf(fptr, "TransferLog %s/%s\n", LOGS_SUBDIR, ACCESS_LOGNAME);
|
|
|
|
fprintf(fptr, "PidFile /var/run/httpd.pid\n");
|
|
|
|
fprintf(fptr, "\n");
|
|
|
|
fprintf(fptr, "StartServers 5\n");
|
|
|
|
fprintf(fptr, "MinSpareServers 5\n");
|
|
|
|
fprintf(fptr, "MaxSpareServers 10\n");
|
|
|
|
fprintf(fptr, "MaxRequestsPerChild 30\n");
|
|
|
|
fprintf(fptr, "MaxClients 150\n");
|
|
|
|
fprintf(fptr, "\n");
|
|
|
|
fprintf(fptr, "User %s\n",tconf.defuser);
|
|
|
|
fprintf(fptr, "Group %s\n",tconf.defgroup);
|
|
|
|
fprintf(fptr, "\n");
|
1995-10-22 20:15:07 +00:00
|
|
|
|
|
|
|
if (tconf.email[0])
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "ServerAdmin %s\n", tconf.email);
|
1995-10-22 20:15:07 +00:00
|
|
|
if (tconf.hostname[0])
|
1996-04-28 03:27:26 +00:00
|
|
|
fprintf(fptr, "ServerName %s\n", tconf.hostname);
|
1995-10-22 20:15:07 +00:00
|
|
|
|
|
|
|
fclose(fptr);
|
|
|
|
}
|
1995-11-05 01:00:31 +00:00
|
|
|
else {
|
1995-10-22 20:15:07 +00:00
|
|
|
msgConfirm("Could not create %s",file);
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1995-11-05 01:00:31 +00:00
|
|
|
}
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-04-28 01:07:27 +00:00
|
|
|
sprintf(file, "%s/%s/srm.conf", APACHE_BASE, CONFIG_SUBDIR);
|
1995-10-22 20:15:07 +00:00
|
|
|
if (file_readable(file))
|
1995-10-27 17:31:03 +00:00
|
|
|
vsystem("mv -f %s %s.ORIG", file, file);
|
1995-10-22 20:15:07 +00:00
|
|
|
fptr = fopen(file,"w");
|
1996-03-18 15:28:10 +00:00
|
|
|
if (fptr) {
|
1996-04-23 01:29:35 +00:00
|
|
|
fprintf(fptr, "FancyIndexing on\n");
|
|
|
|
fprintf(fptr, "DefaultType text/plain\n");
|
|
|
|
fprintf(fptr, "IndexIgnore */.??* *~ *# */HEADER* */README* */RCS\n");
|
|
|
|
fprintf(fptr, "HeaderName HEADER\n");
|
|
|
|
fprintf(fptr, "ReadmeName README\n");
|
|
|
|
fprintf(fptr, "AccessFileName .htaccess\n");
|
|
|
|
fprintf(fptr, "\n");
|
|
|
|
fprintf(fptr, "AddEncoding x-compress Z\n");
|
|
|
|
fprintf(fptr, "AddEncoding x-gzip gz\n");
|
|
|
|
fprintf(fptr, "DefaultIcon /icons/unknown.gif\n");
|
|
|
|
fprintf(fptr, "\n");
|
|
|
|
fprintf(fptr, "AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip\n");
|
|
|
|
fprintf(fptr, "AddIconByType (TXT,/icons/text.gif) text/*\n");
|
|
|
|
fprintf(fptr, "AddIconByType (IMG,/icons/image2.gif) image/*\n");
|
|
|
|
fprintf(fptr, "AddIconByType (SND,/icons/sound2.gif) audio/*\n");
|
|
|
|
fprintf(fptr, "AddIconByType (VID,/icons/movie.gif) video/*\n");
|
|
|
|
fprintf(fptr, "\n");
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-04-23 01:29:35 +00:00
|
|
|
fprintf(fptr, "AddIcon /icons/text.gif .ps .shtml\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/movie.gif .mpg .qt\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/binary.gif .bin\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/burst.gif .wrl\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/binhex.gif .hqx .sit\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/uu.gif .uu\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/tar.gif .tar\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/back.gif ..\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/dir.gif ^^DIRECTORY^^\n");
|
|
|
|
fprintf(fptr, "AddIcon /icons/blank.gif ^^BLANKICON^^\n");
|
|
|
|
fprintf(fptr, "\n");
|
1995-10-22 20:15:07 +00:00
|
|
|
|
1996-04-23 01:29:35 +00:00
|
|
|
fprintf(fptr, "ScriptAlias /cgi_bin/ %s/cgi_bin/\n",APACHE_BASE);
|
|
|
|
fprintf(fptr, "Alias /icons/ %s/icons/\n",APACHE_BASE);
|
|
|
|
fprintf(fptr, "DocumentRoot %s\n",tconf.docroot);
|
|
|
|
fprintf(fptr, "UserDir %s\n", tconf.userdir);
|
|
|
|
fprintf(fptr, "DirectoryIndex %s\n", tconf.welcome);
|
|
|
|
fprintf(fptr, "\n");
|
1995-10-22 20:15:07 +00:00
|
|
|
|
|
|
|
fclose(fptr);
|
|
|
|
}
|
1995-11-05 01:00:31 +00:00
|
|
|
else {
|
1995-10-22 20:15:07 +00:00
|
|
|
msgConfirm("Could not create %s",file);
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1995-11-05 01:00:31 +00:00
|
|
|
}
|
1996-04-28 03:27:26 +00:00
|
|
|
if (DITEM_STATUS(i) == DITEM_SUCCESS)
|
1995-11-05 01:00:31 +00:00
|
|
|
variable_set2("apache_httpd", "YES");
|
1996-04-23 01:29:35 +00:00
|
|
|
return i | DITEM_RESTORE;
|
1995-10-22 20:15:07 +00:00
|
|
|
}
|