#!/bin/bash

cp /etc/lighttpd/lighttpd.conf            /etc/lighttpd/lighttpd.conf.back
cp /etc/lighttpd/conf-enabled/10-cgi.conf /etc/lighttpd/conf-enabled/10-cgi.conf.back

cp /opt/opengnsys/lib/httpd/lighttpd.conf /etc/lighttpd/
cp /opt/opengnsys/lib/httpd/10-cgi.conf   /etc/lighttpd/conf-enabled/

chmod 755 /opt
mkdir -p /usr/lib/cgi-bin
cp /opt/opengnsys/lib/httpd/* /usr/lib/cgi-bin
/etc/init.d/lighttpd start

## dstat fails because /var/lib/pcp/pmns/root does not exist.
## we work around that by starting/stopping pmcd once. When it starts, it creates the missing file.
if [[ ! -f /var/lib/pcp/pmns/root ]]; then
    /etc/init.d/pmcd start &>/dev/null
    /etc/init.d/pmcd stop &>/dev/null
fi
dstat --disk --net > /tmp/bandwidth &

echo "WAITING" >> $OGLOGSESSION
