File: editor

package info (click to toggle)
xen-tools 4.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 1,476 kB
  • sloc: perl: 4,942; sh: 1,690; makefile: 268
file content (92 lines) | stat: -rwxr-xr-x 1,646 bytes parent folder | download | duplicates (6)
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
#!/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 prefix for finding scripts from.
#
prefix=$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 prefix
   #
   file=${i#$source}

   #
   #  Strip the .sed suffix
   #
   file=$(echo "$file" | sed -e 's/\.sed$//')

   #
   #  Does the file exist in the new install?
   #
   if [ -e "${prefix}/${file}" ]; then

       #
       #  Log it.
       #
       logMessage "Running script $i - against ${prefix}/${file}"

       #
       #  Invoke it.
       #
       sed -i~ -f $i "${prefix}/${file}"
   fi
done


#
#  Log our finish
#
logMessage Script $0 finished