idd.sh: added ability to find package manager for pv

This commit is contained in:
Molluk 2017-09-29 13:09:07 -07:00
parent 3d8981362f
commit e72464b0a8

26
idd.sh
View File

@ -85,7 +85,28 @@ Quit(){
exit 0; exit 0;
fi fi
} }
FindMgr(){
use_which=$(which {dnf,pacman,xbps-install})
base_dir="/usr/bin"
printf "${BWHITE}\n\nGetting Dependencies...${NC}\n\n"
if [ -f "${base_dir}/apt" ] || [ -f "${base_dir}/apt-get" ];then
apt-get update; apt-get -y install pv
elif [ "${use_which}" = "${base_dir}/dnf" ];then
dnf -y install pv
elif [ "${use_which}" = "${base_dir}/pacman" ];then
pacman -Sy pv
elif [ "${use_which}" = "${base_dir}/xbps-install" ];then
xbps-install -Sy pv
else
printf "\n${LRED}No suitible package manager was found!${NC}\n\n"
fi
return
}
case "$1" in case "$1" in
-d) if [ -f /usr/bin/pv ];then -d) if [ -f /usr/bin/pv ];then
@ -140,6 +161,9 @@ case "$1" in
usage: idd -d [directory] usage: idd -d [directory]
""" """
;; ;;
-t) FindMgr
;;
*) if [ -f /usr/bin/pv ];then *) if [ -f /usr/bin/pv ];then
clear clear
printf "${LCYAN}idd - interactive dd${NC}\n" printf "${LCYAN}idd - interactive dd${NC}\n"
@ -186,7 +210,7 @@ case "$1" in
echo echo
printf "${LGREEN}Done writing file${NC}\n" printf "${LGREEN}Done writing file${NC}\n"
else else
echo "${0}: pv command not found in /usr/bin" FindMgr && ${0}
fi fi
;; ;;
esac esac