1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-08 23:06:56 +00:00
freebsd-ports/net/cvsup-mirror/scripts/configure

203 lines
5.2 KiB
Plaintext
Raw Normal View History

#! /bin/sh
base=${PREFIX}/etc/cvsup
variables="user group host host_crypto interval maxclients facility distribs"
ask() {
local question default answer
question=$1
default=$2
if [ -z "${PACKAGE_BUILDING}" ]; then
read -p "${question} [${default}]? " answer
fi
if [ x${answer} = x ]; then
answer=${default}
fi
echo ${answer}
}
yesno() {
local dflt question answer
question=$1
dflt=$2
while :; do
answer=$(ask "${question}" "${dflt}")
case "${answer}" in
[Yy]*) return 0;;
[Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
ask_distrib() {
local desc dflt link dir subdir
link=$1
dflt=$2
subdir=$3
desc=$4
if yesno "Do you wish to mirror the ${desc}" y; then
if [ "${subdir}" != "." ]; then
cat <<EOF
Note: the location for this must match "*/${subdir}", and
"${subdir}" must be a true subdirectory, not a symbolic link.
EOF
fi
while :; do
dir=$(ask "Where would you like to put it" ${dflt})
if [ "${subdir}" = "." ]; then
break
fi
dir=$(expr "${dir}" : "\(.*\)/${subdir}\$")
if [ "x${dir}" != x ]; then
break
fi
echo "The location must match \"*/${subdir}\""
done
distribs="${distribs} ${link} ${dir} ${subdir}"
return 0
else
distribs="${distribs} ${link} SKIP ${subdir}"
return 1
fi
}
canonicalize() {
echo $1 | tr "[:upper:]" "[:lower:]"
}
#------------------------------------------------------------------------------
cat <<EOF
I am going to ask you a few questions so that I can set up your
FreeBSD mirror configuration. Every question has a [default]
answer. To accept the default, just press ENTER.
At this point, I am just gathering information. I will not touch
your system until you type "make install".
EOF
if [ x${USA_RESIDENT} = xYES ]; then
dflt_domestic=y
else
dflt_domestic=n
fi
if yesno "Is this host in the USA or Canada" ${dflt_domestic}; then
domestic=yes
else
domestic=no
fi
host=$(ask "Master site for your non-crypto updates" freefall.freebsd.org)
if [ ${domestic} = yes ]; then
dflt_host_crypto=${host}
else
dflt_host_crypto=cvsup.internat.freebsd.org
fi
cat <<EOF
If you are not planning to mirror the crypto files, just accept
the default answer for the next question.
EOF
host_crypto=$(ask "Master site for your crypto updates" ${dflt_host_crypto})
host=$(canonicalize ${host})
host_crypto=$(canonicalize ${host_crypto})
while :; do
interval=$(ask "How many hours between updates of your files" 1)
case ${interval} in
1|2|3|4|6|8|12|24) break;;
esac
echo "Please answer 1, 2, 3, 4, 6, 8, 12, or 24"
done
cat <<EOF
Now you must decide which sets of files you wish to make available
from your mirror site. You can choose any combination, and you
can put each set anywhere you want to on your disks. Although each
set is optional, we strongly encourage every mirror site to carry
at least the main source tree.
EOF
distribs="distrib.self .. ."
ask_distrib FreeBSD.cvs /home/ncvs . \
"main source tree, except crypto code (350 MB)"
ask_distrib FreeBSD-crypto.cvs /home/ncvs . \
"crypto code (7 MB)"
ask_distrib FreeBSD-www.current /usr/local/www . \
"installed World Wide Web data (16 MB)"
ask_distrib FreeBSD-gnats.current /home/gnats gnats \
"GNATS bug tracking database (12 MB)"
ask_distrib FreeBSD-mail.current /home/mail . \
"mailing list archive (150 MB)"
cat <<EOF
Now, a few questions so that I can set up your CVSup server properly.
For security reasons, the CVSup server should run under its own
unique user and group IDs. These IDs should have no special access
privileges. Normally, the user "cvsup" and group "cvsup" are used,
but you can choose other names if you wish. At "make install"
time, I will create the user and group, if they don't already exist.
For security reasons, you must use unique user and group IDs for
this. Do NOT use "nobody", "nonroot", or "nogroup".
EOF
user=$(ask "Unique unprivileged user ID for running the server" cvsup)
group=$(ask "Unique unprivileged group ID for running the server" cvsup)
cat <<EOF
The CVSup server does its logging via syslog. At "make install"
time, I will set up the logging for you, if necessary. I will use
the "!program" feature of syslog to keep your CVSup log messages
separate from the messages of your other daemons.
EOF
while :; do
facility=$(ask "Syslog facility for the server log" daemon)
case ${facility} in
daemon|local[0-7]|ftp|user) break;;
esac
echo "Please answer daemon, local0-local7, ftp, or user"
done
cat <<EOF
You can control the load on your machine by limiting the number of
clients that the CVSup server will serve at once. CVSup won't load
your network especially heavily, but it is more CPU and disk
intensive than most other file server software.
EOF
while :; do
maxclients=$(ask "Maximum simultaneous client connections" 8)
if expr "${maxclients}" : "[0-9][0-9]*\$" >/dev/null 2>&1; then
break
fi
echo "Please answer with a number"
done
#------------------------------------------------------------------------------
echo ""
echo -n "Building the \"config.sh\" file ... "
for var in ${variables}; do
eval echo ${var}=\\\"\${${var}}\\\"
done > ${WRKSRC}/config.sh
echo "Done."