function modules
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
function check()
|
||||
{
|
||||
local a=false
|
||||
echo -e "Verification of compression systems:\n"
|
||||
echo -e "Systems\t\t\tStatus"
|
||||
echo "----------------------------------"
|
||||
for i in "rar" "unrar" "tar" "bzip2" "gzip" "zip" "7za"
|
||||
do
|
||||
if ! [ -x "$(command -v $i)" ]
|
||||
then
|
||||
echo -e "$i\t\t\t\e[91mNot Installed\e[0m"
|
||||
$a = true
|
||||
else
|
||||
echo -e "$i\t\t\t\e[32mInstalled\e[0m"
|
||||
fi
|
||||
done
|
||||
|
||||
if $a
|
||||
then
|
||||
echo -e "\nIn order to use all the extensions install the packages: tar, bzip2, gzip, zip, 7za, rar, unrar"
|
||||
fi
|
||||
echo ""
|
||||
exit 0
|
||||
}
|
||||
|
||||
function rarInstall(){
|
||||
|
||||
if [[ $(uname -m) -eq "x86_64" ]]
|
||||
then
|
||||
RAR_URL="https://www.rarlab.com/rar/rarlinux-x64-5.9.1.tar.gz"
|
||||
RAR_FILE="rarlinux-x64-5.9.1.tar.gz"
|
||||
else
|
||||
RAR_URL="https://www.rarlab.com/rar/rarlinux-5.9.1.tar.gz"
|
||||
RAR_FILE="rarlinux-5.9.1.tar.gz"
|
||||
fi
|
||||
wget $RAR_URL
|
||||
tar -zxvf $RAR_FILE
|
||||
cd rar
|
||||
cp -v rar unrar /usr/local/bin/
|
||||
cd ..
|
||||
rm -r rar $RAR_FILE
|
||||
echo "rar/unrar installed."
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
echo -e "Install dependencies\n"
|
||||
|
||||
if [ "$UID" != "0" ]; then
|
||||
echo " Only root can execute this script, sorry."
|
||||
echo " Try 'sudo $0 $DEST'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -e "$(command -v rar)" ]
|
||||
then
|
||||
echo "rar installed."
|
||||
else
|
||||
rarInstall
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v apt)" ]
|
||||
then
|
||||
echo -e "APT system detected\n"
|
||||
apt install -y tar bzip2 gzip zip p7zip-full 1> /dev/null
|
||||
elif [ -n "$(grep "centos" /etc/*-release)" ]
|
||||
then
|
||||
echo -e "CentOS system detected\n"
|
||||
yum install -y -q epel-release 1> /dev/null
|
||||
rpm -U --quiet http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm 1> /dev/null
|
||||
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 1> /dev/null
|
||||
yum repolist 1> /dev/null
|
||||
yum install -y -q tar bzip2 gzip zip p7zip 1> /dev/null
|
||||
elif [ -x "$(command -v dnf)" ]
|
||||
then
|
||||
echo -e "DNF system detected\n"
|
||||
dnf install -y -q tar bzip2 gzip zip p7zip 1> /dev/null
|
||||
elif [ -x "$(command -v yum)" ]
|
||||
then
|
||||
echo -e "Yum system detected\n"
|
||||
yum install -y -q tar bzip2 gzip zip p7zip 1> /dev/null
|
||||
elif [ -x "$(command -v pacman)" ]
|
||||
then
|
||||
echo -e "Pacman system detected\n"
|
||||
pacman -Sqy --noconfirm tar bzip2 gzip zip p7zip 1> /dev/null
|
||||
elif [ -x "$(command -v zypper)" ]
|
||||
then
|
||||
echo -e "Zypper system detected\n"
|
||||
zypper install -y tar bzip2 gzip zip p7zip-full 1> /dev/null
|
||||
else
|
||||
echo -e "System installer not detected\n"
|
||||
fi
|
||||
|
||||
echo -e "\nDependencies installation finished\n"
|
||||
exit 0
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
function compressor()
|
||||
{
|
||||
case $1 in
|
||||
*.tar)
|
||||
tar -cvf $1 $2
|
||||
;;
|
||||
*.tar.gz | *.tgz)
|
||||
tar -czvf $1 $2
|
||||
;;
|
||||
*.tar.bz2 | *.tbz | *.tbz2 | *.tb2)
|
||||
tar -c $2 | bzip2 > $1
|
||||
;;
|
||||
*.tar.xz | *.txz)
|
||||
tar -cJf $1 $2
|
||||
;;
|
||||
*.bz2)
|
||||
bzip2 -c $2 > $1
|
||||
;;
|
||||
*.gz)
|
||||
gzip -c $2 > $1
|
||||
;;
|
||||
*.zip)
|
||||
zip -r $1 $2
|
||||
;;
|
||||
*.7z)
|
||||
7za a $1 $2
|
||||
;;
|
||||
*.rar)
|
||||
rar a $1 $2
|
||||
;;
|
||||
*)
|
||||
echo "Extension not found."
|
||||
echo -e "For more information run 'lch --help'\n"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -e "\nDone"
|
||||
exit 0
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
function decompressor()
|
||||
{
|
||||
case $1 in
|
||||
*.tar)
|
||||
tar -xvf $1
|
||||
;;
|
||||
*.tar.gz | *.tgz)
|
||||
tar -xzvf $1
|
||||
;;
|
||||
*.tar.bz2 | *.tbz | *.tbz2 | *.tb2)
|
||||
tar xjf $1
|
||||
;;
|
||||
*.tar.xz | *.txz)
|
||||
tar -xf $1
|
||||
;;
|
||||
*.bz2)
|
||||
bzip2 -d $1
|
||||
;;
|
||||
*.gz)
|
||||
gzip -d $1
|
||||
;;
|
||||
*.zip)
|
||||
unzip $1
|
||||
;;
|
||||
*.7z)
|
||||
7za e $1
|
||||
;;
|
||||
*.rar)
|
||||
unrar x $1
|
||||
;;
|
||||
*)
|
||||
echo "Extension not found."
|
||||
echo -e "For more information run 'lch --help'\n"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -e "\nDone"
|
||||
exit 0
|
||||
}
|
||||
Reference in New Issue
Block a user