#!/bin/bash

#we do not let user to delete config files

if [ -d $1 ]; then
    echo "It is an directory, not an file"
    exit 0
fi

if [ ! -e $1 ]; then
   echo "No such file exists"
   exit 0
fi


ab_path=`expr index "$1" "/"`

file_name=$1

if [ $ab_path -ne 1 ];then
     ralative_path=`dirname $1`
     file=`basename $1`
     fullpath=$(cd $ralative_path;  pwd)
     if [ "${fullpath}" != "/" ]; then
         file_name=${fullpath}/${file}
     else
        file_name=/${file}
     fi
fi

check_file_name=`expr match "$file_name" "/pica/config/pica.conf"`
if [ $check_file_name -eq 0 ]; then
    sudo rm $1
else
    echo "Please do not delete config files!"
fi


