#! /bin/sh

if test -f /usr/share/magic; then
  MAGIC="/usr/share/magic"
elif test -f /usr/local/share/magic; then
  MAGIC="/usr/local/share/magic"
elif test -f /etc/magic; then
  MAGIC="/etc/magic"
else
  echo "Cannot find magic file to patch."
  exit
fi

if grep "^[^#].*belong" $MAGIC 2>/dev/null >/dev/null; then
  LONG=belong
  SHORT=beshort
else
  LONG=long
  SHORT=short
fi

if grep DACT $MAGIC 2>/dev/null >/dev/null; then
	exit
else
  cat >> $MAGIC << EOF

#------------------------------------------------------------------------------
# dact:  file(1) magic for DACT compressed files
#
0	$LONG		0x444354C3	DACT compressed data
>4	byte		>-1		(version %i.
>5	byte		>-1		\b%i.
>6	byte		>-1		\b%i)
>7	$LONG		>0		\b, original size: %i bytes
>15	$LONG		>30		\b, block size: %i bytes
EOF
fi
