mirror of
https://gitlab.com/JKANetwork/jka-toolkit.git
synced 2026-02-27 07:23:48 +01:00
Merge branch 'hotfix' of gitlab.com:JKANetwork/jka-toolkit into hotfix
This commit is contained in:
@@ -209,7 +209,7 @@ case "$1" in
|
|||||||
xbps-reconfigure -f $packages
|
xbps-reconfigure -f $packages
|
||||||
esac;;
|
esac;;
|
||||||
R|-R)
|
R|-R)
|
||||||
printf -- "$(gettext "You are going to remove %s")" "$packages"
|
printf -- "$(gettext "You are going to remove %s\n")" "$packages"
|
||||||
case "$SO" in
|
case "$SO" in
|
||||||
apt)
|
apt)
|
||||||
apt remove $packages;;
|
apt remove $packages;;
|
||||||
|
|||||||
@@ -5,126 +5,49 @@
|
|||||||
#Function decompress(); decompress the file whith the format especified
|
#Function decompress(); decompress the file whith the format especified
|
||||||
|
|
||||||
# gettext initialization
|
# gettext initialization
|
||||||
export TEXTDOMAIN='jkazip'
|
#export TEXTDOMAIN='jkazip'
|
||||||
export TEXTDOMAINDIR='/usr/share/locale'
|
#peroexport TEXTDOMAINDIR='/usr/share/locale'
|
||||||
|
|
||||||
function decompress() {
|
#function sacaFormato, get the file extension to zip or unzip
|
||||||
if [ $files -eq 0 ];then
|
function sacaFormato() {
|
||||||
format=$(ls $2 | cut -f2 -d".")
|
local var=$1
|
||||||
format2=$(ls $2 | cut -f3 -d".")
|
cant=$(echo $var | grep -o "\." | wc -l)
|
||||||
|
fieldPost=$(expr $cant + 1)
|
||||||
|
postform=$(echo $var | cut -f$fieldPost -d".")
|
||||||
|
preform=$(echo $var | cut -f$cant -d".")
|
||||||
|
if [[ $preform = "tar" ]];then
|
||||||
|
formato=$(echo ${preform}.${postform})
|
||||||
else
|
else
|
||||||
format=$(echo $1 | cut -f1 -d".")
|
formato=$postform
|
||||||
format2=$(echo $1 | cut -f2 -d".")
|
|
||||||
fi
|
|
||||||
if [ $format = "tar" ];then
|
|
||||||
if [ -z $format2 ];then
|
|
||||||
tar xvf $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format2 = "gz" ];then
|
|
||||||
tar xvzf $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format2 = "bz2" ];then
|
|
||||||
tar xvjf $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format2 = "xz" ];then
|
|
||||||
tar xvJf $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format2 = "lz" ];then
|
|
||||||
tar cvf $2 --lzip
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
elif [ $format = "tlz" ];then
|
|
||||||
tar cvf $2 --lzip
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "tbz2" ];then
|
|
||||||
tar xvjf $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "tgz" ];then
|
|
||||||
tar xvzf $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "txz" ];then
|
|
||||||
tar xvJf $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "7z" -o $format = "7zip" ];then
|
|
||||||
7z e $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "zip" ];then
|
|
||||||
unzip $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "gz" -o $format = "gzip" ];then
|
|
||||||
gzip -dk $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "bz2" -o $format = "bzip" ];then
|
|
||||||
bzip2 -dk $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $format = "rar" ];then
|
|
||||||
unrar x $2
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been decompressed")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
printf -- "$(gettext "Format %s unknown")" "$format"
|
|
||||||
echo
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
version="1.0.3"
|
#Function msg, print in stdout a final message
|
||||||
|
function msg() {
|
||||||
|
local var=$1
|
||||||
|
printf -- "$(gettext "File/s %s has/have been compressed")" $var
|
||||||
|
}
|
||||||
|
#Function msg2, print in stdout a final message
|
||||||
|
function msg() {
|
||||||
|
local var=$1
|
||||||
|
printf -- "$(gettext "File has been decompressed")" $var
|
||||||
|
}
|
||||||
|
|
||||||
|
version="1.1.0"
|
||||||
if [ -z $1 ];then
|
if [ -z $1 ];then
|
||||||
echo "$(gettext "No option specified, use jkazip -h")"
|
error "$(gettext "No option specified, use jkazip -h")"
|
||||||
elif [ $1 = "-h" ];then
|
elif [ $1 = "-h" ];then
|
||||||
echo "$(gettext " synopsis: jkazip <options> <file or directory>")"
|
echo "$(gettext " synopsis: jkazip <options> <file or directory>")"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$(gettext " -d, decompress file")"
|
echo "$(gettext " -d, decompress file")"
|
||||||
echo "$(gettext " -f <format>, specified format whe decompress, necessary only when the name have more than one point before the file extension")"
|
echo "$(gettext " -c <output file> <input file>, compress file")"
|
||||||
echo "$(gettext " -c <format>, compress file")"
|
|
||||||
echo "$(gettext " -h, show help box and exit")"
|
echo "$(gettext " -h, show help box and exit")"
|
||||||
echo "$(gettext " -v, show version")"
|
echo "$(gettext " -v, show version and exit")"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$(gettext " The order must be \"jkazip -d [-f format] <file or directory>\" or \"jkazip -c <format> <file or directory\"")"
|
echo "$(gettext " The order must be \"jkazip -d <file or directory>\" or \"jkazip -c <format> <file or directory\"")"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$(gettext " Examples")"
|
echo "$(gettext " Examples")"
|
||||||
echo "$(gettext " jkazip -d -f \"tar.gz\" file.txt.tar.gz")"
|
|
||||||
echo "$(gettext " jkazip -d file.7z")"
|
echo "$(gettext " jkazip -d file.7z")"
|
||||||
echo "$(gettext " jkazip -c \"tar.xz\" directory")"
|
echo "$(gettext " jkazip -c ouputfile.tar.gz directory")"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$(gettext " Supported formats: tar, gzip, bzip2, xzip, lzip, 7z, zip and rar")"
|
echo "$(gettext " Supported formats: tar, gzip, bzip2, xzip, lzip, 7z, zip and rar")"
|
||||||
echo "$(gettext " Only one file or directory (some formats don't support directories), for more options use the each program individualy")"
|
echo "$(gettext " Only one file or directory (some formats don't support directories), for more options use the each program individualy")"
|
||||||
@@ -134,141 +57,108 @@ elif [ $1 = "-v" ];then
|
|||||||
echo
|
echo
|
||||||
elif [ $1 = "-d" ];then
|
elif [ $1 = "-d" ];then
|
||||||
if [ -z $2 ];then
|
if [ -z $2 ];then
|
||||||
echo "$(gettext "No file or directory specified")"
|
error "$(gettext "No file or directory specified")"
|
||||||
exit
|
exit
|
||||||
elif [ $2 = "-f" ];then
|
|
||||||
files=1
|
|
||||||
elif [ -f $2 ];then
|
elif [ -f $2 ];then
|
||||||
files=0
|
printf -- "$(gettext "File %s will be decompressed")" "$2"
|
||||||
echo "$(gettext "File %s will be decompressed")" "$2"
|
echo
|
||||||
else
|
else
|
||||||
printf -- "$(gettext "%s no such file or directory")" "$2"
|
error "$(gettext "%s no such file or directory")" "$2"
|
||||||
echo
|
echo
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [ $files -eq 0 ];then
|
entrada=$2
|
||||||
decompress 0 $2
|
sacaFormato $entrada
|
||||||
elif [ $files -eq 1 ];then
|
case $formato in
|
||||||
if [ -d $4 ];then
|
"tar" | "tar.xz" | "tar.lz" | "tar.gz" | "tar.bz2" | "tgz" | "tbz" | "txz" | "tlz")
|
||||||
printf -- "$(gettext "Directory %s will be decompressed")" "$4"
|
tar xvf $entrada
|
||||||
echo
|
msg2 $entrada
|
||||||
elif [ -f $4 ];then
|
;;
|
||||||
printf -- "$(gettext "File %s will be decompressed")" "$4"
|
"7z")
|
||||||
echo
|
7z x $entrada
|
||||||
else
|
msg2 $entrada
|
||||||
printf -- "$(gettext "%s no sush a file or directory")" "$4"
|
;;
|
||||||
echo
|
"zip")
|
||||||
exit
|
unzip $entrada
|
||||||
fi
|
msg2 $entrada
|
||||||
decompress $3 $4
|
;;
|
||||||
fi
|
"gz" | "lz")
|
||||||
|
formato="${formato}ip"
|
||||||
|
$formato -dk $entrada
|
||||||
|
msg2 $entrada
|
||||||
|
;;
|
||||||
|
"xz")
|
||||||
|
$formato -dk $entrada
|
||||||
|
msg $entrada
|
||||||
|
;;
|
||||||
|
"bz2")
|
||||||
|
bzip2 -dk $entrada
|
||||||
|
msg $entrada
|
||||||
|
;;
|
||||||
|
"rar")
|
||||||
|
unrar x $entrada
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "$(gettext "File extension %s are not supported")" $formato
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
elif [ $1 = "-c" ];then
|
elif [ $1 = "-c" ];then
|
||||||
|
salida=$2
|
||||||
if [ -z $3 ];then
|
if [ -z $3 ];then
|
||||||
echo "$(gettext "No file or directory specified")"
|
echo "$(gettext "No file or directory specified")"
|
||||||
exit
|
exit
|
||||||
elif [ -d $3 ];then
|
|
||||||
printf -- "$(gettext "The directory %s will be compressed")" "$3"
|
|
||||||
echo
|
|
||||||
elif [ -f $3 ];then
|
|
||||||
printf -- "$(gettext "The file %s will be compressed")" "$3"
|
|
||||||
echo
|
|
||||||
else
|
else
|
||||||
printf -- "$(gettext "%s no such file or directory")" "$3"
|
for i in $@
|
||||||
echo
|
do
|
||||||
exit
|
if [[ $i != $1 && $i != $2 ]];then
|
||||||
fi
|
if [ ! -d $i -a ! -f $i ];then
|
||||||
if [ -z $2 ];then
|
printf -- "$(gettext "%s no such file or directory")" "$3"
|
||||||
echo "$(gettext "No format specified")"
|
echo
|
||||||
elif [ $2 = "tar" ] 2> /dev/null ;then
|
exit
|
||||||
tar cvf $3.tar $3
|
fi
|
||||||
if [ $? -eq 0 ];then
|
fi
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
done
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "tar.gz" ] 2> /dev/null ;then
|
|
||||||
tar cvzf $3.tar.gz $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "tar.bz2" ] 2> /dev/null ;then
|
|
||||||
tar cvjf $3.tar.bz2 $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "tar.xz" ] 2> /dev/null ;then
|
|
||||||
tar cvJf $3.tar.xz $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "tar.xz" ] 2> /dev/null ;then
|
|
||||||
tar cvf $3.tar.lz --lzip $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "tlz" ] 2> /dev/null ;then
|
|
||||||
tar cvf $3.tlz --lzip $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "tbz2" ] 2> /dev/null ;then
|
|
||||||
tar cvjf $3.tbz2 $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "tgz" ] 2> /dev/null ;then
|
|
||||||
tar cvjf $3.tgz $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "txz" ] 2> /dev/null ;then
|
|
||||||
tar cvJf $3.txz $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "7z" -o $2 = "7zip" ] 2> /dev/null ;then
|
|
||||||
7z a $3.7z $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "zip" ] 2> /dev/null ;then
|
|
||||||
zip $3.zip $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "gz" -o $2 = "gzip" ] 2> /dev/null ;then
|
|
||||||
gzip -9k $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "bz2" -o $2 = "bzip2" ] 2> /dev/null ;then
|
|
||||||
bzip2 -9k $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "lz" -o $2 = "lzip" ] 2> /dev/null ;then
|
|
||||||
lzip -9k $3
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
printf -- "$(gettext "%s has been compressed")" "$3"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
elif [ $2 = "rar" ] 2> /dev/null ;then
|
|
||||||
echo "$(gettext "Format rar are not supported for compression")"
|
|
||||||
else
|
|
||||||
printf -- "$(gettext "Format %s unknown")" "$2"
|
|
||||||
echo
|
|
||||||
fi
|
fi
|
||||||
|
files=$3
|
||||||
|
for (( i=4; i<=$#; i++))
|
||||||
|
do
|
||||||
|
files="$files $(echo $* | cut -f$i -d" ")"
|
||||||
|
done
|
||||||
|
sacaFormato $salida
|
||||||
|
case $formato in
|
||||||
|
"tar" | "tar.xz" | "tar.lz" | "tar.gz" | "tar.bz2" | "tgz" | "tbz" | "txz" | "tlz")
|
||||||
|
tar cvfa $salida $files
|
||||||
|
msg $files
|
||||||
|
;;
|
||||||
|
"7z")
|
||||||
|
7z a $salida $files
|
||||||
|
msg $files
|
||||||
|
;;
|
||||||
|
"zip")
|
||||||
|
zip $salida $files
|
||||||
|
msg $files
|
||||||
|
;;
|
||||||
|
"gz" | "lz")
|
||||||
|
formato="${formato}ip"
|
||||||
|
$formato -9kc $3 > $salida
|
||||||
|
msg $3
|
||||||
|
;;
|
||||||
|
"xz")
|
||||||
|
$formato -9kc $3 > $salida
|
||||||
|
msg $3
|
||||||
|
;;
|
||||||
|
"bz2")
|
||||||
|
$formato -9kc $3 > $salida
|
||||||
|
msg $3
|
||||||
|
;;
|
||||||
|
"rar")
|
||||||
|
error "$(gettext "rar compression are not supported")"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "$(gettext "File extension %s are not supported")" $formato
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
echo "$(gettext "Unknown option")"
|
echo "$(gettext "Unknown option")"
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user