#!/bin/bash
#
# Script to check if firmware or other non-free drivers are required.
#
# Copyright (C) 2007-2008 Kel Modderman <kelvmod@gmail.com>
# Copyright (C) 2008-2015, Stefan Lippers-Hollmann <s.l-h@gmx.de>
# Copyright (C) 2008, Horst Tritremmel <peter_weber69@gmx.at>
# Copyright (C) 2008-2009, Joaquim Boura <x-un-i@sapo.pt>
# Copyright (C) 2009 Niall Walsh <niallwalsh@users.berlios.de>
#                    major modifications to disconnect data from scripts
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 of the
# License.
#
# This program 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.  See the
# GNU General Public License for more details.

function selfhelp () {
	echo "Usage:
  $0 (-y|-i module) (-a) (-h) (-s) (-v) (-x)
    -y          try to install needed firmwares
    -i module   install firmware for given module
    -a          show information on all known modules
    -h          show this help message
    -s          enable short output mode
    -v          increase verbosity (repeat for more)
    -x          prints executed commands and their arguments for debugging
"
}

. /usr/share/aptosid-scripts/fw

#
# check for get_dvb_firmware script
#
[[ -x $(which get_dvb_firmware) ]] && DVB=1 || DVB=0

while getopts ahisvxy opt; do
	case "${opt}" in
		a)
			show_all_cards
			;;
		h)
			selfhelp
			exit
			;;
		i)
			install_driver $2
			;;
		s)
			short="TRUE"
			;;
		v)
			((verbosity++))
			;;
		x)
			set -x
			;;
		y)
			#installable driver
			short="TRUE"
			install_possible="TRUE"
			;;
		*)
			selfhelp
			exit
	esac
done

sys_detect
