2008-07-20 23:13:01 -04:00
|
|
|
#!/bin/sh
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org>
|
2006-01-30 21:49:24 -05:00
|
|
|
#
|
2008-07-20 23:13:01 -04:00
|
|
|
# Permission to use, copy, modify, and distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
2006-01-30 21:49:24 -05:00
|
|
|
#
|
2008-07-20 23:13:01 -04:00
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
2008-10-20 22:57:51 -04:00
|
|
|
[ "${SYSCONFDIR}" ] || SYSCONFDIR=/etc
|
2009-03-28 12:11:48 -04:00
|
|
|
[ "${TRUEPREFIX}" ] || TRUEPREFIX=/usr/local
|
2008-10-20 22:57:51 -04:00
|
|
|
|
2009-03-28 12:11:48 -04:00
|
|
|
afsp=${TRUEPREFIX}/libexec/openafs
|
|
|
|
PATH=${TRUEPREFIX}/sbin:${TRUEPREFIX}/bin:$PATH
|
2008-10-08 11:45:55 -04:00
|
|
|
DIR=`mktemp -d /tmp/_openafs.XXXXXXXXXX` || exit 1
|
|
|
|
trap 'rm -rf $DIR; exit 1' 0 1 2 3 13 15
|
|
|
|
OUTPUT=$DIR/_1
|
2009-03-26 17:28:47 -04:00
|
|
|
defuser="$USER"
|
|
|
|
if [ "$defuser" = "root" ]; then
|
|
|
|
if [ "$SUDO_USER" ]; then
|
|
|
|
defuser="$SUDO_USER"
|
|
|
|
else
|
|
|
|
defuser="todd"
|
|
|
|
fi
|
|
|
|
fi
|
2008-07-20 23:13:01 -04:00
|
|
|
|
|
|
|
# (borrowed from install.sub)
|
|
|
|
# Ask for user input.
|
|
|
|
#
|
|
|
|
# $1 = the question to ask the user
|
|
|
|
# $2 = the default answer
|
|
|
|
#
|
|
|
|
# Save the user input (or the default) in $resp.
|
|
|
|
#
|
|
|
|
# Allow the user to escape to shells ('!') or execute commands
|
|
|
|
# ('!foo') before entering the input.
|
|
|
|
ask() {
|
|
|
|
local _question=$1 _default=$2
|
|
|
|
|
|
|
|
set -o noglob
|
|
|
|
while :; do
|
|
|
|
echo -n "$_question "
|
|
|
|
[[ -z $_default ]] || echo -n "[$_default] "
|
|
|
|
read resp
|
|
|
|
case $resp in
|
|
|
|
!) echo "Type 'exit' to return to install."
|
|
|
|
sh
|
|
|
|
;;
|
|
|
|
!*) eval ${resp#?}
|
|
|
|
;;
|
|
|
|
*) : ${resp:=$_default}
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
set +o noglob
|
|
|
|
}
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Ask for user input until a non-empty reply is entered.
|
|
|
|
#
|
|
|
|
# $1 = the question to ask the user
|
|
|
|
# $2 = the default answer
|
|
|
|
#
|
|
|
|
# Save the user input (or the default) in $resp.
|
|
|
|
ask_until() {
|
|
|
|
resp=
|
|
|
|
while [[ -z $resp ]] ; do
|
|
|
|
ask "$1" "$2"
|
|
|
|
done
|
2006-01-30 21:49:24 -05:00
|
|
|
}
|
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Ask the user for a y or n, and insist on 'y', 'yes', 'n' or 'no'.
|
|
|
|
#
|
|
|
|
# $1 = the question to ask the user
|
|
|
|
# $2 = the default answer (assumed to be 'n' if empty).
|
|
|
|
#
|
|
|
|
# Return 'y' or 'n' in $resp.
|
|
|
|
ask_yn() {
|
|
|
|
local _q=$1 _a=${2:-no} _resp
|
|
|
|
typeset -l _resp
|
|
|
|
|
|
|
|
while :; do
|
|
|
|
ask "$_q" "$_a"
|
|
|
|
_resp=$resp
|
|
|
|
case $_resp in
|
|
|
|
y|yes) resp=y ; return ;;
|
|
|
|
n|no) resp=n ; return ;;
|
|
|
|
esac
|
|
|
|
done
|
2006-01-30 21:49:24 -05:00
|
|
|
}
|
|
|
|
|
2006-02-08 09:50:07 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Logging routine
|
|
|
|
#
|
|
|
|
# $1 = -c or 1st arg
|
|
|
|
# $2 = ...
|
|
|
|
#
|
|
|
|
# log all arguments
|
|
|
|
sc=0
|
|
|
|
log() {
|
2008-10-08 11:45:55 -04:00
|
|
|
local prompt=":"
|
2008-07-20 23:13:01 -04:00
|
|
|
if [ "$1" = "-c" ]; then
|
2008-10-08 11:45:55 -04:00
|
|
|
prompt="#"
|
2008-07-20 23:13:01 -04:00
|
|
|
shift
|
2006-02-08 09:50:07 -05:00
|
|
|
else
|
2008-07-20 23:13:01 -04:00
|
|
|
let sc=sc+1
|
2006-02-08 09:50:07 -05:00
|
|
|
fi
|
2008-10-08 11:45:55 -04:00
|
|
|
dfmt="%H:%M:%S"
|
|
|
|
printf "%s %02d%s " "$(date +"${dfmt}")" $sc "$prompt"
|
|
|
|
# use echo, because printf(1) treats varargs as one arg per line, ugh
|
|
|
|
echo "$@"
|
2006-02-08 09:50:07 -05:00
|
|
|
}
|
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Create a principal in kerberos.
|
|
|
|
#
|
|
|
|
# $1 = principal
|
|
|
|
# $2 = extra arg..
|
|
|
|
#
|
|
|
|
# Delete the principal first before re-adding it to make sure proper
|
|
|
|
# attributes exist.
|
|
|
|
kadd() {
|
|
|
|
local principal=$1
|
|
|
|
log creating principal: $principal
|
|
|
|
shift
|
|
|
|
kadmin del $principal > /dev/null 2>&1
|
2008-10-08 11:45:55 -04:00
|
|
|
log -c kadmin add "$@" $principal
|
2008-07-20 23:13:01 -04:00
|
|
|
kadmin add \
|
|
|
|
--{pw-,}expiration-time=never \
|
|
|
|
--max-ticket-life="1 month" \
|
|
|
|
--max-renewable-life="2 months" \
|
|
|
|
--attributes="" \
|
|
|
|
"$@" $principal
|
2006-02-08 09:50:07 -05:00
|
|
|
}
|
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Re-try a command until success.
|
|
|
|
#
|
|
|
|
# $@ = full command to try
|
|
|
|
#
|
|
|
|
retry() {
|
|
|
|
local try=1
|
2008-10-08 11:45:55 -04:00
|
|
|
log -c "$@"
|
2008-07-20 23:13:01 -04:00
|
|
|
while ! $@
|
|
|
|
do
|
|
|
|
let try=try+1
|
2008-10-08 11:45:55 -04:00
|
|
|
log -c "$@ : try $try"
|
2008-07-20 23:13:01 -04:00
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
}
|
2006-02-08 09:50:07 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Make an afs volume.
|
|
|
|
#
|
|
|
|
# $1 = volume name
|
|
|
|
# $2 = volume mount point
|
|
|
|
#
|
|
|
|
# Any user can read volumes created here.
|
|
|
|
mkvol() {
|
|
|
|
local vol=$1 mnt=$2
|
|
|
|
log "Creating afs volume $1 to be mounted at $mnt"
|
|
|
|
retry vos create $h /vicepa $vol
|
2008-10-08 11:45:55 -04:00
|
|
|
retry fs mkm $mnt $vol
|
|
|
|
retry fs sa $mnt system:anyuser rl
|
2008-07-20 23:13:01 -04:00
|
|
|
}
|
2006-02-10 13:12:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
cat <<__EOT
|
2006-02-10 13:12:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
===========================================================================
|
|
|
|
Welcome to the OpenAFS server1 setup script!
|
2006-02-17 21:05:49 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
This script will assist you in setting up your first afs server.
|
2006-02-17 21:05:49 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
It will use OpenAFS for the AFS server, but arla's afsd that comes with
|
|
|
|
OpenBSD for the AFS client.
|
2006-02-17 21:05:49 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
It will use heimdal KerberosV that comes with OpenBSD.
|
2006-02-10 13:12:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
It presumes you have previously successfully setup a KerberosV realm,
|
|
|
|
you have the password to an administrative principal in the KerberosV realm,
|
|
|
|
you are running it as root, and you have created at least one partition
|
|
|
|
for OpenAFS to use for data storage. Partitions should be mounted under
|
|
|
|
/vicepa, /vicepb, /vicepc, etc.
|
2006-02-10 13:12:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
===========================================================================
|
|
|
|
__EOT
|
2006-02-08 09:50:07 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
#
|
2008-10-11 20:12:07 -04:00
|
|
|
# Sanity checks
|
2008-07-20 23:13:01 -04:00
|
|
|
#
|
2006-02-08 09:50:07 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Require root.
|
|
|
|
if [[ `/usr/bin/whoami` != "root" ]]
|
2006-02-08 09:50:07 -05:00
|
|
|
then
|
2008-07-20 23:13:01 -04:00
|
|
|
echo "Please run this script as root. Thanks."
|
2006-02-08 09:50:07 -05:00
|
|
|
exit
|
2006-01-30 21:49:24 -05:00
|
|
|
fi
|
2008-07-20 23:13:01 -04:00
|
|
|
if [[ `mount|grep " /vicepa "` = "" ]]
|
2006-01-30 21:49:24 -05:00
|
|
|
then
|
2008-07-20 23:13:01 -04:00
|
|
|
echo "Could not find any filesystem mounted at /vicepa"
|
|
|
|
echo "Without this OpenAFS will not function."
|
|
|
|
echo "Please mount a partition under /vicepa"
|
|
|
|
echo "A /vicepa directory will not work as"
|
|
|
|
echo "OpenAFS"
|
2006-01-30 21:49:24 -05:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
#
|
|
|
|
# Setup site specific variables
|
|
|
|
#
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# Ask user for variables if not passed on the command line.
|
|
|
|
if ! [ "$6" ]
|
|
|
|
then
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
The hostname for this afs server should resolve in dns but
|
2008-10-12 13:31:17 -04:00
|
|
|
definitely reside in /etc/hosts. e.g. afs0.example.com.
|
2008-07-20 23:13:01 -04:00
|
|
|
__EOT
|
|
|
|
while :; do
|
|
|
|
ask_until "System hostname?" "$(hostname)"
|
|
|
|
h=${resp}
|
2008-10-12 13:31:17 -04:00
|
|
|
if [[ `grep $h /etc/hosts` = "" ]]
|
2008-07-20 23:13:01 -04:00
|
|
|
then
|
2008-10-12 13:31:17 -04:00
|
|
|
echo "Could not find /etc/hosts entry for $h."
|
2008-07-20 23:13:01 -04:00
|
|
|
continue
|
|
|
|
fi
|
2008-10-20 22:57:51 -04:00
|
|
|
if [[ `grep $(hostname) /etc/hosts` = "" ]]
|
|
|
|
then
|
|
|
|
echo "Could not find /etc/hosts entry for $(hostname)."
|
|
|
|
echo "(afs processes use the system hostname..)"
|
|
|
|
continue
|
|
|
|
fi
|
2006-01-30 21:49:24 -05:00
|
|
|
break
|
2008-07-20 23:13:01 -04:00
|
|
|
done
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
The IPv4 IP address for this afs server should resolve in dns but
|
2008-10-12 13:31:17 -04:00
|
|
|
definitely reside in /etc/hosts. e.g. 192.168.1.200.
|
2008-07-20 23:13:01 -04:00
|
|
|
__EOT
|
|
|
|
while :; do
|
|
|
|
ask_until "System IP?" "$(host $h | \
|
|
|
|
awk '/has address/{print $4}')"
|
|
|
|
ip=${resp}
|
2008-10-12 13:31:17 -04:00
|
|
|
if [[ `grep $ip /etc/hosts` = "" ]]
|
2008-07-20 23:13:01 -04:00
|
|
|
then
|
2008-10-12 13:31:17 -04:00
|
|
|
echo "Could not find /etc/hosts entry for $ip."
|
2008-07-20 23:13:01 -04:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
done
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
The cell name is typically a dns name. e.g. example.com.
|
|
|
|
__EOT
|
|
|
|
ask_until "AFS Cell Name?" "${h#*.}"
|
|
|
|
c=${resp}
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
The realm name is the KerberosV REALM, typically the capitalized dns name.
|
|
|
|
e.g. REALM.COM. Use something different at the expense of your sanity.
|
|
|
|
Really.
|
|
|
|
__EOT
|
|
|
|
ask_until "KerberosV REALM?" "$(echo "$c"|tr "[a-z]" "[A-Z]")"
|
|
|
|
R=${resp}
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
This is an existing KerberosV principal with the ability to
|
2009-03-26 17:28:47 -04:00
|
|
|
create and delete other kerberos principals. e.g. $defuser/admin.
|
2008-07-20 23:13:01 -04:00
|
|
|
__EOT
|
|
|
|
ask_until "KerberosV principal for kerberos administration?" \
|
2009-03-26 17:28:47 -04:00
|
|
|
"$defuser/admin"
|
2008-07-20 23:13:01 -04:00
|
|
|
p=${resp}
|
2008-10-20 22:57:51 -04:00
|
|
|
echo
|
|
|
|
ask_until "Is this the first server setup in the $c cell?" "Y"
|
|
|
|
case "${resp}" in [Yy]*) first=1;; *) first=0;; esac
|
|
|
|
if [ first -eq 0 ]; then
|
|
|
|
set -A sservers fs
|
|
|
|
echo
|
|
|
|
ask_until "What is the primary afs server's name (e.g. afs0.example.com)?"
|
|
|
|
psn=$resp
|
|
|
|
ask_until "What is the primary afs server's IP (e.g. 10.1.2.3)?"
|
|
|
|
psip=$resp
|
|
|
|
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
This principal should already exist from the 1st afs server setup, and
|
|
|
|
will be used to administer afs in a similar way that \`root'
|
|
|
|
can administrate OpenBSD. Tread lightly when using this principal.
|
|
|
|
__EOT
|
|
|
|
else
|
|
|
|
set -A sservers buserver ptserver vlserver fs
|
|
|
|
cat <<__EOT
|
2008-07-20 23:13:01 -04:00
|
|
|
|
2008-10-20 22:57:51 -04:00
|
|
|
Just a sample user to create a basic homedir and account on afs with.
|
2008-07-20 23:13:01 -04:00
|
|
|
__EOT
|
2009-06-18 12:18:12 -04:00
|
|
|
ask_until "KerberosV principal for example user?" "$defuser"
|
2008-10-20 22:57:51 -04:00
|
|
|
u=${resp}
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
This principal will be deleted if it exists, then created with specific
|
|
|
|
attributes. It will be used to administer afs in a similar way that \`root'
|
|
|
|
can administrate OpenBSD. Tread lightly when using this principal.
|
|
|
|
__EOT
|
|
|
|
fi
|
2009-06-18 12:18:12 -04:00
|
|
|
ask_until "KerberosV principal for afs administration?" \
|
2009-03-26 17:28:47 -04:00
|
|
|
"$defuser/afs"
|
2008-07-20 23:13:01 -04:00
|
|
|
A=${resp}
|
2008-10-20 22:57:51 -04:00
|
|
|
slist="" i=0
|
|
|
|
while [ i -lt ${#sservers[*]} ]; do
|
|
|
|
slist="$slist ${sservers[$i]}"
|
|
|
|
let i=i+1
|
|
|
|
done
|
|
|
|
slist="${slist# *}"
|
2008-10-08 11:45:55 -04:00
|
|
|
cat <<__EOT
|
|
|
|
|
2008-10-20 22:57:51 -04:00
|
|
|
Each afs server can run one or more openafs server processes:
|
|
|
|
vlserver(8) - volume location server, keeps track of volume locations
|
|
|
|
ptserver(8) - protection server for users, groups, and permissions
|
|
|
|
buserver(8) - permit backups to occur for vlserver and ptserver databases
|
|
|
|
fs - fileserver, volserver, salvager (for hosts that store files)
|
2008-10-08 11:45:55 -04:00
|
|
|
__EOT
|
2008-10-20 22:57:51 -04:00
|
|
|
ask_until "Servers to run on $h?" "$slist"
|
|
|
|
set -A sservers $resp
|
2008-07-20 23:13:01 -04:00
|
|
|
else
|
|
|
|
# for advanced users, this script can be started with the above
|
|
|
|
# pre-populated via arguments
|
2008-10-08 11:45:55 -04:00
|
|
|
h="$1" ip="$2" c="$3" R="$4" p="$5" A="$6" u="$7"
|
2008-07-20 23:13:01 -04:00
|
|
|
fi
|
2006-02-08 09:50:07 -05:00
|
|
|
|
2008-10-20 22:57:51 -04:00
|
|
|
slist="" i=0 vl2=0
|
|
|
|
while [ i -lt ${#sservers[*]} ]; do
|
2009-03-26 17:28:47 -04:00
|
|
|
if [ "${sservers[$i]}" = "vlserver" -a first -eq 0 ]; then
|
2008-10-20 22:57:51 -04:00
|
|
|
# we are a 2ndary server running vlserver, save to CellServDB
|
|
|
|
vl2=1
|
|
|
|
fi
|
|
|
|
slist="$slist ${sservers[$i]}"
|
|
|
|
let i=i+1
|
|
|
|
done
|
|
|
|
slist="${slist# *}"
|
|
|
|
|
2008-10-08 11:45:55 -04:00
|
|
|
pp=$(echo "$p"|sed 's,/,.,')
|
|
|
|
pA=$(echo "$A"|sed 's,/,.,')
|
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
cat <<__EOT
|
2006-02-08 09:50:07 -05:00
|
|
|
|
2008-10-08 11:45:55 -04:00
|
|
|
Confirm these look correct:
|
2008-07-20 23:13:01 -04:00
|
|
|
hostname : $h
|
|
|
|
IP address : $ip
|
|
|
|
cellname : $c
|
|
|
|
realm : $R
|
2008-10-08 11:45:55 -04:00
|
|
|
krb admin : $p (pts name: $pp)
|
|
|
|
afs admin : $A (pts name: $pA)
|
2008-10-20 22:57:51 -04:00
|
|
|
afs servers: $slist
|
|
|
|
__EOT
|
|
|
|
if [ first -eq 1 ]; then
|
|
|
|
cat <<__EOT
|
2008-10-08 11:45:55 -04:00
|
|
|
sample user: $u
|
2008-10-20 22:57:51 -04:00
|
|
|
__EOT
|
|
|
|
else
|
|
|
|
cat <<__EOT
|
|
|
|
prim. name : $psn
|
|
|
|
prim. ip : $psip
|
|
|
|
__EOT
|
|
|
|
fi
|
|
|
|
cat <<__EOT
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-10-08 11:45:55 -04:00
|
|
|
The next step *DESTROYS* all existing OpenAFS configuration on this system,
|
|
|
|
including any openafs data on all /vicep* partitions!
|
2008-07-20 23:13:01 -04:00
|
|
|
__EOT
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
ask_yn "Are you really sure that you're ready to proceed?"
|
|
|
|
[[ $resp == n ]] && { echo "Ok, try again later.\n" ; exit ; }
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-10-08 11:45:55 -04:00
|
|
|
echo
|
2008-10-12 13:31:17 -04:00
|
|
|
log "preparing ${SYSCONFDIR}/{open,}afs /usr/afs /var/openafs..."
|
2008-10-08 11:45:55 -04:00
|
|
|
|
2008-10-20 22:57:51 -04:00
|
|
|
# Initialize the filesystems
|
|
|
|
initfs() {
|
|
|
|
kdestroy
|
|
|
|
pkill -9 afsd
|
|
|
|
umount /afs > /dev/null 2>&1
|
|
|
|
if [ -d /var/spool/afs ]; then
|
|
|
|
log clearing afs cache
|
|
|
|
retry rm -rf -- "/var/spool/afs/*"
|
|
|
|
retry mkdir -p /var/spool/afs
|
|
|
|
fi
|
|
|
|
log stopping any pre-existing arla and/or openafs daemons
|
|
|
|
if [ "$(pgrep bosserver)" ]
|
|
|
|
then
|
|
|
|
bos shutdown localhost -noauth -wait > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
if [ "$(pgrep bosserver)" ]
|
|
|
|
then
|
|
|
|
bos shutdown localhost -localauth -wait > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
pkill -9 buserver ptserver vlserver fileserver volserver bos bosserver
|
|
|
|
retry rm -rf ${SYSCONFDIR}/openafs /usr/afs /var/openafs
|
|
|
|
retry rm -rf /vicep*/{V*,AFSIDat,Lock}
|
|
|
|
retry rm -f /etc/kerberosV/krb5.keytab
|
|
|
|
|
|
|
|
retry mkdir -p ${SYSCONFDIR}/openafs/server /usr/afs /var/spool/afs
|
|
|
|
retry mkdir -m 700 /var/openafs
|
|
|
|
echo "f $ip" > /var/openafs/NetInfo
|
|
|
|
echo "$R" > ${SYSCONFDIR}/openafs/server/krb.conf
|
|
|
|
ln -s /var/openafs/db /usr/afs/db
|
|
|
|
ln -s ${SYSCONFDIR}/openafs/server /usr/afs/etc
|
|
|
|
}
|
2008-10-08 11:45:55 -04:00
|
|
|
|
2008-10-12 13:31:17 -04:00
|
|
|
# borrowed from /etc/security, backup CellServDB
|
2008-10-08 11:45:55 -04:00
|
|
|
_fnchg() {
|
|
|
|
echo "$1" | sed 's/^\///;s/\//_/g'
|
|
|
|
}
|
2008-10-20 22:57:51 -04:00
|
|
|
|
|
|
|
# be extra cautious
|
|
|
|
backupcsdb() {
|
2008-10-08 11:45:55 -04:00
|
|
|
if [ -s $CURdb ]; then
|
|
|
|
diff -ua $CURdb $csdb > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ]; then
|
|
|
|
cp -p $CURdb $BACKdb
|
|
|
|
cp -p $csdb $CURdb
|
|
|
|
chown root:wheel $CURdb $BACKdb
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
cp -p $csdb $CURdb
|
|
|
|
chown root:wheel $CURdb
|
|
|
|
fi
|
2008-10-20 22:57:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# update the CellServDB's
|
|
|
|
writecsdb() {
|
|
|
|
# put back arla's CellServDB when this script exits
|
|
|
|
log "Adding cell $c to CellServDB"
|
|
|
|
trap 'rm -rf $DIR; cp $CURdb $csdb; exit 1' 0 1 2 3 13 15
|
|
|
|
echo ">$c # $c" > $DIR/CellServDB
|
|
|
|
if [ first -eq 0 ]; then
|
|
|
|
echo "$psip #$psn" >> $DIR/CellServDB
|
|
|
|
if [ vl2 -eq 1 ]; then
|
|
|
|
echo "$ip #$h" >> $DIR/CellServDB
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "$ip #$h" >> $DIR/CellServDB
|
|
|
|
fi
|
|
|
|
cat $DIR/CellServDB | \
|
|
|
|
tee -a $csdb ${SYSCONFDIR}/openafs/server/CellServDB
|
|
|
|
}
|
|
|
|
writethiscell() {
|
|
|
|
echo $c | tee ${SYSCONFDIR}/openafs/server/ThisCell > /etc/afs/ThisCell
|
|
|
|
}
|
|
|
|
hostkeytab() {
|
|
|
|
kadd host/$h --random-key
|
|
|
|
retry kadmin ext host/$h
|
|
|
|
chmod 0400 /etc/kerberosV/krb5.keytab
|
|
|
|
}
|
|
|
|
saveafskey() {
|
|
|
|
log creating ${SYSCONFDIR}/openafs/server/KeyFile
|
|
|
|
retry kadmin ext -k $DIR/afsv5key afs/$c
|
|
|
|
log -c ktutil copy $DIR/afsv5key AFSKEYFILE:${SYSCONFDIR}/openafs/server/KeyFile
|
|
|
|
ktutil copy $DIR/afsv5key AFSKEYFILE:${SYSCONFDIR}/openafs/server/KeyFile
|
|
|
|
retry chmod 600 ${SYSCONFDIR}/openafs/server/KeyFile
|
|
|
|
retry rm $DIR/afsv5key
|
|
|
|
}
|
|
|
|
createafskey() {
|
|
|
|
kadd afs/$c --random-key
|
|
|
|
}
|
|
|
|
addexampleuser() {
|
|
|
|
log When asked for a password below, the answer will set it.
|
|
|
|
let sc=sc-1
|
|
|
|
kadd $A
|
|
|
|
}
|
|
|
|
disablearla() {
|
|
|
|
log "Disabling arla admin commands (use openafs commands on servers):"
|
|
|
|
retry chmod 644 /usr/sbin/{bos,pts,vos,fs}
|
|
|
|
}
|
|
|
|
setuppts() {
|
|
|
|
log setting up pts memberships, $pA as initial afs admin
|
|
|
|
retry pts createuser -name $u -id `id -u $u` -cell $c -noauth
|
|
|
|
retry pts createuser -name $pA -cell $c -noauth
|
|
|
|
retry pts adduser $pA system:administrators -cell $c -noauth
|
|
|
|
retry pts mem system:administrators -cell $c -noauth
|
|
|
|
retry pts listentries -cell $c -noauth
|
|
|
|
retry bos addhost localhost $h -noauth
|
|
|
|
}
|
|
|
|
initcellp1() {
|
|
|
|
log creating root.afs
|
|
|
|
retry vos create $h /vicepa root.afs -noauth
|
|
|
|
retry vos create $h /vicepa root.cell -noauth
|
|
|
|
|
|
|
|
sync;sync
|
|
|
|
sleep 5
|
|
|
|
sync;sync
|
|
|
|
}
|
|
|
|
initcellp2() {
|
|
|
|
log setting permissions/creating volumes
|
|
|
|
retry fs sa /afs system:anyuser rl
|
|
|
|
retry fs flushvolume /afs
|
|
|
|
retry fs mkm /afs/.$c root.cell -cell $c -rw -fast
|
|
|
|
retry fs flushvolume /afs/.$c
|
|
|
|
retry fs sa /afs/.$c system:anyuser rl
|
|
|
|
retry fs flushvolume /afs/.$c
|
|
|
|
cat <<__EOT> /afs/.$c/robots.txt
|
|
|
|
# noticed at ualberta.ca, attempt to prevent robots from traversing afs
|
|
|
|
User-Agent: *
|
|
|
|
Disallow: /
|
|
|
|
__EOT
|
|
|
|
|
|
|
|
mkvol user /afs/.$c/u
|
2009-03-26 17:28:47 -04:00
|
|
|
mkvol user.$defuser /afs/.$c/u/$defuser
|
2008-10-20 22:57:51 -04:00
|
|
|
mkvol mirror /afs/.$c/mirror
|
|
|
|
retry vos addsite $h /vicepa mirror
|
|
|
|
retry vos release mirror
|
|
|
|
|
|
|
|
log Add some remote afs cells
|
|
|
|
# significant remote afs cells of note, and/or install mirrors
|
|
|
|
# as a basic set of remote cells for our example root.afs
|
|
|
|
set -A rc \
|
|
|
|
$c \
|
|
|
|
ualberta.ca \
|
|
|
|
stacken.kth.se \
|
|
|
|
grand.central.org \
|
|
|
|
su.se \
|
|
|
|
mrow.org
|
|
|
|
i=0
|
|
|
|
while [ i -lt ${#rc[*]} ]
|
|
|
|
do
|
|
|
|
log -c fs mkm /afs/${rc[$i]} root.cell -cell ${rc[$i]} -fast
|
|
|
|
fs mkm /afs/${rc[$i]} root.cell -cell ${rc[$i]} -fast
|
|
|
|
let i=i+1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# add files of note to /etc/changelist
|
|
|
|
addchg() {
|
|
|
|
while [ "$1" ]
|
|
|
|
do
|
|
|
|
f="$1"
|
|
|
|
shift
|
|
|
|
if egrep "^${f}$" /etc/changelist > /dev/null 2>&1; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "$f" >> /etc/changelist
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
log updating /etc/afs/CellServDB ${SYSCONFDIR}/openafs/server/CellServDB
|
|
|
|
|
|
|
|
csdb=/etc/afs/CellServDB
|
|
|
|
CURdb=/var/backups/$(_fnchg $csdb).current
|
|
|
|
BACKdb=/var/backups/$(_fnchg $csdb).backup
|
|
|
|
|
|
|
|
initfs
|
|
|
|
backupcsdb
|
|
|
|
writecsdb
|
|
|
|
writethiscell
|
2008-07-20 23:13:01 -04:00
|
|
|
if [ "$(pgrep bosserver)" ]
|
2006-01-30 21:49:24 -05:00
|
|
|
then
|
2008-07-20 23:13:01 -04:00
|
|
|
pkill bosserver
|
2006-01-30 21:49:24 -05:00
|
|
|
fi
|
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
log authenticating $p@$R
|
|
|
|
retry kinit $p@$R
|
2008-10-20 22:57:51 -04:00
|
|
|
hostkeytab
|
|
|
|
|
|
|
|
# only 1st afs server
|
|
|
|
if [ first -eq 1 ]; then
|
|
|
|
createafskey
|
|
|
|
fi
|
|
|
|
saveafskey
|
|
|
|
|
|
|
|
# only 1st afs server
|
|
|
|
if [ first -eq 1 ]; then
|
|
|
|
addexampleuser
|
|
|
|
fi
|
|
|
|
disablearla
|
2008-07-20 23:13:01 -04:00
|
|
|
|
2008-10-08 11:45:55 -04:00
|
|
|
log starting unauthenticated bosserver
|
|
|
|
retry bosserver -log -syslog -noauth
|
2008-10-20 22:57:51 -04:00
|
|
|
retry bos setcellname localhost $c -noauth
|
|
|
|
|
|
|
|
log creating server entries with bos
|
|
|
|
i=0
|
|
|
|
fs=0
|
|
|
|
while [ i -lt ${#sservers[*]} ]; do
|
|
|
|
srv="${sservers[$i]}"
|
|
|
|
case "$srv" in
|
|
|
|
fs)
|
|
|
|
fs=1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
retry bos create localhost $srv simple $afsp/$srv -cell $c -noauth
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
let i=i+1
|
|
|
|
done
|
|
|
|
|
|
|
|
# only 1st afs server
|
|
|
|
if [ first -eq 1 ]; then
|
|
|
|
setuppts
|
|
|
|
fi
|
|
|
|
retry bos adduser localhost $pA -cell $c -noauth
|
|
|
|
retry bos shutdown localhost -cell $c -noauth -wait
|
2008-07-20 23:13:01 -04:00
|
|
|
|
|
|
|
log getting status of bos config
|
2008-10-20 22:57:51 -04:00
|
|
|
retry bos status localhost -noauth -cell $c -long
|
|
|
|
fs=1
|
|
|
|
if [ fs -eq 1 ]; then
|
|
|
|
log creating fs entry with bos
|
|
|
|
retry bos create localhost fs fs $afsp/{fileserver,volserver,salvager} -cell $c -noauth
|
|
|
|
retry bos restart localhost -all -cell $c -noauth
|
|
|
|
fi
|
2008-07-20 23:13:01 -04:00
|
|
|
log getting partition list
|
2008-10-20 22:57:51 -04:00
|
|
|
retry vos listpart localhost -noauth
|
|
|
|
|
|
|
|
# only 1st afs server
|
|
|
|
if [ first -eq 1 ]; then
|
|
|
|
initcellp1
|
|
|
|
fi
|
|
|
|
|
|
|
|
retry bos shutdown localhost -cell $c -noauth -wait
|
2008-10-08 11:45:55 -04:00
|
|
|
pkill -HUP bosserver
|
|
|
|
sleep 3
|
|
|
|
# don't put back CellServDB
|
|
|
|
trap 'rm -rf $DIR; exit 1' 0 1 2 3 13 15
|
|
|
|
|
|
|
|
log starting authenticated bosserver
|
|
|
|
retry bosserver -log -syslog
|
2008-10-20 22:57:51 -04:00
|
|
|
retry bos restart localhost -all -cell $c -localauth
|
2008-10-08 11:45:55 -04:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
|
|
|
|
log starting afs client
|
2008-10-20 22:57:51 -04:00
|
|
|
retry mkdir -p /afs
|
2009-09-07 00:34:54 -04:00
|
|
|
[ "$(mount | egrep "^/afs")" ] || mount -t nnpfs /dev/nnpfs0 /afs
|
2008-10-08 11:45:55 -04:00
|
|
|
retry /usr/libexec/afsd -z --log=/var/log/afsd.log
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
log authenticating $A
|
2008-10-08 11:45:55 -04:00
|
|
|
retry kinit $A
|
|
|
|
retry pts listentries
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
# do this on reboot
|
2008-10-20 22:57:51 -04:00
|
|
|
grep "^afs=YES" /etc/rc.conf > /dev/null 2>&1 || \
|
2008-10-12 13:31:17 -04:00
|
|
|
grep "^afs=YES" /etc/rc.conf.local > /dev/null 2>&1 || \
|
|
|
|
echo afs=YES >> /etc/rc.conf.local
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
retry ls /afs
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-10-20 22:57:51 -04:00
|
|
|
# only 1st afs server
|
|
|
|
if [ first -eq 1 ]; then
|
|
|
|
initcellp2
|
|
|
|
fi
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-07-20 23:13:01 -04:00
|
|
|
log adding replication sites for root.afs, root.cell
|
2008-10-08 11:45:55 -04:00
|
|
|
retry vos addsite $h /vicepa root.afs
|
|
|
|
retry vos addsite $h /vicepa root.cell
|
2006-01-30 21:49:24 -05:00
|
|
|
|
2008-10-20 22:57:51 -04:00
|
|
|
log release of replicated volumes
|
2008-10-08 11:45:55 -04:00
|
|
|
retry vos release root.afs
|
|
|
|
retry vos release root.cell
|
|
|
|
|
2009-03-26 17:28:47 -04:00
|
|
|
log restart afsd so it sees RO replicated volumes
|
|
|
|
pkill afsd
|
|
|
|
retry /usr/libexec/afsd -z --log=/var/log/afsd.log
|
|
|
|
|
2008-10-12 13:31:17 -04:00
|
|
|
addchg /etc/kerberosV/krb5.conf
|
|
|
|
addchg "+/etc/kerberosV/krb5.keytab"
|
|
|
|
addchg /etc/afs/{CellServDB,ThisCell,afsd.conf}
|
|
|
|
addchg ${SYSCONFDIR}/openafs/{BosConfig,server/{CellServDB,ThisCell,UserList,krb.conf}}
|
|
|
|
addchg "+${SYSCONFDIR}/openafs/server/KeyFile"
|
2008-10-08 11:45:55 -04:00
|
|
|
addchg /var/openafs/NetInfo
|
|
|
|
addchg "+/var/openafs/sysid"
|
|
|
|
addchg "+/var/openafs/db/bdb.DB0"
|
|
|
|
addchg "+/var/openafs/db/bdb.DBSYS1"
|
|
|
|
addchg "+/var/openafs/db/prdb.DB0"
|
|
|
|
addchg "+/var/openafs/db/prdb.DBSYS1"
|
|
|
|
addchg "+/var/openafs/db/vldb.DB0"
|
|
|
|
addchg "+/var/openafs/db/vldb.DBSYS1"
|
|
|
|
|
|
|
|
# Pat on the back.
|
|
|
|
cat <<__EOT
|
|
|
|
|
|
|
|
CONGRATULATIONS! Your OpenAFS server setup has been successfully completed,
|
|
|
|
and is now running.
|
2009-03-28 12:11:48 -04:00
|
|
|
Please read ${TRUEPREFIX}/share/openafs/README.OpenBSD for further details;
|
2008-10-08 11:45:55 -04:00
|
|
|
be sure to note the startup and shutdown script examples.
|
|
|
|
__EOT
|