#! /bin/sh

# Remove the old view link (nvi-1.34-14, maybe earlier)
# Don't bother the user with it.
update-alternatives --remove view /usr/bin/nvi >/dev/null

update-alternatives --install /usr/bin/ex ex /usr/bin/nex 30 \
  --slave /usr/share/man/man1/ex.1.gz ex.1.gz /usr/share/man/man1/nex.1.gz
update-alternatives --install /usr/bin/vi vi /usr/bin/nvi 30 \
  --slave /usr/share/man/man1/vi.1.gz vi.1.gz /usr/share/man/man1/nvi.1.gz
update-alternatives --install /usr/bin/view view /usr/bin/nview 30 \
  --slave /usr/share/man/man1/view.1.gz view.1.gz /usr/share/man/man1/nview.1.gz

# These are for the generic editor links

update-alternatives --install /usr/bin/editor editor /usr/bin/nvi 19 \
  --slave /usr/share/man/man1/editor.1.gz editor.1.gz /usr/share/man/man1/nvi.1.gz

#
# Add startup links for recovery script
#

if [ $1 = "configure" ] ; then
    update-rc.d nviboot start 70 S . >/dev/null
    # Clean up old init script
    if [ -f /etc/rc.boot/nvi -a -f /etc/init.d/nviboot ] ; then
	rm /etc/rc.boot/nvi
    fi
fi

#
# /var/tmp/vi.recover needs to be owned by root.
#
if [ $1 = "configure" ] ; then
    [ -d /var/tmp/vi.recover ] || mkdir -p /var/tmp/vi.recover
    chown root:root /var/tmp/vi.recover
    chmod 1777 /var/tmp/vi.recover
fi



exit 0
