aboutsummaryrefslogtreecommitdiffstats
path: root/shells/bash3/pkg-deinstall
blob: 9552db126262f915e1530dbf3eb401134ab8deea (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD$
#

BASH="$(echo ${PKG_PREFIX-/usr/local}/bin/bash | /usr/bin/sed -e 's|//|/|g')"
RBASH="$(echo ${PKG_PREFIX-/usr/local}/bin/rbash | /usr/bin/sed -e 's|//|/|g')"
SHELLS="${PKG_DESTDIR-}/etc/shells"

case $2 in
DEINSTALL)
  if grep -qs "^$BASH\$" "$SHELLS"; then
    if [ `id -u` -eq 0 ]; then
      TMPSHELLS=`mktemp -t shells`
      grep -v "^$BASH\$" "$SHELLS" > "$TMPSHELLS"
      cat "$TMPSHELLS" > "$SHELLS"
      rm "$TMPSHELLS"
    else
      echo "Not root, please remove $BASH from $SHELLS manually"
    fi
  fi
  if grep -qs "^$RBASH\$" "$SHELLS"; then
    if [ `id -u` -eq 0 ]; then
      TMPSHELLS=`mktemp -t shells`
      grep -v "^$RBASH\$" "$SHELLS" > "$TMPSHELLS"
      cat "$TMPSHELLS" > "$SHELLS"
      rm "$TMPSHELLS"
    else
      echo "Not root, please remove $RBASH from $SHELLS manually"
    fi
  fi
  ;;
esac