summaryrefslogtreecommitdiff
path: root/net/cvsup-mirror/scripts/configure
blob: 40f858f8262c7808b03512c9bb50e138307441ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#! /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" cvsup-master.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."