freebsd-ports/japanese/Wnn6/pkg-install

112 lines
3.2 KiB
Text
Raw Normal View History

#!/bin/sh
# an installation script for Wnn6
ask() {
local question default answer
question=$1
default=$2
if [ -z "${PACKAGE_BUILDING}" ]; then
read -p "${question} (y/n) [${default}]? " answer
fi
if [ x${answer} = x ]; then
answer=${default}
fi
echo ${answer}
}
yesno() {
local dflt question answer
question=$1
dflt=$2
while :; do
answer=$(ask "${question}" "${dflt}")
case "${answer}" in
[Yy]*) return 0;;
[Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
case $2 in
PRE-INSTALL)
## Hack /etc/services ##
FILE="/etc/services"
# check
OK=no
HAS_WNN6=no
COUNT=1
for i in `grep wnn6 $FILE `; do
if [ $COUNT = 1 ] && [ X"$i" = X"wnn6" ]; then
HAS_WNN6=yes
elif [ $COUNT = 2 ] && [ $HAS_WNN6 = yes ] && \
[ X"$i" = X"22273/tcp" ]; then
OK=yes
break
fi
COUNT=`expr ${COUNT} + 1`
done
# add an entry for wnn6 to /etc/services
if [ $OK = no ]; then
echo "This system has no entry for Wnn6 in ${FILE}"
if yesno "Would you like to add it automatically?" y; then
mv ${FILE} ${FILE}.bak
(grep -v wnn6 ${FILE}.bak ; \
echo "wnn6 22273/tcp # Wnn6") >> ${FILE}
rm ${FILE}.bak
else
echo "Please add 'wnn6 22273/tcp' into ${FILE}, and try again."
exit 1
fi
fi
POST-INSTALL)
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cd /usr/local/bin; rm -f Wnn6; ln -s ${PKG_PREFIX}/OMRONWnn6/Wnn6fbsd Wnn6
cd /usr/local/lib; rm -f wnn6; ln -s ${PKG_PREFIX}/OMRONWnn6/wnn6fbsd wnn6
if [ X${PKG_PREFIX} != X"/usr/local" ]; then
echo
echo "Warning!!"
echo "We made symbolic links from \"/usr/local/bin/Wnn6\" to \"${PKG_PREFIX}/OMRONWnn6/Wnn6fbsd\""
echo "and from \"/usr/local/lib/wnn6\" to \"${PKG_PREFIX}/OMRONWnn6/wnn6fbsd\""
fi
cd ${PKG_PREFIX}/OMRONWnn6/wnn6fbsd/ja_JP; rm -f dic; ln -s ../../wnn6dic dic
chown -R wnn ${PKG_PREFIX}/OMRONWnn6
chmod 4555 ${PKG_PREFIX}/OMRONWnn6/Wnn6fbsd/jserver
chmod 4555 ${PKG_PREFIX}/OMRONWnn6/Wnn6fbsd/wnnds
## create a startup script ##
wnnserver=/usr/local/bin/Wnn6/jserver
wnnname=Wnn6
startup_script=${PKG_PREFIX}/etc/rc.d/${wnnname}.sh
if [ ! -f ${startup_script} ]; then
echo "Installing ${startup_script} startup file."
echo '#!/bin/sh' > ${startup_script};
echo "wnn=${wnnserver}" >> ${startup_script};
echo 'case $1 in' >> ${startup_script};
echo 'start)' >> ${startup_script};
echo ' if [ -f $wnn ]; then' >> ${startup_script};
echo " echo -n ' ${wnnname}'" >> ${startup_script};
echo ' $wnn' >> ${startup_script};
echo " fi" >> ${startup_script};
echo ' ;;' >> ${startup_script};
echo 'stop)' >> ${startup_script};
echo ' killall $wnn' >> ${startup_script};
echo " echo -n ' ${wnnname}'" >> ${startup_script};
echo ' ;;' >> ${startup_script};
echo '*)' >> ${startup_script};
echo ' echo "Usage: `basename $0` {start|stop}" >&2' >> ${startup_script};
echo ' ;;' >> ${startup_script};
echo 'esac' >> ${startup_script};
echo 'exit 0' >> ${startup_script};
chmod 755 ${startup_script}
chown bin:bin ${startup_script}
fi
;;
esac