#!/bin/ksh -x
##########################################################################################################
##
## Name:            ix_cfgATMega328p
## Created:         September 2015
## Author(s):       Philip Smart
## Description:     A shell script helper program for the dPWR program.
##                  This script is executed by the dPWR program to setup the ATMega328p processor.
##                  Currently there is nothing to set or check but this hook program exists just in case.
## Credits:         
## Copyright:       (c) 2015-2019 Philip Smart <philip.smart@net2net.org>
##
## History:         September 2015   - Initial module written.
##
#########################################################################################################
## This source file 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, either version 3 of the License, or
## (at your option) any later version.
##
## This source file 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.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.
#########################################################################################################

 
trap exit 15

# Get the device to configure.
#
if [ $# != 1 ]; then
    # Error exit
    exit 255
fi
DEVICE=$1
CHECKDEVICE=`echo ${DEVICE} | grep "^\/dev\/tty[a-zA-Z0-9]*$"` 

# Verify the device, cant let a caller change any file.
#
if [ "${CHECKDEVICE}X" = "X" ]; then
    exit 254
fi
 
# Change permissions so the main program can configure it.
#
chown www-data:www-data ${DEVICE}
