#!/usr/bin/sh

#*********************************************************************************************************
#*   __     __               __     ______                __   __                      _______ _______   *
#*  |  |--.|  |.---.-..----.|  |--.|   __ \.---.-..-----.|  |_|  |--..-----..----.    |       |     __|  *
#*  |  _  ||  ||  _  ||  __||    < |    __/|  _  ||     ||   _|     ||  -__||   _|    |   -   |__     |  *
#*  |_____||__||___._||____||__|__||___|   |___._||__|__||____|__|__||_____||__|      |_______|_______|  *
#* http://www.blackpantheros.eu | http://www.blackpanther.hu - kbarcza[]blackpanther.hu * Charles Barcza *
#*************************************************************************************(c)2002-2019********


helptext() {
    echo " == Easy to Use! == "
    echo " - This command: 
    $(basename $0) filename_or_dirname"
    echo " - Will be create a:"
    echo "    'filename_or_dirname.tar.gz' archive"
    exit
}

if [ "$1" = "-h" -o  "$1" = "--help" -o  "$1" = "--segits" ];then 
    helptext
fi

if [ ! -n "$1" ];then 
    helptext
fi

NAME=$(basename $1)
if [ -n "$2" ];then 
for M_NAME in $(echo $@) ;do
 F_NAME=$(basename $M_NAME)
 M_NAME="_To_${F_NAME}"
done
fi


if [ -x "$(which pigz 2>/dev/null)" ];then
echo -n "Working with multi-CPU on : $NAME$M_NAME"
tar -I pigz -cf $NAME$M_NAME.tar.gz $@
elif [ -x "$(which gzip 2>/dev/null)" ];then
echo -n "Working on : $NAME$M_NAME"
tar -czf $NAME$M_NAME.tar.gz $@
else
echo -n "Please install Gzip first for : $NAME$M_NAME"
fi

echo ".tar.gz  DONE!"