1#!/bin/sh
2
3echo "Smartmontools package uninstaller:"
4
5# check if we are running with root uid
6if [[ $EUID -ne 0 ]]; then
7   echo "   Error: this script must be run as root"
8   exit 1
9fi
10
11# check if package is installed
12pkgutil --info com.smartmontools.pkg > /dev/null 2>/dev/null
13if [ $? -ne 0 ]; then
14  echo "   Error: smartmontools package is not installed"
15  exit 1
16fi
17
18# smartmontools pkg could be installed only on system volume, so this should be safe
19cd /
20
21echo "  - removing files"
22for str in `pkgutil --files com.smartmontools.pkg`
23do
24   if [ -f "$str" ]
25   then
26      rm -f "$str"
27   fi
28done
29echo "  - removing empty directories"
30for str in `pkgutil --files com.smartmontools.pkg`
31do
32   if [ -d "$str" ]
33   then
34      rmdir -p "$str" 2>/dev/null
35   fi
36done
37
38echo "  - removing package system entry"
39pkgutil --forget com.smartmontools.pkg
40echo "Done, smartmontolls package removed"
41