#!/bin/bash
# Wrapper Script for the collection of scripts known as Bike Maintain
# Copyright Ben Tasker 2008
# Released under the GNU GPL
# You should have a copy of the license included if not please contact btasker@gmail.com


# Version 0.3b

#loads the most commonly used variables
source .config
source .version

# Functions Begin


# Guess what the next function does!
Goodbye ()

databasebackup ()

vehicleinfo ()

casefileapp ()

casefiledel ()

firstrun ()

blankgenerate ()



#Functions End


# Script Begins
source ./.firstrun

# Check to see if this is the first time we have run BikeMaintain

if [ "$FIRSTRUN" == "Y" ]
then
firstrun
fi

# No, it's not, lets carry on to the;

# Main Menu

echo "Welcome to Bike Maintain $VERSION"
echo ""
echo "Please select from an option below"
echo ""
echo "1 Update Log"
echo "2 Generate Report"
echo "3 Import BikeMaintain File"
echo "4 Create a case file"
echo "5 Add links to a case file"
echo "6 Remove links from a case file"
echo "7 Edit Vehicle Info"
echo "8 Backup Database"
echo "9 Generate Blank Database"
echo "10 Export Full Database"
echo ""
read mainmenu
echo ""
if [ "$mainmenu" == "1" ]
then
echo "Now passing control to the script"
./bikelog.sh
fi
if [ "$mainmenu" == "2" ]
then
echo "Passing control"
./reportgen
fi
if [ "$mainmenu" == "3" ]
then
loadopts="import"
export loadopts
./bikelog.sh
fi
if [ "$mainmenu" == "4" ]
then
loadopts="case"
export loadopts
./bikelog.sh
fi
if [ "$mainmenu" == "5" ]
then
echo "Please Wait"
casefileapp
fi
if [ "$mainmenu" == "6" ]
then
casefiledel
fi
if [ "$mainmenu" == "7" ]
then
echo "Passing control"
vehicleinfo
fi
if [ "$mainmenu" == "8" ]
then
echo "Passing control"
databasebackup
fi
if [ "$mainmenu" == "9" ]
then
blankgenerate
fi
if [ "$mainmenu" == "10" ]
then
dbexport
fi

#Don't recognise input? Exit for now. Will write error handler later

exit