#!/bin/sh

# Copyright (C) 2004-2014 QVidium Technologies, Inc. All rights reserved.

# If booting, wait until rcS script finishes
tries=0
pidof rcS > /dev/null
while [ $? = 0 -a $tries -lt 60 ] ; do
    sleep 1
    tries=`expr $tries + 1`
    pidof rcS > /dev/null
done

RC_CONF=/flash/etc/rc.conf
tmpfile=/tmp/rc_conf.$$
sed '/WEBADMIN_PORT/d' $RC_CONF > $tmpfile
echo 'WEBADMIN_PORT=80' >> $tmpfile
rm -f $RC_CONF
mv $tmpfile $RC_CONF
sync
/etc/init.d/rc.httpd start

mv $0 $0.resetWebPort.sh