#!/bin/sh
# sh Configure [args]
#
# This shell script does an installation of MajorCool
# programs and files based upon user input. Some code
# copied from metaconfig for the sake of portability.
export PATH || (echo "This isn't sh. Feeding myself to sh."; sh $0 $*; kill $$)
if [ ! -t 0 ]; then
echo "Say 'sh Configure', not 'sh <Configure'"
exit 1
fi
(alias) >/dev/null 2>&1 && \
echo "(Korn shell detected. Some ksh's blow up on Configure." && \
echo "If so, try the Bourne shell instead.)"
# This configuration script may be invoked with arguments. They may
# be one of:
# -f, fast don't ask "unnecessary" questions
# variable=value set shell variable to value
# file output filename [default: default.sh]
#
# Read them here to allow for changing defaults to support testing.
#
fastread=read
config=default.sh
while [ $# -ge 1 ]; do
case "$1" in
-f|fast)
fastread='eval ans="" ; echo "<fast>" #' ;;
*=*)
eval $1 ;;
*)
config=$1 ;;
esac
shift
done
# Set up defaults for configuration
# This information describes the configuration defaults. They will
# be overwritten by any of the parameters saved in $config.
# For yes/no values, 0=no, 1=yes
DOMO_DIR=/usr/local/majordomo # Majordomo home directory
DOMO_CONF= # Majordomo configuration file
DOMO_VERSION= # Majordomo version number
WEB_SCHEME="http" # Web server scheme/protocol
WEB_ROOT=/usr/local/share/apache # Web server root directory
WEB_CGIDIR= # Web server CGI directory
WEB_CGIURL="/cgi-bin" # Web server CGI URL
WEB_IMGDIR= # Web server images directory
WEB_IMGURL="/icons" # Web server images URL
WEB_DOCROOT=/usr/local/share/apache/htdocs # Root for served documents
WEB_HEADER= # Header for common site look
WEB_FOOTER= # Footer for common site look
COOL_CF= # Config file for this installation
COOL_SITENAME= # The name of this site
COOL_SITEHOME= # Home page for this site
COOL_TMPDIR="/tmp" # MajorCool scratch area
COOL_CACHE= # MajorCool cache file
COOL_NAME="majordomo" # MajorCool CGI program name
COOL_USERID="bin" # User-id to install as
COOL_GROUPID="bin" # Group-id to install as
COOL_HELPFILE=/majorcool.html # MajorCool HTML info file location
COOL_SITEADDR="simple" # The address lookup function to use
COOL_CREATECMD= # Program to call on CREATE request
COOL_RENAMECMD= # Program to call on RENAME request
COOL_DELETECMD= # Program to call on DELETE request
OPT_ALLOWBROWSE=1 # Allow sub/unsub browsing
OPT_ALLOWMODIFY=1 # Allow list administration
OPT_ALLOWCREATE=1 # Allow list creation
OPT_ALLOWRENAME=1 # Allow list renaming
OPT_ALLOWDELETE=1 # Allow list deletion
OPT_HIDDENLISTS=0 # Hide list of lists from admins?
OPT_HIDDENPASSWD=0 # Admin password not a visible config field?
OPT_NOADVERTISED=0 # Do members see noadvertised lists?
OPT_TRUSTIDENT=0 # Will users be faking their names?
OPT_CMDVERIFY=0 # Paranoia mode. Return commands via e-mail?
OPT_SUBVERIFY=0 # Similar to cmdverify, but only for sub/unsub.
OPT_SENDCF=1 # Offer "send config via mail" option?
OPT_COMMENTEDCF=1 # Include std comments when saving list configs?
OPT_MULTIPART=1 # Use fancy multipart-mixed-replace effects?
OPT_PREFSRETURN=0 # Return to prior screen from Prefs session?
OPT_ROBOTS=1 # Allow Internet spiders to index the CGI?
OPT_SCANSTEPS=50 # Update interval suring list scan.
PERLBIN="/usr/bin/perl" # How to start a perl script
#----------------------------------------------------------------------------
: some greps do not return status, grrr.
echo "grimblepritz" >grimble
if grep blurfldyick grimble >/dev/null 2>&1 ; then
contains=contains
elif grep grimblepritz grimble >/dev/null 2>&1 ; then
contains=grep
else
contains=contains
fi
rm -f grimble
: the following should work in any shell
case "$contains" in
contains*)
echo " "
echo "AGH! Grep doesn't return a status. Attempting remedial action."
cat >contains <<'EOSS'
grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
EOSS
chmod +x contains ;;
esac
echo "Checking echo to see how to suppress newlines..."
(echo "hi there\c" ; echo " ") >.echotmp
if $contains c .echotmp >/dev/null 2>&1 ; then
n='-n'; c=''
else
n=''; c='\c'
fi
rm -f .echotmp
echo $n "Type carriage return to continue. Your cursor should be here-->$c"
$fastread ans
COOL_CF=`echo "$config" | sed -n -e 's/\.sh//p'`
TMPFILE=mc$$
trap "rm -f ${TMPFILE}* contains; exit 1 " 1 2 3 5 15
umask 022
# legacy
[ -f config.sh ] && {
echo " "
echo "Found old config.sh file. Renaming to $config..."
echo $n "Press the <newline> key to continue... $c"
$fastread ans
echo " "
mv config.sh $config
}
[ -f majorcool.cf.common ] && {
echo " "
echo "Found old cf.common file. Moving to install directory."
echo "You will have to transfer any customizations by hand."
echo $n "Press the <newline> key to continue... $c"
$fastread ans
echo " "
mv majorcool.cf.common install/majorcool.cf.common.old
}
[ -x cpset.sh ] && rm cpset.sh
[ -x cpset ] && rm cpset
# Print an error. Exit if exit value is greater than 0.
# Syntax: error value message
error() {
exitval=$1; shift
echo "ERROR: $*" >&2
[ $exitval -gt 0 ] && {
rm -f ${TMPFILE}*
exit $exitval
}
}
# Compare two versions of a file with various list, select, and edit options.
# Syntax: accept_new_file oldfile newfile selection
# Return 0 if new version accepted and 1 if not
accept_new_file() {
_old=$1; _new=$2; _ans=$3
while : ; do
case "$_ans" in
[Dd]*)
{ echo "<<Original ====== New>>"; diff $_old $_new
} | ${PAGER:-pg} ;;
[Ll]*)
${PAGER:-pg} $_new ;;
[Ee]*)
${EDITOR:-vi} $_new ;;
[Yy]*)
return 0 ;;
[Nn]*)
return 1 ;;
*)
cat <<EOM
Not a valid answer, type one of:
yes accept new version
no do not accept new version
list list the new version
edit edit the new version
diff list differences between old and new versions
EOM
esac
echo $n "Accept the new version? [yes|no|list|edit|diff]? $c"
read _ans
done
}
# Obtain a yes or no answer
# Syntax: yesorno default prompt
# Return 1 for yes, 0 for no
yesorno() {
[ $# -ge 2 ] || error 1 "Syntax: yesorno default prompt"
default=$1; shift
prompt="$*"
case "$default" in
0) default=N ;;
1) default=Y ;;
esac
while : ; do
echo $n "$prompt [$default]? $c"
$fastread ans
[ "$ans" ] || ans=$default
case "$ans" in
y|Y|[Yy][Ee][Ss])
return 1 ;;
n|N|[Nn][Oo])
return 0 ;;
esac
done
}
# Install a file with variable substitution
# Usage: sed_cpset source destination mode owner group
sed_cpset() {
[ $# -eq 5 ] || error 1 "sed_cpset source destination mode owner group"
sed \
-e "s;DOMO_DIR;$DOMO_DIR;g" \
-e "s;DOMO_CONF;$DOMO_CONF;g" \
-e "s;DOMO_VERSION;$DOMO_VERSION;g" \
-e "s;WEB_SCHEME;$WEB_SCHEME;g" \
-e "s;WEB_ROOT;$WEB_ROOT;g" \
-e "s;WEB_CGIDIR;$WEB_CGIDIR;g" \
-e "s;WEB_CGIURL;$WEB_CGIURL;g" \
-e "s;WEB_IMGDIR;$WEB_IMGDIR;g" \
-e "s;WEB_IMGURL;$WEB_IMGURL;g" \
-e "s;WEB_DOCROOT;$WEB_DOCROOT;g" \
-e "s;WEB_HEADER;$WEB_HEADER;g" \
-e "s;WEB_FOOTER;$WEB_FOOTER;g" \
-e "s;COOL_CF;$COOL_CF;g" \
-e "s;COOL_SITENAME;$COOL_SITENAME;g" \
-e "s;COOL_SITEHOME;$COOL_SITEHOME;g" \
-e "s;COOL_TMPDIR;$COOL_TMPDIR;g" \
-e "s;COOL_CACHE;$COOL_CACHE;g" \
-e "s;COOL_NAME;$COOL_NAME;g" \
-e "s;COOL_USERID;$COOL_USERID;g" \
-e "s;COOL_GROUPID;$COOL_GROUPID;g" \
-e "s;COOL_HELPFILE;$COOL_HELPFILE;g" \
-e "s;COOL_SITEADDR;$COOL_SITEADDR;g" \
-e "s;COOL_CREATECMD;$COOL_CREATECMD;g" \
-e "s;COOL_RENAMECMD;$COOL_RENAMECMD;g" \
-e "s;COOL_DELETECMD;$COOL_DELETECMD;g" \
-e "s;OPT_ALLOWBROWSE;$OPT_ALLOWBROWSE;g" \
-e "s;OPT_ALLOWMODIFY;$OPT_ALLOWMODIFY;g" \
-e "s;OPT_ALLOWCREATE;$OPT_ALLOWCREATE;g" \
-e "s;OPT_ALLOWRENAME;$OPT_ALLOWRENAME;g" \
-e "s;OPT_ALLOWDELETE;$OPT_ALLOWDELETE;g" \
-e "s;OPT_HIDDENLISTS;$OPT_HIDDENLISTS;g" \
-e "s;OPT_HIDDENPASSWD;$OPT_HIDDENPASSWD;g" \
-e "s;OPT_NOADVERTISED;$OPT_NOADVERTISED;g" \
-e "s;OPT_TRUSTIDENT;$OPT_TRUSTIDENT;g" \
-e "s;OPT_CMDVERIFY;$OPT_CMDVERIFY;g" \
-e "s;OPT_SUBVERIFY;$OPT_SUBVERIFY;g" \
-e "s;OPT_SENDCF;$OPT_SENDCF;g" \
-e "s;OPT_COMMENTEDCF;$OPT_COMMENTEDCF;g" \
-e "s;OPT_MULTIPART;$OPT_MULTIPART;g" \
-e "s;OPT_PREFSRETURN;$OPT_PREFSRETURN;g" \
-e "s;OPT_ROBOTS;$OPT_ROBOTS;g" \
-e "s;OPT_SCANSTEPS;$OPT_SCANSTEPS;g" \
-e "s;PERLBIN;$PERLBIN;g" $1 > ${TMPFILE}B
# we know the above var=value pairs in advance
# module dependencies are on-the-fly
for var in $MODULE_DEPENDENCIES; do
sed -e "s;$var;`eval echo \"\\\$${var}\"`;g" ${TMPFILE}B \
> ${TMPFILE}C
mv ${TMPFILE}C ${TMPFILE}B
done
$CPSET ${TMPFILE}B $2 $3 $4 $5
rm -f ${TMPFILE}B
return 0
}
#----------------------------------------------------------------------------
if [ -r $config ]; then
cat <<EOM
The configuration file '$config' has been found from a previous
installation. If you do not wish to change from your current
configuration you should be able to just enter <newline> at every
prompt. This shell script will use the values from the current
configuration as the defaults for this upgrade of the MajorCool
software.
EOM
. ./$config
# legacy
[ "$CPSET" = "./cpset.sh" ] && CPSET="install/cpset"
[ "$CPSET" = "./cpset" ] && CPSET="install/cpset"
[ -n "$COOL_USER" ] && COOL_NAME=$COOL_USER
else
cat <<EOM
No configuration file from a previous installation of MajorCool
has been found, so this is assumed to be a first time installation.
This configuration shell script will examine your system and ask
you questions to determine how MajorCool should be installed. Many
of the questions will have default answers in square brackets;
typing carriage return will give you the default.
This configuration script has three sections:
1) Configuration
Asks lots of questions. Uses the answers to create a file
$config that contains the configuration information.
2) Confirmation
Allows you to view/edit the generated configuration file.
3) Installation
Installs the programs and files.
EOM
# Ask for <newline> or <return> before continuing
echo " "
echo $n "Press the <newline> key to continue... $c"
read ans
echo " "
fi
cat <<EOM
MajorCool can be configured with multiple "personalities". For
example, it can support multiple Majordomo config files when used
in a virtual-host Majordomo setup, or multiple "entry-points" into
the same Majordomo by using differently named CGI scripts.
The key to this "multiple personality" feature is the config file
you are creating at this very moment. It is named '$config' and,
with the answers provided, it will create a 'majorcool_${COOL_CF}.cf'
file to be used by MajorCool.
If you wish to create a new "personality" separate from this current
'$COOL_CF', simply specify an alternate config filename on the
Configure command line:
Configure other.sh
EOM
echo $n "Press the <newline> key to continue... $c"
$fastread ans
echo " "
# Locate the cpset program
echo " "
echo "Locating programs..."
dirs="/bin /usr/bin /sbin /usr/sbin /usr/lbin /usr/local/bin install"
for dir in $dirs; do
[ -x "$dir/cpset" ] && {
CPSET="$dir/cpset"
break
}
done
echo "...cpset is $CPSET."
for dir in $dirs; do
[ -x $dir/rolo ] && {
ROLOPROGRAM=$dir/rolo
break
}
done
[ -x "$ROLOPROGRAM" ] || ROLOPROGRAM="not found"
echo "...rolo is $ROLOPROGRAM."
# If the Majordomo config file is present in the "standard" location,
# we can use it to tell us some things.
if [ -f /etc/majordomo.cf ]; then
ans=`grep '$homedir =' /etc/majordomo.cf | sed -n -e '$s/.*"\(.*\)".*/\1/p'`
[ "$DOMO_DIR" ] || {
[ -n "$ans" ] && DOMO_DIR=$ans
}
[ "$DOMO_CONF" ] || DOMO_CONF="/etc/majordomo.cf"
fi
# Set up the majordomo directory
cat <<EOM
MajorCool interacts with Majordomo and runs under the Majordomo
wrapper program. Therefore it needs to know where to find Majordomo
and the majordomo.cf file (and where to place the MajorCool program).
EOM
while : ; do
echo " "
echo "What is the installation directory of Majordomo?"
echo $n " [$DOMO_DIR]: $c"
$fastread ans
[ -n "$ans" ] && DOMO_DIR=$ans
if [ -d "$DOMO_DIR" ]; then
if [ -x $DOMO_DIR/majordomo -a -x $DOMO_DIR/wrapper ]; then
echo "Will place the MajorCool programs in $DOMO_DIR."
break
else
cat <<EOM
Did not find the Majordomo programs (majordomo and wrapper) in
'$DOMO_DIR'. Please verify the Majordomo installation.
EOM
DOMO_DIR=''
fi
elif [ -r $DOMO_DIR ]; then
echo "$DOMO_DIR already exists and it is not a directory!"
DOMO_DIR=''
fi
done
[ "$DOMO_CONF" ] || DOMO_CONF=$DOMO_DIR/majordomo.cf
while : ; do
echo " "
echo "What is the path to your Majordomo configuration file?"
echo $n " [$DOMO_CONF]: $c"
$fastread ans
[ -n "$ans" ] && DOMO_CONF=$ans
if [ -f "$DOMO_CONF" ]; then
echo "Using configuration file name '$DOMO_CONF'"
break
else
echo "$DOMO_CONF does not seem to exist."
DOMO_CONF=''
fi
done
# The Majordomo setup did all the hard work for this - use it.
[ "$PERLBIN" ] || PERLBIN=`sed -n -e '1 s/#![ ]*//p' < $DOMO_DIR/majordomo`
DOMO_VERSION="`$PERLBIN -I$DOMO_DIR -e '
{require "majordomo_version.pl"; print $majordomo_version;}'`"
# Pick a TMP directory
[ "$COOL_TMPDIR" ] || COOL_TMPDIR="$COOL_TMPDIR"
while : ; do
echo " "
echo "Where would you like temp files created when MajorCool runs?"
echo $n " [$COOL_TMPDIR]: $c"
$fastread ans
[ -n "$ans" ] && COOL_TMPDIR=$ans
if [ -d "$COOL_TMPDIR" ]; then
break
else
echo "$COOL_TMPDIR does not seem to exist."
COOL_TMPDIR=''
fi
done
# This shell needs some basic write permissions. Let's check.
[ -w $DOMO_DIR ] || {
cat <<EOM
This shell script (Configure) must be run as a user with write
permission to the Majordomo directory. Please 'su' or 'login' as
necessary and then execute this shell script.
EOM
exit 1
}
# Get Web setup info
cat <<EOM
MajorCool needs to install CGI programs, support files, and icons in
your Web server directories.
EOM
while : ; do
echo " "
echo "What is the root directory for your Web server?"
echo $n " [$WEB_ROOT]: $c"
$fastread ans
[ -n "$ans" ] && WEB_ROOT=$ans
if [ -d "$WEB_ROOT" ]; then
break
elif [ -r "$WEB_ROOT" ]; then
echo "$WEB_ROOT already exists and it is not a directory!"
WEB_ROOT=''
else
echo "$WEB_ROOT does not exist!"
WEB_ROOT=''
fi
done
# Now set up all the things that are dependent on WEB_ROOT.
[ "$WEB_CGIURL" ] || WEB_CGIURL="/cgi-bin"
[ "$WEB_CGIDIR" ] || {
[ -d $WEB_ROOT/cgi-bin ] && WEB_CGIDIR="$WEB_ROOT/cgi-bin"
}
[ "$WEB_IMGURL" ] || WEB_IMGURL="/icons"
[ "$WEB_IMGDIR" ] || {
[ -d $WEB_ROOT/icons ] && WEB_IMGDIR="$WEB_ROOT/icons"
}
[ "$WEB_DOCROOT" ] || {
[ -d $WEB_ROOT/htdocs ] && WEB_DOCROOT="$WEB_ROOT/htdocs"
}
while : ; do
echo " "
echo "Where is the cgi-bin directory for your Web server?"
echo $n " [$WEB_CGIDIR]: $c"
$fastread ans
[ -n "$ans" ] && WEB_CGIDIR=$ans
if [ -d "$WEB_CGIDIR" ]; then
echo "Will place the programs in $WEB_CGIDIR."
break
elif [ -r "$WEB_CGIDIR" ]; then
echo "$WEB_CGIDIR already exists and it is not a directory!"
WEB_CGIDIR=''
else
echo "$WEB_CGIDIR does not exist!"
WEB_CGIDIR=''
fi
done
while : ; do
echo " "
echo "What is your server's URL for '$WEB_CGIDIR'?"
echo $n " [$WEB_CGIURL]: $c"
$fastread ans
[ -n "$ans" ] && WEB_CGIURL=$ans
[ -n "$WEB_CGIURL" ] && break
done
while : ; do
echo " "
echo "Where is the image directory for your Web server?"
echo $n " [$WEB_IMGDIR]: $c"
$fastread ans
[ -n "$ans" ] && WEB_IMGDIR=$ans
if [ -d "$WEB_IMGDIR" ]; then
echo "Will place the icons in $WEB_IMGDIR."
break
elif [ -r "$WEB_IMGDIR" ]; then
echo "$WEB_IMGDIR already exists and it is not a directory!"
WEB_IMGDIR=''
else
echo "$WEB_IMGDIR does not exist!"
WEB_IMGDIR=''
fi
done
while : ; do
echo " "
echo "What is your server's URL for '$WEB_IMGDIR'?"
echo $n " [$WEB_IMGURL]: $c"
$fastread ans
[ -n "$ans" ] && WEB_IMGURL=$ans
[ -n "$WEB_IMGURL" ] && break
done
while : ; do
echo " "
echo "Where is the root directory for documents on your Web server?"
echo $n " [$WEB_DOCROOT]: $c"
$fastread ans
[ -n "$ans" ] && WEB_DOCROOT=$ans
if [ -d "$WEB_DOCROOT" ]; then
break
elif [ -r "$WEB_DOCROOT" ]; then
echo "$WEB_DOCROOT already exists and it is not a directory!"
WEB_DOCROOT=''
else
echo "$WEB_DOCROOT does not exist!"
WEB_DOCROOT=''
fi
done
cat <<EOM
Each installed "personality" of MajorCool must have its own CGI
script name. For example, you would need multiple instances if
you implemented Majordomo virtual host support or separated the
end-user and admin functions of MajorCool into multiple entry
points.
EOM
while : ; do
echo " "
echo "What are you going to call this MajorCool CGI?"
echo $n " [$COOL_NAME]: $c"
$fastread ans
[ -n "$ans" ] && COOL_NAME=$ans
[ -n "$COOL_NAME" ] && break
done
cat <<EOM
Some Web sites utilize included headers & footers to provide a common
"look and feel". MajorCool can use the same included files (e.g.,
utilizing site-standard <BODY> attributes) if you tell it where.
(Use 'none' to erase the current values)
EOM
echo "Location of HTML header (if applicable)?"
echo $n " [$WEB_HEADER]: $c"
$fastread ans
[ -n "$ans" ] && WEB_HEADER=$ans
[ "$ans" = "none" ] && WEB_HEADER=""
echo "Location of HTML footer (if applicable)?"
echo $n " [$WEB_FOOTER]: $c"
$fastread ans
[ -n "$ans" ] && WEB_FOOTER=$ans
[ "$ans" = "none" ] && WEB_FOOTER=""
[ "$COOL_HELPFILE" ] || COOL_HELPFILE="/mc_${COOL_CF}_help.htm"
cat <<EOM
MajorCool needs to place it's Help file somewhere on the Web server.
You can (should) have different Help files for each MajorCool copy
you are installing.
EOM
while : ; do
echo " "
echo "Where in $WEB_DOCROOT should the Help file be installed?"
echo $n " [$COOL_HELPFILE]: $c"
$fastread ans
[ -n "$ans" ] && COOL_HELPFILE=$ans
[ "$COOL_HELPFILE" ] && break
done
cat <<EOM
In order to reference this Help file, we need to know what 'scheme'
or protocol the Web server & CGI will be using. For instance, some
sites might be using Secure HTTP [shttp] or SSL [https]. Most sites
will just use generic HTTP....
EOM
while : ; do
echo " "
echo "What scheme will the Web server be using?"
echo $n " [$WEB_SCHEME]: $c"
$fastread ans
[ -n "$ans" ] && WEB_SCHEME=$ans
[ -n "$WEB_SCHEME" ] && break
done
cat <<EOM
All these files to be installed need to have a user-id and group-id
for ownership. What user/group would you like to use?
EOM
while : ; do
echo " "
echo "Which user-id?"
echo $n " [$COOL_USERID]: $c"
$fastread ans
[ -n "$ans" ] && COOL_USERID=$ans
if [ "$COOL_USERID" ]; then
break
else
echo "You must enter a valid user-id."
fi
done
while : ; do
echo " "
echo "Which group-id?"
echo $n " [$COOL_GROUPID]: $c"
$fastread ans
[ -n "$ans" ] && COOL_GROUPID=$ans
if [ "$COOL_GROUPID" ]; then
break
else
echo "You must enter a valid group-id."
fi
done
cat <<EOM
MajorCool needs to know the name you call your site so that it can
include it in the title and header of generated HTML documents. This
is typically a phrase or description as opposed to a URL.
EOM
while : ; do
echo " "
echo "What is the name you call your site?"
echo $n " [$COOL_SITENAME]: $c"
$fastread ans
[ -n "$ans" ] && COOL_SITENAME=$ans
if [ "$COOL_SITENAME" ]; then
break
else
echo "You must enter a site name."
fi
done
cat <<EOM
MajorCool provides a "HOME" button to return to a site's home page.
This is different from the URL of MajorCool itself; this is the
main entry point for your organization's Web.
EOM
while : ; do
echo " "
echo "What URL should be used for the site home?"
echo $n " [$COOL_SITEHOME]: $c"
$fastread ans
[ -n "$ans" ] && COOL_SITEHOME=$ans
if [ "$COOL_SITEHOME" ]; then
break
else
echo "You must enter a URL."
fi
done
### MajorCool configuration stuff.
cat <<EOM
MajorCool has separate 'modules' for end-user list browsing,
list-owner administration, list creation, and list deletion.
You may selectively enable/disable access to these functions.
EOM
yesorno $OPT_ALLOWBROWSE "Provide end-user BROWSE access"
OPT_ALLOWBROWSE=$?
yesorno $OPT_ALLOWMODIFY "Provide administrator MODIFY access"
OPT_ALLOWMODIFY=$?
yesorno $OPT_ALLOWCREATE "Provide list CREATE access"
OPT_ALLOWCREATE=$?
yesorno $OPT_ALLOWRENAME "Provide list RENAME access"
OPT_ALLOWRENAME=$?
yesorno $OPT_ALLOWDELETE "Provide list DELETE access"
OPT_ALLOWDELETE=$?
if [ $OPT_ALLOWBROWSE -ne 0 -o $OPT_ALLOWMODIFY -ne 0 ]; then
# Set up the Cache file
cat <<EOM
In the interest of speed, the end-user BROWSE function of MajorCool
utilizes a Key Cache file to store frequently accessed list
attributes. You must specify the location for this Cache file.
The setup will create a base Cache file for you, but you will need
to automate this process via cron to ensure continued updates.
Note: If you have a virtual host setup with multiple Majordomo
domains sharing the \$homedir, then you must specify a different
Cache file name for each end-user "personality" you install.
EOM
[ "$COOL_CACHE" ] || COOL_CACHE="$DOMO_DIR/.majordomo_keys"
while : ; do
echo " "
echo "Where do you want to keep the Key Cache file?"
echo $n " [$COOL_CACHE]: $c"
$fastread ans
[ -n "$ans" ] && COOL_CACHE=$ans
[ "$COOL_CACHE" ] && break
done
## Optional stuff for NCR mostly
# look for the mail configuration file
[ "$ROLOPROGRAM" ] && {
dirs="/usr/lib/sendmail /usr/lib/mail"
for dir in $dirs; do
[ -r $dir/$config ] && {
MAILCONFIG=$dir/$config
break
}
done
# Read the mail configuration file to get the domain name
[ "$MAILCONFIG" ] && . $MAILCONFIG
}
cat <<EOM
MajorCool can use customized address mapping functions to:
o Define suitable prompts for name and/or address data entry.
o Define an address mapping function used to tie a name or address
to a set of address regexp's. These regexp's will be used to
determine list membership even if a user may be subscribed with
multiple addresses.
o Define an address-comparison function used for the sorting of
subscriber addresses.
EOM
echo $n "Press the <newline> key to continue... $c"
$fastread ans
echo " "
echo "The mapping functions currently provided include:"
echo " "
PWD=`pwd`
# Determine what address modules are available at this site
for module in $PWD/siteaddr/*; do
[ -f $module ] || continue
#name=`echo $module | sed -e 's;siteaddr/;;g'`
name=`basename $module`
[ "$name" = "none" ] && continue
explain=`grep '^#~' $module | sed -e 's/^#~//g'`
echo "o $name - $explain"; echo " "
done
while : ; do
echo "Which address mapping function will you use?"
echo $n " [$COOL_SITEADDR]: $c"
$fastread ans
echo " "
[ -n "$ans" ] && COOL_SITEADDR=$ans
if [ -f "$PWD/siteaddr/$COOL_SITEADDR" ]; then
break
else
echo "SiteAddress file '$COOL_SITEADDR' not found"
COOL_SITEADDR=''
fi
done
require=`grep '^#+' $PWD/siteaddr/$COOL_SITEADDR | sed -e 's/^#+//g'`
if [ -n "$require" ]; then
echo "Module '$COOL_SITEADDR' has additional dependencies:"
for r in $require; do
MODULE_DEPENDENCIES="$MODULE_DEPENDENCIES $r"
while : ; do
echo "What is a value for $r?"
echo $n " [`eval echo \"\\\$${r}\"`]: $c"
$fastread ans
echo " "
[ -n "$ans" ] && eval $r=$ans
[ "`eval echo \"\\\$${r}\"`" ] && break
done
done
fi
else
# BROWSE not configured
COOL_SITEADDR='none'
fi
if [ $OPT_ALLOWCREATE -ne 0 ]; then
# prompt for list_create_cmd
cat <<EOM
I see that you have enabled CREATE mode. Creation requests can be mailed
to the majordomo-owner, or a program can be invoked to process the request
automatically. This program must accept -d/-o/-p arguments.
Specify a fully-pathed command to be executed here, or leave blank for
the default mail behavior. (Use 'none' to erase the current value)
EOM
echo "Program to execute (if applicable)?"
echo $n " [$COOL_CREATECMD]: $c"
$fastread ans
[ -n "$ans" ] && COOL_CREATECMD=$ans
[ "$ans" = "none" ] && COOL_CREATECMD=""
fi
if [ $OPT_ALLOWRENAME -ne 0 ]; then
# prompt for list_rename_cmd
cat <<EOM
I see that you have enabled RENAME mode. Renaming requests can be mailed
to the majordomo-owner, or a program can be invoked to process the request
automatically. This program must accept -o/-p arguments.
Specify a fully-pathed command to be executed here, or leave blank for
the default mail behavior. (Use 'none' to erase the current value)
EOM
echo "Program to execute (if applicable)?"
echo $n " [$COOL_RENAMECMD]: $c"
$fastread ans
[ -n "$ans" ] && COOL_RENAMECMD=$ans
[ "$ans" = "none" ] && COOL_RENAMECMD=""
fi
if [ $OPT_ALLOWDELETE -ne 0 ]; then
# prompt for list_delete_cmd
cat <<EOM
I see that you have enabled DELETE mode. Deletion requests can be mailed
to the majordomo-owner, or a program can be invoked to process the request
automatically. This program must accept -o/-p arguments.
Specify a fully-pathed command to be executed here, or leave blank for
the default mail behavior. (Use 'none' to erase the current value)
EOM
echo "Program to execute (if applicable)?"
echo $n " [$COOL_DELETECMD]: $c"
$fastread ans
[ -n "$ans" ] && COOL_DELETECMD=$ans
[ "$ans" = "none" ] && COOL_DELETECMD=""
fi
cat <<EOM
MajorCool has a number of options that can be set to customize its
operation.
EOM
yesorno $OPT_HIDDENLISTS "Require administrators to type the list name"
OPT_HIDDENLISTS=$?
yesorno $OPT_HIDDENPASSWD "Require admin password change to be confirmed"
OPT_HIDDENPASSWD=$?
yesorno $OPT_NOADVERTISED "Do list members see noadvertised lists"
OPT_NOADVERTISED=$?
yesorno $OPT_TRUSTIDENT "Do you trust that users are who they say"
OPT_TRUSTIDENT=$?
yesorno $OPT_CMDVERIFY "Do you want to use instruct mode (aka paranoia mode)"
OPT_CMDVERIFY=$?
yesorno $OPT_SUBVERIFY "Perform sub/unsub by having requester use e-mail"
OPT_SUBVERIFY=$?
yesorno $OPT_SENDCF "Allow admins to get config file (sent via e-mail)"
OPT_SENDCF=$?
yesorno $OPT_COMMENTEDCF "Save Majordomo comments in list config file"
OPT_COMMENTEDCF=$?
yesorno $OPT_MULTIPART "Use 'server push' effects if supported"
OPT_MULTIPART=$?
yesorno $OPT_PREFSRETURN "Return to prior screen after Prefs session"
OPT_PREFSRETURN=$?
yesorno $OPT_ROBOTS "Allow Internet 'spiders' to index this CGI"
OPT_ROBOTS=$?
if [ $OPT_ALLOWBROWSE -ne 0 -a $OPT_MULTIPART -ne 0 ]; then
cat <<EOM
I see that you have enabled 'server push' effects for those browsers
that support it. One of the more time-consuming BROWSE tasks involves
scanning lists for membership and access privileges. On systems with
many lists, the length of the scan might cause the user to wonder
whether MajorCool is truly active. By setting the scan step factor to
a non-zero value (default=$OPT_SCANSTEPS), MajorCool will provide the user with
some feedback via a stepped countdown of the lists remaining to be
scanned. (eg, 150...100...50...)
Specify an update interval (number) here, or 0 for no updated countdown.
(Greater than 20 recommended if this feature is used.)
EOM
echo "Update interval?"
echo $n " [$OPT_SCANSTEPS]: $c"
$fastread ans
[ -n "$ans" ] && OPT_SCANSTEPS=$ans
fi
# Write out the new $config to a temporary file. We won't save it
# in the correct place until it has been verified as being correct.
cat <<EOF >$TMPFILE
# Configuration file for MajorCool
# These should only be modified through the use of the Configure script
# For yes/no values, 0=no, 1=yes
# SYSTEM DETAILS
# How to start a perl script
PERLBIN="$PERLBIN"
# The cpset command for installations
CPSET="$CPSET"
# MAJORDOMO DETAILS
# Home directory
DOMO_DIR="$DOMO_DIR"
# Configuration file location
DOMO_CONF="$DOMO_CONF"
# Version number
DOMO_VERSION="$DOMO_VERSION"
# WEB SERVER DETAILS
# Server scheme (http, shttp, https)
WEB_SCHEME="$WEB_SCHEME"
# Server root directory
WEB_ROOT="$WEB_ROOT"
# CGI directory
WEB_CGIDIR="$WEB_CGIDIR"
# CGI URL
WEB_CGIURL="$WEB_CGIURL"
# Images directory
WEB_IMGDIR="$WEB_IMGDIR"
# Images URL
WEB_IMGURL="$WEB_IMGURL"
# Root for served documents
WEB_DOCROOT="$WEB_DOCROOT"
# Header & footer for common site look
WEB_HEADER="$WEB_HEADER"
WEB_FOOTER="$WEB_FOOTER"
# MAJORCOOL CONFIG
# The name of this site
COOL_SITENAME="$COOL_SITENAME"
# The URL of this site's home page
COOL_SITEHOME="$COOL_SITEHOME"
# TMP directory
COOL_TMPDIR="$COOL_TMPDIR"
# Location of key cache file
COOL_CACHE="$COOL_CACHE"
# CGI program name
COOL_NAME="$COOL_NAME"
# UNIX user/group-id owners
COOL_USERID="$COOL_USERID"
COOL_GROUPID="$COOL_GROUPID"
# Help file for MajorCool
COOL_HELPFILE="$COOL_HELPFILE"
# The address lookup function to use
COOL_SITEADDR="$COOL_SITEADDR"
# The programs to invoke on CREATE/RENAME/DELETE
COOL_CREATECMD="$COOL_CREATECMD"
COOL_RENAMECMD="$COOL_RENAMECMD"
COOL_DELETECMD="$COOL_DELETECMD"
# MAJORCOOL OPTIONS
# Module access
OPT_ALLOWBROWSE="$OPT_ALLOWBROWSE"
OPT_ALLOWMODIFY="$OPT_ALLOWMODIFY"
OPT_ALLOWCREATE="$OPT_ALLOWCREATE"
OPT_ALLOWRENAME="$OPT_ALLOWRENAME"
OPT_ALLOWDELETE="$OPT_ALLOWDELETE"
# Hide list of lists from admins?
OPT_HIDDENLISTS="$OPT_HIDDENLISTS"
# Admin passwd not in regular config?
OPT_HIDDENPASSWD="$OPT_HIDDENPASSWD"
# Members see noadvertised lists?
OPT_NOADVERTISED="$OPT_NOADVERTISED"
# Trust the address that users enter?
OPT_TRUSTIDENT="$OPT_TRUSTIDENT"
# Use paranoia mode? Sends commands in e-mail...
OPT_CMDVERIFY="$OPT_CMDVERIFY"
# Send sub/unsub commands in e-mail for user confirmation?
OPT_SUBVERIFY="$OPT_SUBVERIFY"
# Allow admins to request emailed config?
OPT_SENDCF="$OPT_SENDCF"
# Save comments in list config file?
OPT_COMMENTEDCF="$OPT_COMMENTEDCF"
# Use MIME screen update feature if supported?
OPT_MULTIPART="$OPT_MULTIPART"
# Return to prior screen after Prefs session?
OPT_PREFSRETURN="$OPT_PREFSRETURN"
# Allow Internet spiders to index this CGI?
OPT_ROBOTS="$OPT_ROBOTS"
# Update interval during list membership scan.
OPT_SCANSTEPS="$OPT_SCANSTEPS"
EOF
echo "# SITEADDR OPTIONS (may be empty)" >>$TMPFILE
for var in $MODULE_DEPENDENCIES; do
echo " $var=`eval echo \"\\\$${var}\"`" >>$TMPFILE
done
# We need to know how to display stuff slowly to the screen. If the
# PAGER variable is not set (or cannot be found) then try the sort of
# names that make sense as pagers.
[ "$PAGER" ] || {
for PAGER in pg more less cat; do
( cat /dev/null | $PAGER >/dev/null 2>&1 ) && {
echo "PAGER set to $PAGER."
break
}
done
}
# Ask for <newline> or <return> before continuing
cat <<EOM
The screen full of information that will follow is the contents of
the generated $config file. Please check that it is correct.
EOM
echo $n "Press the <return> or <newline> key to continue... $c"
$fastread ans
echo " "
if [ -r $config ]; then
old=$config
else
old=/dev/null
fi
if accept_new_file $old $TMPFILE list; then
if cmp -s $old $TMPFILE; then
echo "Configuration file has not changed."
rm -f $TMPFILE
else
echo "Writing information to '$config' for later use."
$CPSET -o $TMPFILE $config 644 $COOL_USERID $COOL_GROUPID
if cmp -s $config OLD$config; then
rm -f OLD$config #nothing changed
elif [ -r OLD$config ]; then
echo "The old configuration is saved as OLD$config."
fi
fi
else
cat <<EOM
Since you disagree with what you have entered, you will have to
re-run this Configure script again to change your choices.
EOM
exit 1
fi
# Reread the config file to pick up any edited changes
. ./$config
# ======================= Installation ===========================
echo $n "Press return to install MajorCool using $config... $c"
read ans
echo " "
echo "Installing MajorCool programs in '$DOMO_DIR'"
for file in majorcool.pl mj_key_cache; do
echo "...'$file'..."
sed_cpset $file $DOMO_DIR/$file 0755 $COOL_USERID $COOL_GROUPID
done
echo "Installing 'majorcool_$COOL_CF.cf' (with siteaddr=$COOL_SITEADDR)"
cat install/majorcool.cf.common siteaddr/$COOL_SITEADDR >$TMPFILE
sed_cpset $TMPFILE $DOMO_DIR/majorcool_$COOL_CF.cf 0755 $COOL_USERID $COOL_GROUPID
echo "Installing 'majorcool.cgi' as '$WEB_CGIDIR/$COOL_NAME'"
sed_cpset majorcool.cgi $WEB_CGIDIR/$COOL_NAME 0755 $COOL_USERID $COOL_GROUPID
echo "Installing MajorCool icons in '$WEB_IMGDIR'"
for file in `ls icons`; do
if [ ! -f icons/$file ]; then continue; fi
if cmp -s icons/$file $WEB_IMGDIR/$file; then continue; fi
echo "...'icons/$file'..."
$CPSET icons/$file $WEB_IMGDIR/$file 0644 $COOL_USERID $COOL_GROUPID
done
echo "Installing Help file as '$WEB_DOCROOT/$COOL_HELPFILE'"
cat install/HelpHeader >$TMPFILE
$PERLBIN install/extract INTRO Docs/usage.htm >>$TMPFILE
[ $OPT_ALLOWBROWSE -ne 0 ] && {
$PERLBIN install/extract BROWSE Docs/usage.htm >>$TMPFILE
}
[ $OPT_ALLOWMODIFY -ne 0 ] && {
$PERLBIN install/extract MODIFY Docs/usage.htm >>$TMPFILE
}
[ $OPT_ALLOWCREATE -ne 0 ] && {
$PERLBIN install/extract CREATE Docs/usage.htm >>$TMPFILE
}
[ $OPT_ALLOWRENAME -ne 0 ] && {
$PERLBIN install/extract RENAME Docs/usage.htm >>$TMPFILE
}
[ $OPT_ALLOWDELETE -ne 0 ] && {
$PERLBIN install/extract DELETE Docs/usage.htm >>$TMPFILE
}
$PERLBIN install/extract PREFS Docs/usage.htm >>$TMPFILE
$PERLBIN install/extract PREFS Docs/config.htm >>$TMPFILE
[ -f install/site.info ] && {
cat install/site.info >>$TMPFILE
}
cat install/HelpFooter >>$TMPFILE
$PERLBIN -pi -e "s|\.\./icons/|WEB_IMGURL/|g;" $TMPFILE
sed_cpset $TMPFILE $WEB_DOCROOT/$COOL_HELPFILE 0644 $COOL_USERID $COOL_GROUPID
rm -f ${TMPFILE}*
# Now test out the installation to make sure that everything is okay.
cat <<EOM
Testing the MajorCool installation.
EOM
echo $n "Press return to test now... $c"
read ans
echo " "
if [ $OPT_ALLOWBROWSE -ne 0 -o $OPT_ALLOWMODIFY -ne 0 ]; then
# Cache format changed; force update (maybe)
[ -f "$COOL_CACHE" ] && {
echo "Key Cache format has changed with this release."
echo "Checking file format..."
grep "" $COOL_CACHE >/dev/null || rm $COOL_CACHE
}
[ -f "$COOL_CACHE" ] || {
echo "Creating initial Key Cache file in '$COOL_CACHE'."
echo "You will need to automate this process..."
set -ex
$DOMO_DIR/wrapper mj_key_cache -v -K $COOL_CACHE -C $DOMO_CONF
set +ex
}
fi
cat <<EOM
You should next see a bunch of HTML output to the screen. This would
be the MajorCool opening screen if accessed via a Web browser to the
'$WEB_CGIURL/$COOL_NAME' address.
EOM
set -ex
$WEB_CGIDIR/$COOL_NAME
set +ex
cat <<EOM
Note: MajorCool can be made even more functional if the Owner keyword
modifications have also been implemented. See the installation
page for details.
EOM
# ALL DONE!
echo " "
echo "Installation/configuration completed successfully."
$PERLBIN install/notify.pl $DOMO_CONF $DOMO_DIR $COOL_CF
exit 0
syntax highlighted by Code2HTML, v. 0.9.1