Linux Compression Humanized
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.7 KiB

3 years ago
  1. #!/bin/bash
  2. function check()
  3. {
  4. local a=false
  5. echo -e "Verification of compression systems:\n"
  6. echo -e "Systems\t\t\tStatus"
  7. echo "----------------------------------"
  8. for i in "rar" "unrar" "tar" "bzip2" "gzip" "zip" "7za"
  9. do
  10. if ! [ -x "$(command -v $i)" ]
  11. then
  12. echo -e "$i\t\t\t\e[91mNot Installed\e[0m"
  13. $a = true
  14. else
  15. echo -e "$i\t\t\t\e[32mInstalled\e[0m"
  16. fi
  17. done
  18. if $a
  19. then
  20. echo -e "\nIn order to use all the extensions install the packages: tar, bzip2, gzip, zip, 7za, rar, unrar"
  21. fi
  22. echo ""
  23. exit 0
  24. }
  25. function rarInstall(){
  26. if [[ $(uname -m) -eq "x86_64" ]]
  27. then
  28. RAR_URL="https://www.rarlab.com/rar/rarlinux-x64-5.9.1.tar.gz"
  29. RAR_FILE="rarlinux-x64-5.9.1.tar.gz"
  30. else
  31. RAR_URL="https://www.rarlab.com/rar/rarlinux-5.9.1.tar.gz"
  32. RAR_FILE="rarlinux-5.9.1.tar.gz"
  33. fi
  34. wget $RAR_URL
  35. tar -zxvf $RAR_FILE
  36. cd rar
  37. cp -v rar unrar /usr/local/bin/
  38. cd ..
  39. rm -r rar $RAR_FILE
  40. echo "rar/unrar installed."
  41. }
  42. function install()
  43. {
  44. echo -e "Install dependencies\n"
  45. if [ "$UID" != "0" ]; then
  46. echo " Only root can execute this script, sorry."
  47. echo " Try 'sudo $@'"
  48. exit 0
  49. fi
  50. if [ -e "$(command -v rar)" ]
  51. then
  52. echo "rar installed."
  53. else
  54. rarInstall
  55. fi
  56. if [ -x "$(command -v apt)" ]
  57. then
  58. echo -e "APT system detected\n"
  59. apt install -y tar bzip2 gzip zip p7zip-full 1> /dev/null
  60. elif [ -n "$(grep "centos" /etc/*-release)" ]
  61. then
  62. echo -e "CentOS system detected\n"
  63. yum install -y -q epel-release 1> /dev/null
  64. rpm -U --quiet http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm 1> /dev/null
  65. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 1> /dev/null
  66. yum repolist 1> /dev/null
  67. yum install -y -q tar bzip2 gzip zip p7zip 1> /dev/null
  68. elif [ -x "$(command -v dnf)" ]
  69. then
  70. echo -e "DNF system detected\n"
  71. dnf install -y -q tar bzip2 gzip zip p7zip 1> /dev/null
  72. elif [ -x "$(command -v yum)" ]
  73. then
  74. echo -e "Yum system detected\n"
  75. yum install -y -q tar bzip2 gzip zip p7zip 1> /dev/null
  76. elif [ -x "$(command -v pacman)" ]
  77. then
  78. echo -e "Pacman system detected\n"
  79. pacman -Sqy --noconfirm tar bzip2 gzip zip p7zip 1> /dev/null
  80. elif [ -x "$(command -v zypper)" ]
  81. then
  82. echo -e "Zypper system detected\n"
  83. zypper install -y tar bzip2 gzip zip p7zip-full 1> /dev/null
  84. else
  85. echo -e "System installer not detected\n"
  86. fi
  87. echo -e "\nDependencies installation finished\n"
  88. exit 0
  89. }