~ubuntu-branches/ubuntu/natty/dpsyco/natty

« back to all changes in this revision

Viewing changes to lib/src/change.func

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2002-04-08 20:41:30 UTC
  • Revision ID: james.westby@ubuntu.com-20020408204130-aumsesgfm39nwyb0
Tags: 1.0.10
* Added documentation from Machael Boman
  <michael.boman@securecirt.com>, closes: #128120.
* Fixed purge problem, moved deconfiguring to prerm from postinst,
  closes: #141732.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# DocumentId:   $Id: change.func,v 1.6 2001/09/07 10:02:45 ola Exp $
 
2
# Author:       $Author: ola $
 
3
# Date:         $Date: 2001/09/07 10:02:45 $
 
4
# Summary:
 
5
#       A change function to update a file using sed.
 
6
 
 
7
###############################################################################
 
8
# Name:         changefile
 
9
# Description:  Change a file using sed.
 
10
# Arguments:    The sed script to use.
 
11
#               File to change.
 
12
###############################################################################
 
13
changefile() {
 
14
    TMPSEDSC="$1"
 
15
    TMPFILE="$2"
 
16
    if [ -f "$TMPFILE" ] ; then
 
17
        cp -a $TMPFILE "$TMPFILE.tmp"
 
18
        cat "$TMPFILE.tmp" | sed -e "$TMPSEDSC" > $TMPFILE
 
19
        if [ -s $TMPFILE ] ; then
 
20
            rm -f "$TMPFILE.tmp"
 
21
        else
 
22
            if [ ! -s $TMPFILE.tmp ] ; then
 
23
                echo "The file $TMPFILE was cleared probably because of a error in the"
 
24
                echo "sed script. Restoring from backup."
 
25
                mv "$TMPFILE.tmp" $TMPFILE
 
26
            fi
 
27
        fi
 
28
    else
 
29
        echo "File $TMPFILE not found. So it is not possible to change it."
 
30
    fi
 
31
}