aboutsummaryrefslogtreecommitdiffstats
path: root/japanese/ebnetd/pkg-install
blob: d29231b3efb60d0bc2d892f94410eb24e7902266 (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
#!/bin/sh -
# an installation script for ndtpd

ask() {
    local question default answer

    question=$1
    default=$2

    if [ -z "${PACKAGE_BUILDING}" ]; then
    read -p "${question} (y/n) [${default}]? " answer
        [ "${answer}" ] && default=${answer}
    fi
    echo ${default}
}

yesno() {
    local question default

    question=$1
    default=$2

    while :; do
    case `ask "${question}" ${default}` in
        [Yy]*) return 0;;
        [Nn]*) return 1;;
    esac
    echo "Please answer yes or no."
    done
}

[ "$2" = POST-INSTALL ] || exit 0

#
# Add an entry for `ndtp' to /etc/services.
#
file=/etc/services
back=${file}.bak
name=ndtp
port=2010/tcp
comment="Network Dictionary Transfer Protocol"

echo "************************************************************************"
if sed 's/#.*//' ${file} | grep -qw ${name}; then
    echo "This system has already an entry for ${name} in ${file}."
else
    echo "This system has no entry for ${name} in ${file}."
    if yesno "  Would you like to add it automatically?" y; then
    cp -f ${file} ${back}
    echo "    The original file is saved as ${back}."

    if sed 's/#.*//' ${file} | grep -qw ${port}; then
        sed 's,^\([^#]*[    ]'${port}'\),\1 '${name}, ${back} > ${file}
    else
        echo "${name}       ${port}   #${comment}" >> ${file}
    fi
    fi
fi
echo "************************************************************************"

exit 0