#!/bin/sh
#
# Create configuration file for nightview-daemon
#
# Common script for nightviewd daemon and telescoped.
#
# $Id: nightview-conf,v 1.10 2008-08-15 20:42:30 hroch Exp $
#


SYSTEMRC=/usr/local/etc/nightview.conf

echo "NIGHTVIEW DAEMON config creator."
echo

if [ -z "$*" ]; then
   echo Specify a parameter as a name for configuration spript. For example run
   echo
   echo "  $0 /usr/local/etc/nightview.conf"
   echo
   exit 0
else
   SYSTEMRC=$1
fi

set -C noclobber

if [ -f "$SYSTEMRC" ] 
  then
    echo "You have the nightviewd or telescoped configured yet. The configuration file"
    echo "      $SYSTEMRC"
    echo "will not be created again. But, you can easy customize it"
    echo "by the simple editing in your prefered editor."
    exit 0
fi

DN=$(dirname $SYSTEMRC)
if [ -n "$DN" -a ! -d "$DN" ]; then
   mkdir -p $DN
fi

cat > $SYSTEMRC << EOF
# Config file for Nightview daemon.
# 

# ---------------------------------------------------------------------------
# A camera is connected to Device.
#
# Select one from this:
#
#   for parallel device:
#   port      device      
#    1        lp0, 0x378, LPT1
#    2        lp1, 0x278, LPT1   
#    3        lp2, 0x3bc, LPT3
#
#   for USB device:
# any USB     USB, usb    
#    1        USB1, usb0 (default)
#    2        USB2, usb1
#    2        USB3, usb2
#    2        USB4, usb3
#
#   for ethernet device use its ip address:
#  any eth    192.168.0.1
#

Device = usb0

#
#----------------------------------------------------------------------------

#
#---------------------------------------------------------------------------
# Site options
#
# Specify your site coordinates. This values will be used without any 
# changes in header of the created FITS file. 
#

# Name of site 
Site = "Monte Boo"

# longitude (+east, -west) in degrees
Longitude = 16.58395

# latitude (+north, -south) in degrees
Latitude = 49.204128

# altitude (+over sea, -under sea) in meters
Altitude = 304.0

# Identifier of the telescope
Telescope = "0.62m, 1:4.6"

# Focal lenght of telescope in meters
Focus = 2.73

#
#--------------------------------------------------------------------------
# Filters definition
#
#  Specify string(s) for your filter(s)
#

# Is a filter wheel connected? (true=connected, false=not connected)
Filter wheel = true

# position in carousel (filter wheel)
Filter 1 = "B"
Filter 2 = "V"
Filter 3 = "R"
Filter 4 = "I"
Filter 5 = "clear"

#
#--------------------------------------------------------------------------
#

# Authentication key for nighthttpd
#
# f@debian:/tmp> python
# import base64
# base64.b64encode('kokot:neco')

AuthKey = a29rb3Q6bmVjbw==

# 
# http://en.wikipedia.org/wiki/Basic_authentication_scheme
#

EOF

if [ $? -eq 0 ]; then
  echo "The nightviewd config file was been created as"
  echo "$SYSTEMRC"
  echo "You can easy customize it by the editing in your prefered editor."
  #echo
  #echo "A new config file has been sucessfully created."
  #echo "Bye"
fi

exit 0
