#!/usr/bin/env sh

if ! [ -e settings ]; then OUTFILE="settings"; else OUTFILE="settings.new"; fi


cat > $OUTFILE << EOF
# configure the http-retrieval method
# everything other than "lynx" will use the perl-module LWP::Simple
#
#   METHOD=[lynx|.*]
#
# example:
# METHOD=lynx
#
EOF

if [ "$OUTFILE" = "settings.new" ]; then
  cat settings | grep "^METHOD=" >> $OUTFILE
  echo >> $OUTFILE
else echo "METHOD=perl" >> $OUTFILE
  fi

cat >> $OUTFILE << EOF
# Configure some shoutcast streams you want to monitor:
# multiple lines are of course allowed.
#
#   STREAM=<URL>,<description>
#
# example:
# STREAM=http://some.host.org/stats.html,testhost
#
EOF

if [ "$OUTFILE" = "settings.new" ]; then
  cat settings | grep "^STREAM=" >> $OUTFILE
  echo >> $OUTFILE
  fi

echo
echo "Please check the settings file and adapt it to satisfy your needs."
if [ "$OUTFILE" = "settings.new" ]; then
  mkdir -p backup
  NOW=`date +%Y%m%d-%H%M%S`
  mv -f settings backup/settings-$NOW
  mv -f settings.new settings
  echo "a backup of the previous settings has been saved."
  fi
echo

