File: lib.uninstaller

package info (click to toggle)
shorewall-init 5.2.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 336 kB
  • sloc: sh: 1,665; perl: 168; makefile: 16
file content (105 lines) | stat: -rw-r--r-- 2,313 bytes parent folder | download | duplicates (12)
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
#
# Shorewall 5.2 -- /usr/share/shorewall/lib.installer
#
#     (c) 2017 - Tom Eastep (teastep@shorewall.net)
#     (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
#
#	Complete documentation is available at http://shorewall.net
#
#       This program is part of Shorewall.
#
#	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.
#
#	You should have received a copy of the GNU General Public License
#	along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# The purpose of this library is to hold those functions used by the products uninstaller.
#
#########################################################################################

fatal_error()
{
    echo "   ERROR: $@" >&2
    exit 1
}

split() {
    local ifs
    ifs=$IFS
    IFS=:
    set -- $1
    echo $*
    IFS=$ifs
}

qt()
{
    "$@" >/dev/null 2>&1
}

mywhich() {
    local dir

    for dir in $(split $PATH); do
	if [ -x $dir/$1 ]; then
	    return 0
	fi
    done

    return 2
}

remove_file() # $1 = file to remove
{
    if [ -n "$1" ] ; then
        if [ -f $1 -o -h $1 ] ; then
            rm -f $1
            echo "$1 Removed"
        fi
    fi
}

remove_directory() # $1 = directory to remove
{
    if [ -n "$1" ] ; then
        if [ -d $1 ] ; then
            rm -rf $1
            echo "$1 Removed"
        fi
    fi
}

remove_file_with_wildcard() # $1 = file with wildcard to remove
{
    if [ -n "$1" ] ; then
        for f in $1; do
            if [ -d $f ] ; then
                rm -rf $f
                echo "$f Removed"
            elif [ -f $f -o -h $f ] ; then
                rm -f $f
                echo "$f Removed"
            fi
        done
    fi
}

restore_file() # $1 = file to restore
{
    if [ -f ${1}-shorewall.bkout ]; then
	if (mv -f ${1}-shorewall.bkout $1); then
	    echo
	    echo "$1 restored"
        else
	    exit 1
        fi
    fi
}