diff options
author | jdp <jdp@FreeBSD.org> | 1997-02-02 12:11:35 +0800 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1997-02-02 12:11:35 +0800 |
commit | 4d0058f9e988dac1d1adff81cf7a1fcda5fee209 (patch) | |
tree | f026cc807139f51fd84a5f27a502c9b96b6a17e5 | |
parent | b908f5da2910a4452030d6d1b907ed2215df5fd9 (diff) | |
download | freebsd-ports-gnome-4d0058f9e988dac1d1adff81cf7a1fcda5fee209.tar.gz freebsd-ports-gnome-4d0058f9e988dac1d1adff81cf7a1fcda5fee209.tar.zst freebsd-ports-gnome-4d0058f9e988dac1d1adff81cf7a1fcda5fee209.zip |
The cvsup-mirror port, a kit that makes it easy to set up a FreeBSD
mirror site.
-rw-r--r-- | net/cvsup-mirror/Makefile | 45 | ||||
-rw-r--r-- | net/cvsup-mirror/files/cvsupd.sh | 16 | ||||
-rw-r--r-- | net/cvsup-mirror/files/supfile | 11 | ||||
-rw-r--r-- | net/cvsup-mirror/files/update.sh | 68 | ||||
-rw-r--r-- | net/cvsup-mirror/pkg-comment | 1 | ||||
-rw-r--r-- | net/cvsup-mirror/pkg-deinstall | 90 | ||||
-rw-r--r-- | net/cvsup-mirror/pkg-descr | 15 | ||||
-rw-r--r-- | net/cvsup-mirror/pkg-install | 213 | ||||
-rw-r--r-- | net/cvsup-mirror/pkg-plist | 6 | ||||
-rw-r--r-- | net/cvsup-mirror/scripts/configure | 198 |
10 files changed, 663 insertions, 0 deletions
diff --git a/net/cvsup-mirror/Makefile b/net/cvsup-mirror/Makefile new file mode 100644 index 000000000000..5c96d248fbcf --- /dev/null +++ b/net/cvsup-mirror/Makefile @@ -0,0 +1,45 @@ +# New ports collection makefile for: cvsup-mirror +# Version required: none +# Date created: 01 February 1997 +# Whom: jdp +# +# $Id$ +# + +DISTNAME= cvsup-mirror-1.0 +CATEGORIES= net +DISTFILES= + +MAINTAINER= jdp@FreeBSD.org + +RUN_DEPENDS= ${PREFIX}/sbin/cvsupd:${PORTSDIR}/net/cvsup +NO_WRKSUBDIR= true +NO_CHECKSUM= true +NO_PATCH= true +NO_BUILD= true +IS_INTERACTIVE= true +NO_PACKAGE= too interactive +SCRIPTS_ENV= USA_RESIDENT=${USA_RESIDENT} + +base=${PREFIX}/etc/cvsup +rc=${PREFIX}/etc/rc.d + +do-extract: + @test -d ${WRKSRC} || ${MKDIR} ${WRKSRC} + +do-install: + @echo "Installing files" + @test -d ${base} || mkdir -p ${base} + @test -d ${rc} || mkdir -p ${rc} + @${INSTALL_DATA} ${WRKSRC}/config.sh ${base} + @${INSTALL_SCRIPT} ${FILESDIR}/update.sh ${base} + @${INSTALL_DATA} ${FILESDIR}/supfile ${base} + @${INSTALL_DATA} ${FILESDIR}/supfile.crypto ${base} + @${INSTALL_DATA} ${FILESDIR}/supfile.non-crypto ${base} + @${INSTALL_SCRIPT} ${FILESDIR}/cvsupd.sh ${rc} + @${CP} /dev/null ${base}/.start_server + +post-install: + @PREFIX=${PREFIX} /bin/sh ${PKGDIR}/INSTALL ${PKGNAME} POST-INSTALL + +.include <bsd.port.mk> diff --git a/net/cvsup-mirror/files/cvsupd.sh b/net/cvsup-mirror/files/cvsupd.sh new file mode 100644 index 000000000000..1190e591c685 --- /dev/null +++ b/net/cvsup-mirror/files/cvsupd.sh @@ -0,0 +1,16 @@ +#! /bin/sh + +if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/cvsupd\.sh\$"); then + echo "$0: Cannot determine the PREFIX" >&2 + exit 1 +fi +base=${PREFIX}/etc/cvsup + +export PATH=/bin:/usr/bin:${PREFIX}/sbin +umask 2 + +test -x ${PREFIX}/sbin/cvsupd || exit 1 +echo -n " cvsupd" +cd ${base} || exit +. config.sh || exit +su -m ${user} -c "cvsupd -C ${maxclients} -l @${facility}" diff --git a/net/cvsup-mirror/files/supfile b/net/cvsup-mirror/files/supfile new file mode 100644 index 000000000000..fb82b1916263 --- /dev/null +++ b/net/cvsup-mirror/files/supfile @@ -0,0 +1,11 @@ +# +# Standard supfile for CVSup FreeBSD mirrors. +# +*default delete use-rel-suffix +cvs-all release=cvs prefix=prefixes/FreeBSD.cvs norsync +cvs-crypto release=cvs prefix=prefixes/FreeBSD-crypto.cvs +src-sys release=lite2 prefix=prefixes/FreeBSD.lite2 norsync +src-sys release=smp prefix=prefixes/FreeBSD.smp norsync +gnats release=current prefix=prefixes/FreeBSD-gnats.current +www release=current prefix=prefixes/FreeBSD-www.current +distrib release=self prefix=prefixes/distrib.self diff --git a/net/cvsup-mirror/files/update.sh b/net/cvsup-mirror/files/update.sh new file mode 100644 index 000000000000..c6b73c474e91 --- /dev/null +++ b/net/cvsup-mirror/files/update.sh @@ -0,0 +1,68 @@ +#! /bin/sh + +if ! export PREFIX=$(expr $0 : "\(/.*\)/etc/cvsup/update\.sh\$"); then + echo "$0: Cannot determine the PREFIX" >&2 + exit 1 +fi + +export PATH=/bin:/usr/bin:${PREFIX}/bin + +lock=/var/spool/lock/cvsup.lock +log=/var/log/cvsup.log + +# Rotate the log files + +umask 22 +test -f ${log}.7 && mv -f ${log}.7 ${log}.8 +test -f ${log}.6 && mv -f ${log}.6 ${log}.7 +test -f ${log}.5 && mv -f ${log}.5 ${log}.6 +test -f ${log}.4 && mv -f ${log}.4 ${log}.5 +test -f ${log}.3 && mv -f ${log}.3 ${log}.4 +test -f ${log}.2 && mv -f ${log}.2 ${log}.3 +test -f ${log}.1 && mv -f ${log}.1 ${log}.2 +test -f ${log}.0 && mv -f ${log}.0 ${log}.1 +test -f ${log} && mv -f ${log} ${log}.0 +exec >${log} 2>&1 + +# Do the update + +date "+CVSup update begins at %Y/%m/%d %H:%M:%S" + +# The rest of this is executed while holding the lock file, to ensure that +# multiple instances won't collide with one another. + +lockf -t 0 ${lock} /bin/sh << 'E*O*F' + +base=${PREFIX}/etc/cvsup +cd ${base} || exit +. config.sh || exit + +colldir=sup.client +startup=${PREFIX}/etc/rc.d + +umask 2 + +if [ ${host_crypto} = ${host} ]; then + echo "Updating from ${host}" + cvsup -gL 1 -c ${colldir} -h ${host} supfile +else + if [ -d prefixes/FreeBSD-crypto.cvs ]; then + echo "Updating from ${host_crypto}" + cvsup -gL 1 -c ${colldir} -h ${host_crypto} supfile.crypto + fi + echo "Updating from ${host}" + cvsup -gL 1 -c ${colldir} -h ${host} supfile.non-crypto +fi + +if [ -f .start_server ]; then + if [ -x ${startup}/cvsupd.sh ]; then + echo -n "Starting the server:" + /bin/sh ${startup}/cvsupd.sh + echo "." + fi + rm -f .start_server +fi + +E*O*F + +date "+CVSup update ends at %Y/%m/%d %H:%M:%S" diff --git a/net/cvsup-mirror/pkg-comment b/net/cvsup-mirror/pkg-comment new file mode 100644 index 000000000000..be0369519ec5 --- /dev/null +++ b/net/cvsup-mirror/pkg-comment @@ -0,0 +1 @@ +A kit for easily setting up a FreeBSD mirror site using CVSup. diff --git a/net/cvsup-mirror/pkg-deinstall b/net/cvsup-mirror/pkg-deinstall new file mode 100644 index 000000000000..44d0200eb9e1 --- /dev/null +++ b/net/cvsup-mirror/pkg-deinstall @@ -0,0 +1,90 @@ +#! /bin/sh + +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 +} + +if [ x$2 != xDEINSTALL ]; then + exit +fi + +export PATH=/bin:/usr/bin:/usr/sbin + +base=${PKG_PREFIX}/etc/cvsup + +. ${base}/config.sh || exit + +if ps -axc | grep -q cvsupd; then + echo "Please kill your running cvsupd processes first" >&2 + exit 1 +fi + +tmp="/etc/#cvsma$$" +trap "rm -f ${tmp}" 0 1 2 3 15 + +rm -rf ${base}/prefixes +rm -f ${base}/.start_server + +if yesno "Do you want me to remove scheduled updates from \"/etc/crontab\"" y +then + sed "/\/etc\/cvsup\/update\.sh/d" /etc/crontab >${tmp} || exit + chmod 644 ${tmp} + mv ${tmp} /etc/crontab || exit + echo "Done." +fi + +if yesno \ + "Do you want me to remove the cvsupd logging from \"/etc/syslog.conf\"" y +then + sed "/^!cvsupd/,/cvsupd\.log\$/d" /etc/syslog.conf >${tmp} || exit + chmod 644 ${tmp} + mv ${tmp} /etc/syslog.conf || exit + + if [ -f /var/run/syslog.pid ]; then + echo "Giving syslogd a kick in the pants." + kill -HUP $(cat /var/run/syslog.pid) + fi + echo "Done." +fi + +if yesno "Do you want me to remove the cvsupd log entry from \ +\"/etc/newsyslog.conf\"" y; then + sed "/cvsupd\.log/d" /etc/newsyslog.conf >${tmp} || exit + chmod 644 ${tmp} + mv ${tmp} /etc/newsyslog.conf || exit + echo "Done." +fi + +if yesno "Do you want me to remove group \"${group}\"" y; then + pw groupdel -n ${group} + echo "Done." +fi +if yesno "Do you want me to remove user \"${user}\"" y; then + pw userdel -n ${user} + echo "Done." +fi diff --git a/net/cvsup-mirror/pkg-descr b/net/cvsup-mirror/pkg-descr new file mode 100644 index 000000000000..d8dd415f0202 --- /dev/null +++ b/net/cvsup-mirror/pkg-descr @@ -0,0 +1,15 @@ +This is the CVSup Mirror Kit, an easy way to set up a FreeBSD mirror +site. When you type "make", it asks you a few questions about +which files you want to mirror, where you want to put them on your +disks, where you want to update them from, etc. After a "make +install" your system will then be running as a nearly self-maintaining +FreeBSD mirror site. It will even update its own configuration +files from the master site automatically. + +This kit is not for people who just want to keep their own files +up to date with CVSup. It is for people who wish to run servers +that distribute the FreeBSD sources to others. + +This port requires CVSup version 14.1.1 or later. + +jdp@FreeBSD.org diff --git a/net/cvsup-mirror/pkg-install b/net/cvsup-mirror/pkg-install new file mode 100644 index 000000000000..ef180f4b5d61 --- /dev/null +++ b/net/cvsup-mirror/pkg-install @@ -0,0 +1,213 @@ +#! /bin/sh + +base=${PREFIX}/etc/cvsup +prefixes=${base}/prefixes + +chmods_done=" " + +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 +} + +install_links() { + local link dir subdir path + + while [ $# -ge 3 ]; do + link=$1 + dir=$2 + subdir=$3 + echo " Linking ${link} -> ${dir}" + ln -sf ${dir} ${prefixes}/${link} || exit + if [ "x${dir}" != "xSKIP" -a "x${dir}" != "x.." ]; then + if [ "x${subdir}" = "x." ]; then + path=${dir} + else + path=${dir}/${subdir} + fi + ( cd ${prefixes} || exit + test -d ${path} || mkdir -p ${path} || exit ) + if ! expr "${chmods_done}" : ".* ${path} " >/dev/null 2>&1; then + echo -n " Making the ${path} tree world-readable ..." + ( chdir ${prefixes} || exit + chmod -R a+rX ${path} || exit ) + echo " done." + chmods_done="${chmods_done}${path} " + fi + fi + shift 3 + done +} + +case $2 in + +POST-INSTALL) + . ${base}/config.sh || exit + + if which -s pw && which -s lockf; then + : + else + cat <<EOF + +This system looks like a pre-2.2 version of FreeBSD. I see that it +is missing the "lockf" and/or "pw" utilities. I need these utilities. +Please get them and install them, and try again. You can get the +sources from: + + ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.bin/lockf.tar.gz + ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.sbin/pw.tar.gz + +EOF + exit 1 + fi + + echo "" + if grep -q "^${group}:" /etc/group; then + echo "You already have a group \"${group}\", so I will use it." + else + echo "You need a group \"${group}\"." + if which -s pw && yesno "Would you like me to create it" y; then + pw groupadd ${group} || exit + echo "Done." + else + echo "Please create it, and try again." + if ! grep -q "^${user}:" /etc/passwd; then + echo "While you're at it, please create a user \"${user}\" too," + echo "with a default group of \"${group}\"." + fi + exit 1 + fi + fi + + if grep -q "^${user}:" /etc/passwd; then + echo "You already have a user \"${user}\", so I will use it." + else + echo "You need a user \"${user}\"." + if which -s pw && yesno "Would you like me to create it" y; then + pw useradd ${user} -g ${group} -h - -d /nonexistent \ + -s /nonexistent -c "CVSup Daemon" || exit + echo "Done." + else + echo "Please create it, and try again." + exit 1 + fi + fi + + echo "Fixing ownerships and modes in \"${base}\"." + chown -R root.${group} ${base} + chmod -R g=u,o=u-w ${base} + + echo "Setting up links and directories for distributions." + test -d ${prefixes} || mkdir ${prefixes} || exit + install_links ${distribs} + + echo "" + if grep -q "^[^#]*${facility}.*/var/log/cvsupd.log" /etc/syslog.conf; then + echo -n "It looks like you already have some logging set up, so I " + echo "will use it." + else + if yesno "Would you like me to set up the syslog logging" y; then + echo "Setting up server logging in \"/etc/syslog.conf\"." + cat <<EOF >>/etc/syslog.conf +!cvsupd +${facility}.info /var/log/cvsupd.log +EOF + + if [ ! -f /var/log/cvsupd.log ]; then + echo "Creating \"/var/log/cvsupd.log\"." + cp /dev/null /var/log/cvsupd.log + fi + + if [ -f /var/run/syslog.pid ]; then + echo "Giving syslogd a kick in the pants." + kill -HUP $(cat /var/run/syslog.pid) + fi + + echo "Adding cvsupd log entry to \"/etc/newsyslog.conf\"." + cat <<EOF >>/etc/newsyslog.conf +/var/log/cvsupd.log 664 7 * 24 Z +EOF + echo "Done." + else + cat <<EOF +OK, please remember to do it yourself. You should log "${facility}.info" +to "/var/log/cvsupd.log". Don't forget to add an entry to +"/etc/newsyslog.conf". +EOF + fi + fi + + echo "" + if grep -q "^[^#]*${base}/update\.sh" /etc/crontab; then + echo "It looks like your crontab is already set up, so I'll use that." + else + if [ ${interval} -eq 1 ]; then + updstr="hourly updates" + else + updstr="updates every ${interval} hours" + fi + if yesno "Would you like me to set up your crontab for ${updstr}" y + then + echo "Scheduling ${updstr} in \"/etc/crontab\"." + delay=5 + now=$(date "+%s") + start=$((${now} + ${delay}*60)) + hh=$(date -r ${start} "+%H") + mm=$(date -r ${start} "+%M") + h=$((${hh})) + m=$((${mm})) + if [ ${interval} -eq 1 ]; then + hstr="*" + else + h0=$((${h} % ${interval})) + if [ ${interval} -eq 24 ]; then + hstr=${h0} + else + h1=$((${h0} + 24 - ${interval})) + hstr=${h0}-${h1}/${interval} + fi + fi + cat <<EOF >>/etc/crontab +${m} ${hstr} * * * root ${base}/update.sh +EOF + cat <<EOF +Done. The first update will be ${delay} minutes from now, at ${hh}:${mm}. +The cvsupd server will be started automatically after the first update, +and whenever you reboot. +EOF + else + cat <<EOF +OK, please remember to do it yourself. The crontab entry should run +"${base}/update.sh" as root. +EOF + fi + fi + + echo "" + echo "You are now a FreeBSD mirror site." + ;; +esac diff --git a/net/cvsup-mirror/pkg-plist b/net/cvsup-mirror/pkg-plist new file mode 100644 index 000000000000..cd07ad92cf0f --- /dev/null +++ b/net/cvsup-mirror/pkg-plist @@ -0,0 +1,6 @@ +etc/cvsup/config.sh +etc/cvsup/supfile +etc/cvsup/supfile.crypto +etc/cvsup/supfile.non-crypto +etc/cvsup/update.sh +etc/rc.d/cvsupd.sh diff --git a/net/cvsup-mirror/scripts/configure b/net/cvsup-mirror/scripts/configure new file mode 100644 index 000000000000..6854f90ad8f0 --- /dev/null +++ b/net/cvsup-mirror/scripts/configure @@ -0,0 +1,198 @@ +#! /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 + 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 (340 MB)" +ask_distrib FreeBSD-crypto.cvs /home/ncvs . \ + "crypto code (7 MB)" +ask_distrib FreeBSD.lite2 /home/lite2 . \ + "BSD-4.4lite2 merge source tree (45 MB)" +ask_distrib FreeBSD.smp /home/smp . \ + "SMP support source tree (25 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)" + +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." |