#!/bin/sh
VICTIM=/etc/hosts
SERVER=mxr.maemo.org
IPADDRESS=66.33.212.254
LINE="$IPADDRESS $SERVER"
FOUNDDNS=1
export FOUNDDNS SERVER IPADDRESS LINE
if test -d /scratchbox; then
 VICTIM="/scratchbox$VICTIM"
 echo It seems there is a scratchbox environment. 1>&2
 echo trying to change it... 1>&2
fi
if test -f $VICTIM; then
 if test ! -w $VICTIM; then
  echo Can not write to $VICTIM 1>&2
  echo You will need to execute the following manually: 1>&2
  echo "  echo $LINE >> $VICTIM" 1>&2
  exit 1
 fi
 FOUNDDNS=`fgrep $SERVER $VICTIM 2> /dev/null`
 if test ! -z "$FOUNDDNS"; then
  echo There should not be an entry in $VICTIM for $SERVER 1>&2
  echo You will have to remove "$FOUNDDNS" from $VICTIM manually. 1>&2
  exit 1
 fi
else
 echo This package expects to find a file named $VICTIM 1>&2
 echo This file may not exist in scratchbox installs, 1>&2
 echo in which case this package will create it. 1>&2
 echo . 1>&2
 echo If you see this message and are using a real device, 1>&2
 echo please complain to someone and provide logs. 1>&2
fi
umask 0033
echo $LINE >> $VICTIM
exit 0
