summaryrefslogtreecommitdiff
path: root/build/mac/uninstall-pcp.in
blob: 8a1cec53e765607e9e115db5c27777a73491db82 (plain)
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
#!/bin/sh
#
# Copyright (c) 2003-2004 Silicon Graphics, Inc.  All Rights Reserved.
# 
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

if [ $USER != "root" ]
then
    echo "Only the root user can uninstall PCP, try the following command instead:"
    echo "    sudo $0"
    exit 1
fi

@echo@ @echo_n@ "Are you sure you want to uninstall PCP? [y/n] @echo_c@"
read answer

if [ "X$answer" != "Xy" -a "X$answer" != "XY" ]
then
    echo "Uninstall cancelled."
    exit 1
fi

here=`pwd`
BINADM_DIR="@pcp_binadm_dir@"

if [ "$here" = "$BINADM_DIR" -o "$here" = `dirname $BINADM_DIR` ]
then
    echo "Do not run $0 from $BINADM_DIR, uninstall cancelled."
    exit 1
fi

echo "Stopping PCP..."
/Library/StartupItems/pcp/pmcd stop
sleep 5

if [ -x $BINADM_DIR/install-pcp -a -r $BINADM_DIR/idb ]
then
    echo "Removing Receipts"
    if [ -d /Library/Receipts/pcp-*.pkg ]; then
	rm -rf /Library/Receipts/pcp-*.pkg
    fi
    echo "Uninstall in background to remove all running scripts"
    # Copy to /tmp since inst will remove itself and this script
    cp $BINADMR_DIR/install-pcp $BINDAMD_DIR/idb /tmp
    # create tidy up script
    echo '#!/bin/sh' > /tmp/_pcp_tidy.sh
    echo '/tmp/install-pcp -v -r -l /var/log/pcp_inst.log /tmp/idb && /bin/rm -rf /Library/Receipts/pcp-*' >> /tmp/_pcp_tidy.sh
    echo '/bin/rm -f /tmp/install-pcp /tmp/idb /tmp/_pcp_tidy.sh' >> /tmp/_pcp_tidy.sh
    echo 'echo Done' >> /tmp/_pcp_tidy.sh
    chmod u+x /tmp/_pcp_tidy.sh
    # Run remove, overriding this shell
    exec /tmp/_pcp_tidy.sh
else
    echo "Unable to find $BINADM_DIR/install-pcp. Remove failed"
    exit 1
fi