~ubuntu-branches/ubuntu/natty/wicd/natty-security

1 by David Paleino
Import upstream version 1.5.2
1
#!/bin/bash
2
3
# Copyright 2008 Robby Workman <rworkman@slackware.com>, Northport, AL, USA
4
# Copyright 2008 Alan Hicks <alan@slackware.com>, Lizella, GA, USA
5
# All rights reserved.
6
#
7
# Redistribution and use of this script, with or without modification, is
8
# permitted provided that the following conditions are met:
9
#
10
# 1. Redistributions of this script must retain the above copyright
11
#    notice, this list of conditions and the following disclaimer.
12
#
13
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
14
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
21
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24
CWD=$(pwd)
25
26
INSTALL_LOG=${INSTALL_LOG:-"$CWD/install.log"}
27
UNINSTALL_LOG=${UNINSTALL_LOG:-"$CWD/uninstall.log"}
28
29
DIR_LIST=$(mktemp)
30
FILE_LIST=$(mktemp)
31
32
trap "do_cleanup ; exit 0" EXIT;
33
trap "do_cleanup ; exit 1" SIGINT SIGTERM;
34
35
error_nolog() {
36
  echo "There does not appear to be an installation log present, most"
37
  echo "likely because you did not install Wicd from this directory."
38
  do_cleanup
39
  exit 1
40
}
41
42
do_success() {
43
  echo "You have successfully uninstalled Wicd."
44
  echo "Configuration files added after installation were NOT removed."
45
  exit 0
46
}
47
   
48
get_contents() {
49
  while read LINE ; do
50
    if [ -d "$LINE" ]; then
51
      # $LINE is a directory
52
      echo "$LINE" >> "$DIR_LIST"
53
    else 
54
      # $LINE is a file or symlink or the like
55
      echo "$LINE" >> "$FILE_LIST"
56
    fi
57
    # Now handle parent directories
58
    RECURSE=true
59
    while [ "$RECURSE" = "true" ]; do
60
      LINE="$(dirname $LINE)"
61
      if [ ! "$LINE" = "/" ]; then
62
        echo "$LINE" >> "$DIR_LIST"
63
      else
64
        RECURSE=false
65
      fi
66
    done
67
  done < $INSTALL_LOG
68
}
69
70
do_uninstall() {
71
  cat $FILE_LIST | xargs rm -f &> $UNINSTALL_LOG
72
  cat $DIR_LIST | sort -ur | xargs rmdir &> $UNINSTALL_LOG
73
}
74
75
do_cleanup() {
76
  rm -f $FILE_LIST $DIR_LIST 2>/dev/null
77
}
78
79
[ -e $INSTALL_LOG ] || error_nolog
80
get_contents
81
do_uninstall
82
do_cleanup
83
do_success
84