#!/bin/sh

set -e

THIS_PACKAGE=rpcbind
# update-rc.d levels
K=06

if [ -f /sbin/runit ]; then
  if [ -d /etc/sv ] && [ ! -d "/etc/sv/rpcbind" ]; then
    cp -r /usr/share/runit/sv/rpcbind /etc/sv/
    echo "Copying to /etc/sv"
  fi
fi

if [ -f /sbin/runit ]; then  
  #remove /etc/init.d/rpcbind if it exists since we are using runit
  if [ -f /etc/init.d/rpcbind ]; then 
      rm /etc/init.d/rpcbind
  fi 
  if [ ! -h "/etc/service/rpcbind" ]; then
    ln -s /etc/sv/rpcbind/ /etc/service/
  fi  
else
  if [ -x /etc/init.d/rpcbind ]; then
    update-rc.d rpcbind defaults $K >/dev/null 2>&1
  fi
fi

if [ "$1" = configure ] ; then
         adduser --force-badname --system --quiet --home /run/rpcbind --no-create-home _rpc
fi

#DEBHELPER#
