summaryrefslogtreecommitdiffstats
path: root/os_darwin/pkg/root/usr/local/sbin/smart-pkg-uninstall
blob: 72bb3fa5ea73e35400bf24649381ffa4605bf17e (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
#!/bin/sh

echo "Smartmontools package uninstaller:"

# check if we are running with root uid
if [[ $EUID -ne 0 ]]; then
   echo "   Error: this script must be run as root"
   exit 1
fi

# check if package is installed
pkgutil --info com.smartmontools.pkg > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
  echo "   Error: smartmontools package is not installed"
  exit 1
fi

# smartmontools pkg could be installed only on system volume, so this should be safe
cd /

echo "  - removing files"
for str in `pkgutil --files com.smartmontools.pkg`
do
   if [ -f "$str" ]
   then
      rm -f "$str"
   fi
done
echo "  - removing empty directories"
for str in `pkgutil --files com.smartmontools.pkg`
do
   if [ -d "$str" ]
   then
      rmdir -p "$str" 2>/dev/null
   fi
done

echo "  - removing package system entry"
pkgutil --forget com.smartmontools.pkg
echo "Done, smartmontolls package removed"