"target" is also the name used in the debian installer for the installation target while "prefix" is too ambiguous.
93 lines
1.6 KiB
Bash
Executable File
93 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Role-script for the generalised editing of files for guests.
|
|
#
|
|
# This script works via a skeleton directory containing small
|
|
# .sed files which will contain edits to be applied to an arbitrary
|
|
# tree of files upon the new domU.
|
|
#
|
|
# For example if we have the following sed file:
|
|
#
|
|
# /etc/xen-tools/sed.d/etc/ssh/sshd_config.sed
|
|
#
|
|
# this will be applied to /etc/ssh/sshd_config upon the new guest
|
|
# *if* it exists. If the file encoded in the name doesn't exist then
|
|
# it will be ignored.
|
|
#
|
|
# Steve
|
|
# --
|
|
#
|
|
|
|
|
|
|
|
#
|
|
# Our installation directory + our target for finding scripts from.
|
|
#
|
|
TARGET=$1
|
|
source=/etc/xen-tools/sed.d/
|
|
|
|
|
|
#
|
|
# Source our common functions - this will let us install a Debian package.
|
|
#
|
|
if [ -e /usr/share/xen-tools/common.sh ]; then
|
|
. /usr/share/xen-tools/common.sh
|
|
else
|
|
echo "Installation problem"
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
# Log our start
|
|
#
|
|
logMessage Script $0 starting
|
|
|
|
|
|
#
|
|
# Make sure source directory exists.
|
|
#
|
|
if [ ! -d "${source}" ]; then
|
|
logMessage "Source directory ${source} not found"
|
|
exit
|
|
fi
|
|
|
|
|
|
#
|
|
# Now find files which exist.
|
|
#
|
|
for i in `find ${source} -name '*.sed' -print`; do
|
|
|
|
#
|
|
# Get the name of the file, minus the source target
|
|
#
|
|
file=${i#$source}
|
|
|
|
#
|
|
# Strip the .sed suffix
|
|
#
|
|
file=$(echo "$file" | sed -e 's/\.sed$//')
|
|
|
|
#
|
|
# Does the file exist in the new install?
|
|
#
|
|
if [ -e "${TARGET}/${file}" ]; then
|
|
|
|
#
|
|
# Log it.
|
|
#
|
|
logMessage "Running script $i - against ${TARGET}/${file}"
|
|
|
|
#
|
|
# Invoke it.
|
|
#
|
|
sed -i~ -f $i "${TARGET}/${file}"
|
|
fi
|
|
done
|
|
|
|
|
|
#
|
|
# Log our finish
|
|
#
|
|
logMessage Script $0 finished
|