| 1 |
#! /bin/sh
|
| 2 |
|
| 3 |
# $Id $
|
| 4 |
#*********************************************************************
|
| 5 |
# postinst -- setup fai
|
| 6 |
#
|
| 7 |
# This script is part of FAI (Fully Automatic Installation)
|
| 8 |
# Copyright (c) 2000 by Thomas Lange, Universitaet zu Koeln
|
| 9 |
#*********************************************************************
|
| 10 |
#
|
| 11 |
# see: dh_installdeb(1)
|
| 12 |
|
| 13 |
set -e
|
| 14 |
|
| 15 |
# summary of how this script can be called:
|
| 16 |
# * <postinst> `configure' <most-recently-configured-version>
|
| 17 |
# * <old-postinst> `abort-upgrade' <new version>
|
| 18 |
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
| 19 |
# <new-version>
|
| 20 |
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
| 21 |
# <failed-install-package> <version> `removing'
|
| 22 |
# <conflicting-package> <version>
|
| 23 |
# for details, see /usr/doc/packaging-manual/
|
| 24 |
#
|
| 25 |
# quoting from the policy:
|
| 26 |
# Any necessary prompting should almost always be confined to the
|
| 27 |
# post-installation script, and should be protected with a conditional
|
| 28 |
# so that unnecessary prompting doesn't happen if a package's
|
| 29 |
# installation fails and the `postinst' is called with `abort-upgrade',
|
| 30 |
# `abort-remove' or `abort-deconfigure'.
|
| 31 |
|
| 32 |
. /etc/fai.conf
|
| 33 |
|
| 34 |
test -f /etc/init.d/nfs-server && nfsserver=nfs-server
|
| 35 |
test -f /etc/init.d/nfs-kernel-server && nfsserver=nfs-kernel-server
|
| 36 |
|
| 37 |
add_export_line() {
|
| 38 |
|
| 39 |
# add a line to /etc/exports
|
| 40 |
|
| 41 |
pattern=$1
|
| 42 |
shift
|
| 43 |
options=$*
|
| 44 |
|
| 45 |
[ -f /etc/exports ] && grep -q "^$pattern[[:space:]]" /etc/exports && return
|
| 46 |
echo "$pattern $options" >> /etc/exports
|
| 47 |
/etc/init.d/$nfsserver start >/dev/null
|
| 48 |
/etc/init.d/$nfsserver reload >/dev/null
|
| 49 |
}
|
| 50 |
|
| 51 |
add_fai_account() {
|
| 52 |
|
| 53 |
if id $LOGUSER 2>/dev/null 1>&2 ; then
|
| 54 |
echo Account \$LOGUSER=$LOGUSER already exists.
|
| 55 |
echo Make sure, that all install clients can
|
| 56 |
echo log into this account without a password
|
| 57 |
else
|
| 58 |
adduser --system --disabled-password --gecos "fai account for log files" $LOGUSER || true
|
| 59 |
gid=`id -g $LOGUSER`
|
| 60 |
perl -pi.bak -e "s#^$LOGUSER:(.+):/bin/false#$LOGUSER:\1:/bin/bash#" /etc/passwd
|
| 61 |
echo "+@faiclients root" > /home/$LOGUSER/.rhosts
|
| 62 |
chown $LOGUSER:$gid /home/$LOGUSER/.rhosts
|
| 63 |
chmod go-rwx /home/$LOGUSER/.rhosts
|
| 64 |
touch /home/$LOGUSER/.account_created_by_fai_package
|
| 65 |
fi
|
| 66 |
}
|
| 67 |
|
| 68 |
case "$1" in
|
| 69 |
configure)
|
| 70 |
|
| 71 |
add_fai_account >/dev/null
|
| 72 |
|
| 73 |
echo Creating FAI nfsroot can take a long time
|
| 74 |
make-fai-nfsroot > /tmp/make-fai-nfsroot.log 2>&1
|
| 75 |
|
| 76 |
add_export_line /usr/local/share/fai "@faiclients(ro)"
|
| 77 |
add_export_line $NFSROOT "@faiclients(ro,no_root_squash)"
|
| 78 |
add_export_line /usr "@faiclients(ro,no_root_squash)"
|
| 79 |
|
| 80 |
if [ ! -d /usr/local/share/fai/fai_config ];then
|
| 81 |
echo "You have no fai configuration. Copy FAI template files with:"
|
| 82 |
echo "cp -pR /usr/share/doc/fai/templates/* /usr/local/share/fai"
|
| 83 |
echo "Then change the configuration files to meet your local needs."
|
| 84 |
fi
|
| 85 |
|
| 86 |
;;
|
| 87 |
|
| 88 |
abort-upgrade|abort-remove|abort-deconfigure)
|
| 89 |
|
| 90 |
;;
|
| 91 |
|
| 92 |
*)
|
| 93 |
echo "postinst called with unknown argument \`$1'" >&2
|
| 94 |
exit 0
|
| 95 |
;;
|
| 96 |
esac
|
| 97 |
|
| 98 |
# dh_installdeb will replace this with shell code automatically
|
| 99 |
# generated by other debhelper scripts.
|
| 100 |
|
| 101 |
#DEBHELPER#
|
| 102 |
|
| 103 |
exit 0
|