1999-08-19 10:50:30 +00:00
|
|
|
#!/bin/sh -
|
|
|
|
# an installation script for ndtpd
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
ask() {
|
|
|
|
local question default answer
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
question=$1
|
|
|
|
default=$2
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
if [ -z "${PACKAGE_BUILDING}" ]; then
|
|
|
|
read -p "${question} (y/n) [${default}]? " answer
|
|
|
|
[ "${answer}" ] && default=${answer}
|
|
|
|
fi
|
|
|
|
echo ${default}
|
|
|
|
}
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
yesno() {
|
|
|
|
local question default
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
question=$1
|
|
|
|
default=$2
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
while :; do
|
|
|
|
case `ask "${question}" ${default}` in
|
|
|
|
[Yy]*) return 0;;
|
|
|
|
[Nn]*) return 1;;
|
1998-04-21 15:10:50 +00:00
|
|
|
esac
|
1999-08-19 10:50:30 +00:00
|
|
|
echo "Please answer yes or no."
|
1998-04-21 15:10:50 +00:00
|
|
|
done
|
1999-08-19 10:50:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[ "$2" = POST-INSTALL ] || exit 0
|
1998-04-21 15:10:50 +00:00
|
|
|
|
|
|
|
#
|
1999-08-19 10:50:30 +00:00
|
|
|
# Add an entry for `ndtp' to /etc/services.
|
1998-04-21 15:10:50 +00:00
|
|
|
#
|
1999-08-19 10:50:30 +00:00
|
|
|
file=/etc/services
|
|
|
|
back=${file}.bak
|
|
|
|
name=ndtp
|
|
|
|
port=2010/tcp
|
|
|
|
comment="Network Dictionary Transfer Protocol"
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
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}."
|
1998-04-21 15:10:50 +00:00
|
|
|
|
1999-08-19 10:50:30 +00:00
|
|
|
if sed 's/#.*//' ${file} | grep -qw ${port}; then
|
|
|
|
sed 's,^\([^#]*[ ]'${port}'\),\1 '${name}, ${back} > ${file}
|
|
|
|
else
|
|
|
|
echo "${name} ${port} #${comment}" >> ${file}
|
|
|
|
fi
|
|
|
|
fi
|
1998-04-21 15:10:50 +00:00
|
|
|
fi
|
1999-08-19 10:50:30 +00:00
|
|
|
echo "************************************************************************"
|
1998-04-21 15:10:50 +00:00
|
|
|
|
|
|
|
exit 0
|