#!/bin/sh
#
# icecaststart - start the icecast I server
#
# Copyright (C) 2004 Ilja Gerhardt <ilja@so36.de>
#
# This source code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Public License as published 
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This source code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Please refer to the GNU Public License for more details.
#
# You should have received a copy of the GNU Public License along with
# this source code; if not, write to:
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

: ${DIALOG=dialog}
myip=`/sbin/ifconfig | grep inet | awk {'print $2;'} | sed s/.*://`

[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
# LANGUAGE="`getbootparam lang`"

case "$LANGUAGE" in
de|at|ch)
BT="Icecast I"
TI=" Icecast I gestartet "
M1="Der Icecastserver, Version I, wurde gestartet."
P0="Probleme mit Icecast I"
P1="\Zb\Z1Es scheint ein Problem zugeben...\n
Der angegebene Icecastserver auf localhost\n
kann \Zr\Z1NICHT\Zb\Z1 über den Port 8000\n
erreicht werden"
;;
*)
BT="Icecast I"
TI=" Icecast I started "
M1="Icecast server I started"
P0="Problems with Icecast I"
P1="\Zb\Z1There might be a problem:\n
the icecast server cannot be reached on\n
localhost on port 8000"
;;
esac

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin"
export PATH

# LANG et al.
[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n

RXVT=""
[ -n "$DISPLAY" ] && RXVT="rxvt -bg black -fg green -cr red -e"
[ "`id -u`" != "0" ] && $RXVT sudo "$0" "$@"

[ -x /etc/init.d/icecast-server ] && /etc/init.d/icecast-server start

sleep 1

$DIALOG --title "$TI" --backtitle "$BT" --cr-wrap --clear --msgbox "$M1" 0 0

if (! nmap -p8000 localhost | grep open)
then
$DIALOG --colors --title "$P0" --backtitle "$BT" --cr-wrap --clear --msgbox "$P1" 0 0 
exit 0
fi
