aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/e2fsprogs/pkg-install
blob: c31dbadd6bd36d0f0a3813932108fd8f4da490ae (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
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
# $FreeBSD$
#
# ports/sysutils/e2fsprogs/pkg-install - (C) 2006 by Matthias Andree
# redistributable under the modified BSD license
#
# ask() and yesno() based on ports/mail/postfix/pkg-install

PKG_PREFIX=${PKG_PREFIX:=/usr/local}
BATCH=${BATCH:=no}

ask() {
        local question default answer

        question=$1
        default=$2
        if [ -z "${PACKAGE_BUILDING}" -a x${BATCH} = xno ]; then
                read -p "${question} [${default}]? " answer
        fi
        if [ x${answer} = x ]; then
                answer=${default}
        fi
        echo ${answer}
}

yesno() {
        local question default answer

        question=$1
        default=$2
        while :; do
                answer=$(ask "${question}" "${default}")
                case "${answer}" in
                        [Yy][Ee][SsPp]|[Yy])  return 0;;
                        [Nn]|[Nn][Oo])  return 1;;
                esac
                echo "Please answer yes or no."
        done
}

if [ "x$2" = xPOST-INSTALL ] && [ -z "${PACKAGE_BUILDING}" ]; then
    cat <<_EOF

To have your ext2 and ext3 filesystems fsck'ed correctly without explicitly
invoking the fsck_ext2fs utility installed by this port you will need to
create links or copy the fsck utilities installed by this port in/to /sbin, e.g.

ln -f "${PKG_PREFIX}/sbin/fsck_ext2fs" /sbin/ 2>/dev/null \\
  || install -m755 "${PKG_PREFIX}/sbin/fsck_ext2fs" /sbin/
ln -f "${PKG_PREFIX}/sbin/e2fsck" /sbin/e2fsck 2>/dev/null \\
  || install -m755 "${PKG_PREFIX}/sbin/e2fsck" /sbin/e2fsck

IMPORTANT: you also need to repeat the steps above after a port upgrade!

_EOF

    if yesno "Shall I create the links now?" yes ; then
        echo "Installing /sbin/fsck_ext2fs and /sbin/e2fsck."
        ln -f "${PKG_PREFIX}/sbin/fsck_ext2fs" /sbin/ 2>/dev/null \
          || install -m755 "${PKG_PREFIX}/sbin/fsck_ext2fs" /sbin/
        ln -f "${PKG_PREFIX}/sbin/e2fsck" /sbin/e2fsck 2>/dev/null \
          || install -m755 "${PKG_PREFIX}/sbin/e2fsck" /sbin/e2fsck
    fi
fi

if [ "x$2" = xDEINSTALL ] ; then
    cat <<_EOF

If you are deinstalling the e2fsprogs port for good, rather than upgrading it,
remember to remove the files you may have installed into /sbin, example:

rm -f /sbin/fsck_ext2fs /sbin/e2fsck

_EOF

    if yesno "Shall I remove the links now?" yes ; then
        echo "Removing /sbin/fsck_ext2fs and /sbin/e2fsck."
        rm -f /sbin/fsck_ext2fs /sbin/e2fsck
    fi
fi