/usr/lib/fai/fai-divert is in fai-client 3.4.8ubuntu5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #! /bin/bash
# $Id$
#*********************************************************************
#
# fai-divert -- add or remove a diversion for fai
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2002-2007 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# A copy of the GNU General Public License is available as
# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
# can also obtain it by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#*********************************************************************
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mkdivert() {
# make a diversion of a file
[ "$debug" ] || local divertquiet=--quiet
$ROOTCMD dpkg-divert $divertquiet --package fai --rename --add $1 &&
cat > $FAI_ROOT/$1 <<-EOF
#! /bin/sh
# diversion of $1 created by FAI
exit 0
EOF
chmod a+rx $FAI_ROOT/$1
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
adddivert() {
# add an executable to the list of diversions
local item
for item in "$@"; do
mkdivert $item
done
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rmdivert() {
# remove diversion
[ "$debug" ] || local divertquiet=--quiet
rm -f $FAI_ROOT/$1
$ROOTCMD dpkg-divert $divertquiet --package fai --rename --remove $1
# when a diversion was made before the file exists
[ -f $FAI_ROOT/$1.distrib.dpkg-new ] && mv $FAI_ROOT/$1.distrib.dpkg-new $FAI_ROOT/$1
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rmalldivert() {
# remove all diversions made by fai
local item
for item in $($ROOTCMD dpkg-divert --list fai | awk '{ print $3 }'); do
rmdivert $item
done
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
usage() {
cat <<EOF
fai-divert, add or remove a diversion for fai.
Copyright (C) 2002-2007 by Thomas Lange
Usage: fai-divert [OPTION] ... FILE
-a FILE ... Replace each file by a dummy script.
-R Remove all diversion made by fai.
-r FILE Remove a diversion.
-v Be verbose.
Report bugs to <lange@informatik.uni-koeln.de>.
EOF
exit 0
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ "$1" ] || usage
# do not execute if command is not available
[ -f $FAI_ROOT/usr/sbin/dpkg-divert ] || {
echo "$FAI_ROOT/usr/sbin/dpkg-divert not available. Skipping."
exit 1
}
while getopts arRhv opt ; do
case "$opt" in
v) verbose=1 ;;
R) rmalldivert ;;
r) shift ; rmdivert $1 ;;
a) shift ; adddivert $@ ;;
h) usage ;;
esac
done
|